代码之家  ›  专栏  ›  技术社区  ›  Richard Barraclough

使用gimp批量调整图像大小

  •  0
  • Richard Barraclough  · 技术社区  · 6 年前

    我想调整目录中每个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) 只打印文件名!

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

    0 回复  |  直到 5 年前
        1
  •  0
  •   arx    5 年前

    问题源于引用命令行的方式。这应该有效:

    "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
    

    最后,问题中的代码块被格式化为块外的最后一个圆括号,这使得它很容易丢失。我已经更新了。