大量の画像ファイルにテキストレイヤーを追加してGIMP形式で保存したい。
その準備でpython-fuの機能をいくつか調べた。
正直初めてシェーム?いじったときよりかなり日本語情報あって助かった。
GIMP pythonコンソールで縦書きのテキストレイヤーを追加するスクリプト
#######################################
#一番下のレイヤーの情報取得
image = gimp.image_list()[0]
#テキストレイヤーを追加する
text = unicode("テキストレイヤー", "utf-8")
text_layer = pdb.gimp_text_layer_new(image, text, "MS Gothic", 32, 0)
#テキストレイヤーの位置指定
new_left_up_x = image.height / 4
new_left_up_y = image.width / 4
text_layer.set_offsets(new_left_up_x, new_left_up_y)
#新規作成したテキストレイヤーを有効にする
image.add_layer(text_layer)
#テキストレイヤーを縦書きにする
pdb.gimp_text_layer_set_base_direction(text_layer,2)
#テキストレイヤーのサイズを変更する
text_layer_height = image.height / 4
text_layer_width = image.width / 6
pdb.gimp_text_layer_resize(text_layer, text_layer_width, text_layer_height)
#GIMP形式で保存
save_path = "C:\\Users\\user\\Desktop\\test.xcf"
pdb.gimp_file_save(image,text_layer,save_path,save_path)
#######################################