2014年6月13日金曜日

Python-Fuで切り抜きスクリプトを作ってみた。

参考ページ
#!/usr/bin/env python


# Crop images in GIMP Python

from gimpfu import *

def crop(testfp):
    pngimg = pdb.file_png_load(testfp, testfp)
    pngimg.crop(100, 100, 0, 50) # Xが0、Yが50からX,Yともに100ずつ切り抜く
    pdb.file_png_save_defaults(pngimg, pngimg.active_drawable, testfp, testfp)

register(
    "python-fu-crop-sample",
    "Crop an image",
    "Crops the image.",
    "programmm",
    "programmm",
    "2014",
    "test crop",
    "*",
    [
        (PF_STRING, "string","Image file path", None)
    ],
    [],
    crop,
    menu="<Image>/Filters")

main()

Ubuntu 14.04 でPython-Fuを使う。

参考ページ1
参考ページ2

サンプルをインストールしてみる。 Writing GIMP Scripts and Plug-Insからhelloworld.pyをダウンロードする。

$ cp ~/Downloads/helloworld.py ~/.gimp-2.8/plug-ins
$ chmod a+x ~/.gimp-2.8/plug-ins/helloworld.py

gimpを起動→フィルター→Python-Fu→Consoleを選択



























Browseをクリック
















適応をクリック




























こんな感じで引数を入れて実行すると文字入りの画像が作られる。

2014年5月30日金曜日

SSHでさくらVPSのUbuntu Serverを操作する。

まずクライアント・サーバの公開鍵、秘密鍵を作成する
$ mkdir .ssh
$ cd .ssh
$ ssh-keygen -t rsa
id_rsa.pubが公開鍵 id_rsaが秘密鍵 クライアントとサーバーの公開鍵を交換する。 方法は  scpなりFTPなり何でもOK。 交換した公開鍵をauthorized_keysに登録する。
$ touch authorized_keys
$ cat 公開鍵をコピーしたパス/id_rsa.pub >> authorized_keys
つぎにクライアントでconfigファイルを作成する。
$ cd .ssh
$ touch config
$ nano config
Host anywhere_vps
  HostName 1.222.333.55
  Port 22
  User anywhere_user
  IdentityFile ~/.ssh/authorized_keys
最後にアクセスしてみる
$ ssh anywhere_vps
アクセスできない場合
 ・ufwの設定を確認してみるか、可能なら一時的に無効にしてみる
 ・/etc/hosts.allowでクライアントからのアクセスが許可されているかを確認
 ・/etc/hosts.denyでアクセス拒否されていないか確認

2014年5月27日火曜日

Ubuntu 14.04で無線LANを接続する

参考ページ
$ sudo apt-get install linux-firmware-nonfree
で再起動。

2014年5月20日火曜日

Ubuntu 14.04で Dartium error on startupに遭遇した場合の対処

参考ページ
$ sudo ln -s /lib/i386-linux-gnu/libudo.1 /lib/i386-linux-gnu/libudev.so.0
としてシンボリックリンクを作成することで解決された。