我正在尝试准备一个自动调整图像文件大小的脚本。我找到了这个LINK,但我不知道如何使用它。
有没有人能提供一个我可以用作起点的工作脚本?
发布于 2015-04-26 09:49:14
以下函数用于调整图像大小:
(define (resize-image filename-in filename-out new-width new-height)
(let* ((image (car (gimp-file-load RUN-NONINTERACTIVE filename-in "")))
(drawable (car (gimp-image-active-drawable image)))
)
(gimp-image-scale image new-width new-height)
(gimp-file-save RUN-NONINTERACTIVE image drawable filename-out "")
)
)现在,调整目录中所有jpg的大小:
(define (file-basename filename)
(let*
(
(broken-up (strbreakup filename "."))
(wo-last-r (cdr (reverse broken-up)))
(wo-last (reverse wo-last-r))
(result "")
)
(while wo-last
(set! result (string-append result (car wo-last) ))
(set! wo-last (cdr wo-last))
(if (> (length wo-last) 0) (set! result (string-append result ".")))
)
result
)
)
(define (ex_09 file-pattern new-width new-height )
(let* ( (filelist (cadr (file-glob file-pattern 1))))
(while (not (null? filelist))
(let* ( (cur-file (car filelist)) )
(resize-image
cur-file
(string-append (file-basename cur-file) "_resized.jpg")
100
100
)
(set! filelist (cdr filelist))
)
)
)
)我想这就是你的答案。
发布于 2016-04-23 01:41:28
代码来自这个地址。http://www.adp-gmbh.ch/misc/tools/script_fu/ex_09.html
开箱即用,这对我不起作用。我做了一些修改:
在file_basename.scm文件中,我删除了一些我没有用到的东西。因此,调整大小的文件创建在与原始文件相同的目录中:
(define (file-basename filename)
(let*
(
(broken-up (strbreakup filename "."))
(wo-last-r (cdr (reverse broken-up)))
(wo-last (reverse wo-last-r))
(car broken-up)
)
)在ex_09.scm文件中:我只使用了新宽度和新高度变量。
(define (ex_09 file-pattern new-width new-height )
(let* ( (filelist (cadr (file-glob file-pattern 1))))
(while (not (null? filelist))
(let* ( (cur-file (car filelist)) )
(resize-image
cur-file
(string-append (file-basename cur-file) "_resized.jpg")
new-width
new-height
)
(set! filelist (cdr filelist))
)
)
)
) Hop这很有帮助!感谢你的RenéNyffenegger的代码。:)
https://stackoverflow.com/questions/29865702
复制相似问题