我在使用 GIMP 的 script-fu 方面相当新,我正在编写一个脚本来遍历 .tif 图像文件的完整文件夹,将它们的大小调整为最大尺寸为 1200 像素,同时保持比例图片。然后它将文件保存为 .png 文件类型。
我遇到但似乎无法找到答案的问题是:
错误:(:1)汽车:参数1必须是:对
据我所知,这是说我正在尝试查找没有内容的列表的第一个条目,但我没有看到任何进一步的例子,这将是一个问题。我已经在许多网站上寻求帮助,并且对脚本进行了一段时间的修改,所以我认为是时候寻求帮助了。不幸的是,据我所知,GIMP 的文档并不是很可靠。我是在某个地方遗漏了仍然导致此错误的 car() 还是现在指的是更模棱两可的东西?
提前致谢...
(script-fu-register
"batchresize"
"Batch Resize"
"Resizes all images in folder to the desired maximum size and saves as .png"
"name"
"(c) 2017"
"March 2017"
""
SF-VALUE "Maximum Dimension" "1200"
SF-STRING "Target Folder" "/Scripts/Input/*.tif"
)
(script-fu-menu-register "batchresize" "<Image>/File/Batch"
)
(define
(batchresize maximum targetfolder
)
(let*
(
(filelist
(car
(file-glob targetfolder 1
)
)
)
(width 1200
)
(height 1200
)
)
(while
(not
(null? filelist
)
)
(let*
(
(filename
(car filelist
)
)
(image
(car
(gimp-file-load RUN-NONINTERACTIVE filename filename
)
)
)
(drawable
(car
(gimp-image-get-active-layer image
)
)
)
)
(Set! width car(gimp-image-width)
)
(Set! height car(gimp-image-height)
)
(if
(> height width
)
(set! proportion
(/ width height
)
)
(set! height maximum
)
(set! width
(* maximum proportion
)
)
(if
(< height width
)
(set! proportion
(/ height width
)
)
(set! width maximum
)
(set! height
(* maximum proportion
)
)
(if
(= height width
)
(set! height maximum
)
(set! width maximum
)
)
(gimp-image-scale-full image width height INTERPOLATION-CUBIC
)
(file-png-save RUN-NONINTERACTIVE image drawable filename filename 1 0 0 0 0 0 0
)
)
(gimp-image-delete image
)
)
(set! filelist
(cdr filelist
)
)
)
)
)
)