昨日作っておいたGimpPluginをイザ使おうと思ったら、緑を反転させる作業もあるじゃないですか・・・
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from gimpfu import *
import os
def plugin_main(image, drawable, dir_path, Comp_lv, Inv_Green):
for layer in image.layers:
image_name = layer.name.lower().replace(".png", "")
#pdb.gimp_message(image_name)
decompose_type = "RGB"
layers_mode = 1
decompose_images = pdb.plug_in_decompose(image, drawable, decompose_type, layers_mode)
gimp.Display(decompose_images[0])
for layer in decompose_images[0].layers:
if (layer.name.find('green') > -1 and Inv_Green):
pdb.gimp_invert(layer)
path="%s/%s.png" % (dir_path, image_name + "_invert_" +layer.name)
else:
path="%s/%s.png" % (dir_path, image_name + "_" +layer.name)
#pdb.gimp_message(path)
pdb.file_png_save(image, layer, path, path, 0, Comp_lv, 1, 0, 0, 0, 1)
register(
"python_fu_decompose_invert_image",
"decompose Image",
"Create 3 image files",
"",
"",
"2018/8/1",
"<Image>/Filters/Languages/Python-Fu/decomposeInvertImage",
"RGB*, GRAY*",
[
(PF_DIRNAME, "directory_path", "Save directoryPath", "."),
(PF_SLIDER, "Comp_lv", "Compression level", 1, (0, 9, 1)),
(PF_BOOL, "Inv_Green", "Invert GreenImage", True),
],
[],
plugin_main)
main()