我有一堆屏幕截图,我想裁剪窗口边框。我想使用脚本将它们全部裁剪。
我可以访问 GIMP,但不能访问 Photoshop,所以我认为 GIMP 将是最好的工具。我之前没有使用 GIMP 编写脚本,所以我查找了一些 GIMP 裁剪脚本。我找到的都与我想要的相似,但不完全一样。我认为将脚本更改为我需要的内容将是一件简单的事情。但是由于我不熟悉脚本语言,所以事实证明它比我想象的要困难。我在这里找到了一个很棒的自动裁剪脚本。有人可以帮我定制我需要的东西吗?
(define (script-fu-rs-center-crop filename outfilename width height)
(let* ((image (car (gimp-file-load RUN-NONINTERACTIVE filename filename)))
(drawable (car (gimp-image-get-active-layer image))))
(let* ((original-width (car (gimp-image-width image)))
(original-height (car (gimp-image-height image)))
(new-width original-width)
(new-height original-height)
(offset-x 0)
(offset-y 0))
(if (<= (/ original-width original-height) (/ width height))
(gimp-image-crop image original-width (* original-width (/ height width)) 0 (/ (- original-height (* original-width (/ height width))) 2) )
(gimp-image-crop image (* original-height (/ width height)) original-height (/ (- original-width (* original-height (/ width height))) 2) 0)
)
)
(set! drawable (car (gimp-image-get-active-layer image)))
(gimp-file-save RUN-NONINTERACTIVE image drawable outfilename outfilename)
(gimp-image-delete image)))
所有照片的整体尺寸都不相同。但它们在顶部、左侧、右侧和底部的像素数量都相同,我想裁剪出来。因此,假设图像具有像素尺寸width
,height
并且我想删除t_junk
顶部的b_junk
像素、底部的l_junk
像素、左侧的r_junk
像素和右侧的像素。所以我希望新的图像尺寸是width - l_junk - r_junk
and height - t_junk - b_junk
。