GIMP Script-Fu:使用蒙版批量编辑图像

GIMP Script-Fu: batch edit images with a mask

我有数千张图片,我必须从中删除近 1/2 的内容。

我每年都会:

这是我为自动执行此操作而编写的代码:

(define  (script-fu-auto-mask-image Mask InImage OutImage)
  (let* (
      Image (car (file-tiff-load RUN-NONINTERACTIVE InImage InImage)) ImgW (car (gimp-image-width Image)) ImgH (car (gimp-image-height Image))
      PrimeLayer (car (gimp-image-get-active-layer Image))
      (gimp-layer-add-alpha PrimeLayer))
      (gimp-layer-new Image ImgW ImgH RGB-IMAGE MaskLayer 0 LAYER-MODE-NORMAL)
      (gimp-file-load-layer RUN-NONINTERACTIVE Image Mask)
      (gimp-image-set-active-layer Image MaskLayer)
      (gimp-image-select-color mask CHANNEL-OP-ADD drawable (0 0 0))
      (gimp-image-set-active-layer Image PrimeLayer)
      ;(gimp-edit-clear drawable)
      (gimp-drawable-edit-clear drawable)
      (gimp-image-remove-layer Image MaskLayer)
      (file-png-save-defaults RUN-NONINTERACTIVE Image drawable OutImage OutImage)
    )
  (gimp-displays-flush)
  (gimp-quit TRUE)
)

这是我用来启动东西和反馈的终端命令

gimp -i -c -b script-fu-auto-mask-image  "Pictures/test/mask.png" "Pictures/test/DSC00805.tif" "test.png"
bps: 16
load_contiguous
bytes_per_pixel: 6, format: 6
batch command executed successfully

它冻结然后我必须 ctrl+c

我已经在 GIMP 控制台中尝试了以下操作:

(file-tiff-load RUN-INTERACTIVE "Pictures/test/DSC00805.tif" "Pictures/test/DSC00805.tif")

它 returns (1) 然后我可以看到它实际上从未在 GIMPS 底部的状态栏中加载图像 window.

我在 Ubuntu 20.04 GIMP 2.10.18(apt 不是 SNAP) 我尝试了 运行 来自 Flatpak 的 GIMP,但遇到了 GTK 模块无法加载的问题......无论如何

从字面上看,我们将不胜感激 - 如果可行,甚至是替代解决方案

它很冷,因为你告诉 gimp 开始,但没有告诉它停止。

你需要封装你现有的命令,然后添加 -b '(gimp-quit 0)'

gimp -i -c -b '(script-fu-auto-mask-image  "Pictures/test/mask.png" "Pictures/test/DSC00805.tif" "test.png")' -b '(gimp-quit 0)'