4

我想调整目录中每个 jpg 的大小。

这是我找到的 gimp 脚本。对我来说看起来很明智。

(define (batch-resize pattern)
    (let* 
        ((filelist (cadr (file-glob pattern 1))))
        (while (not (null? filelist))
            (let* (
                    (filename (car filelist))
                    (image (car (gimp-file-load RUN-NONINTERACTIVE filename filename)))
                    (drawable   (car (gimp-image-active-drawable image)))
                    (cur-width  (car (gimp-image-width image)))
                    (cur-height (car (gimp-image-height image)))
                    (width      (* 0.25 cur-width))
                    (height     (* 0.25 cur-height))
                )
                (gimp-message filename)
                (gimp-image-scale-full image width height INTERPOLATION-CUBIC)
                (let 
                    ((nfilename (string-append "thumb_" filename)))
                    (gimp-file-save RUN-NONINTERACTIVE image drawable nfilename nfilename)
                )
                (gimp-image-delete image)
            )
            (set! filelist (cdr filelist))
        )
    )
)

我将其保存为C:\Users\rwb\.gimp-2.8\scripts\batch-resize.scm然后调用

"C:\Program Files\GIMP 2\bin\gimp-console-2.8.exe" -i -b '(batch-resize "*.JPG")' -b '(gimp-quit 0)'

输出是

    >"C:\Program Files\GIMP 2\bin\gimp-console-2.8.exe" -i -b '(batch-resize "*.JPG")' -b '(gimp-quit 0)'
(gimp-console-2.8.exe:7568): LibGimpBase-WARNING **: gimp-console-2.8.exe: gimp_wire_read(): error
batch command executed successfully
batch command executed successfully

此时它只是挂起。

我期待(gimp-message filename)打印文件名,但什么也没有!

我真的不知道这里发生了什么!你能提供什么建议吗?甚至打印文件名也是一个开始。

4

1 回答 1

1

问题出在您引用命令行的方式上。这应该有效:

"c:\Program Files\GIMP 2\bin\gimp-console-2.10.exe" -b "(batch-resize \"*.JPG\")" -b "(gimp-quit 0)"

请注意,它已针对 GIMP 2.10 进行了更新。此外,用户脚本文件现在存在于:

c:\Users\rwb\AppData\Roaming\GIMP\2.10\scripts

最后,您问题中的代码块被格式化为块外的最后一个括号,这很容易错过。我已经更新了。

于 2019-08-21T21:32:04.413 回答