1
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

python-fu ファイル一括処理サンプル

Last updated at Posted at 2017-07-23

指定ディレクトリ内の画像ファイルをGIMP形式で保存する。GIMPバンドルPythonではTkinter・PYGTKが正常に動作せず、選択ダイアログが使えない為、ディレクトリパスは直接入力する。

# -*- coding: utf-8 -*-

import os

def makeGimp():

# ディレクトリパスの取得
dirPath = 'C:\'

#ファイル名の取得
fileList = os.listdir(dirPath)

#ファイルリストから順に処理
for file in fileList:
	#ロード
	filename = dirPath + os.sep + file
	raw_filename = filename
	image = pdb.gimp_file_load(filename, raw_filename)
	display = pdb.gimp_display_new(image)
	
	#xcf形式で保存
	index = raw_filename.find(".")
	filename = raw_filename[0:index] + ".xcf"
	raw_filename = filename
	drawable = pdb.gimp_image_get_active_layer(image)
	pdb.gimp_xcf_save(0, image, drawable, filename, raw_filename)
	#画像をクローズ
	pdb.gimp_display_delete(display)
1
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?