使用gimp批量调整图像大小

时间:2018-07-14 09:25:36

标签: gimp script-fu gimpfu

我想调整目录中每个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)打印文件名,但什么也不打印!

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

1 个答案:

答案 0 :(得分:0)

问题是由您引用命令行的方式引起的。这应该起作用:

$ curl  -w "HTTP Response: %{http_code} - URL: %{redirect_url}\n"  -o /dev/null  -s http://yahoo.com/
HTTP Response: 301 - URL: https://yahoo.com/
$  curl  -w "%{http_code}\n"  -o /dev/null  -s http://yahoo.com/
301
$ response=$(curl  -w "%{http_code}\n"  -o /dev/null  -s http://yahoo.com/)
$ echo $response
301
$  curl  -w "%{http_code}\n"  -o /dev/null  -s http://yahoo.com/ | cut -d' ' -f3
301
$ response=$( curl  -w "%{http_code}\n"  -o /dev/null  -s http://yahoo.com/ | cut -d' ' -f3)
$ echo $response
301

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

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

最后,问题中的代码块被格式化,并在代码块外面加上了最后的括号,这很容易遗漏。我已经更新了。