0

BIMP バッチ プロセッサ プラグインを使用して、多数の jpg 画像をバッチ編集しようとしています。これは、私の python-fu スクリプトの 1 つでは正常に機能しますが、他のスクリプトでは機能しません。画像には何もしませんが、「新しい」バージョンを保存します。

ただし、GUI のメニューから「悪い」スクリプトを選択すると、完全に機能します。

これは、バッチでは機能しないスクリプトです。

#!/usr/bin/env python

from gimpfu import *

def remove_colour(image, drawable):

    # start undo
    pdb.gimp_image_undo_group_start(image)

    #select the area by colour

    pdb.gimp_context_set_antialias(1)
    pdb.gimp_context_set_feather(1)
    pdb.gimp_context_set_feather_radius(1.0, 1.0)
    pdb.gimp_context_set_sample_merged(0)
    pdb.gimp_context_set_sample_criterion(0)
    pdb.gimp_context_set_sample_transparent(0)    
    pdb.gimp_context_set_sample_threshold_int(100)

    background = gimpcolor.RGB(255,255,255)
    pdb.gimp_context_set_background(background)

    operation = CHANNEL_OP_REPLACE
    color = gimpcolor.RGB(00,85,202)
    pdb.gimp_image_select_color(image, operation, drawable, color)

    #delete the selected area  
    pdb.gimp_drawable_edit_clear(drawable)   

    #end undo
    pdb.gimp_image_undo_group_end(image)


register(
    "python-fu-remove_colour",
    "Remove a colour",
    "Select by colour then delete",
    "A", "A", "2019",
    "remove_colour",
    "*", # type of image it works on (*, RGB, RGB*, RGBA, GRAY etc...)
    [
        # basic parameters are: (UI_ELEMENT, "variable", "label", Default)
        (PF_IMAGE, "image", "takes current image", None),
        (PF_DRAWABLE, "drawable", "Input layer", None)
        # PF_SLIDER, SPINNER have an extra tuple (min, max, step)
        # PF_RADIO has an extra tuples within a tuple:
        # eg. (("radio_label", "radio_value), ...) for as many radio buttons
        # PF_OPTION has an extra tuple containing options in drop-down list
        # eg. ("opt1", "opt2", ...) for as many options
        # see ui_examples_1.py and ui_examples_2.py for live examples
    ],
    [],
    remove_colour, menu="<Image>/Colors")  # second item is menu location

main()

これは、バッチで正常に動作するスクリプトです

#!/usr/bin/env python

from gimpfu import *

def saturate2(image, drawable):

    # start undo
    pdb.gimp_image_undo_group_start(image)

    #saturation
    hue_range = 0
    hue_offset = 0
    lightness = 0
    saturation = 100
    overlap = 0
    pdb.gimp_drawable_hue_saturation(drawable, hue_range, hue_offset, lightness, saturation, overlap)
    pdb.gimp_drawable_hue_saturation(drawable, hue_range, hue_offset, lightness, saturation, overlap)

    #end undo
    pdb.gimp_image_undo_group_end(image)


register(
    "python-fu-saturate2",
    "saturate twice",
    "Run full saturation twice",
    "A", "A", "2019",
    "Double Saturate",
    "*", # type of image it works on (*, RGB, RGB*, RGBA, GRAY etc...)
    [
        # basic parameters are: (UI_ELEMENT, "variable", "label", Default)
        (PF_IMAGE, "image", "takes current image", None),
        (PF_DRAWABLE, "drawable", "Input layer", None)
        # PF_SLIDER, SPINNER have an extra tuple (min, max, step)
        # PF_RADIO has an extra tuples within a tuple:
        # eg. (("radio_label", "radio_value), ...) for as many radio buttons
        # PF_OPTION has an extra tuple containing options in drop-down list
        # eg. ("opt1", "opt2", ...) for as many options
        # see ui_examples_1.py and ui_examples_2.py for live examples
    ],
    [],
    saturate2, menu="<Image>/Colors")  # second item is menu location

main()

エラー メッセージはありません。スクリプトはファイルを正しいフォルダーに保存しますが、編集は行われていません。繰り返しますが、メニューから選択すると問題なく動作しますが、バッチ モードでは動作しません。

どんな助けでも大歓迎です。

4

0 に答える 0