我正在编写一个脚本(我的第一个脚本-fu)来将.jpeg导出到.avif和.webp,并且我想为web优化文件。在某个地方,我读到了从RGB更改为索引调色板的建议,所以我实现了过程gimp-image-convert-indexed。我本来期待更小的,网络优化的文件,但相反的发生了。输出结果产生了巨大的文件:
原版jpeg: 7.510 KB
导出的文件没有gimp-图像转换索引:
.avif: 95 KB
.webp: 2.052 KB
导出文件与gimp-图像转换-索引:
.avif: 6.337 KB
.webp: 19.393 KB
,我发送参数错误了吗?或者说,使用“gimp图像转换索引”的整个想法都是胡说八道吗?
(旁白:我初学者的剧本还有其他明显的缺陷吗?)(欢迎评论和提示。)
convert.scm:
(define (filename-basename orig-name)
(car (strbreakup orig-name "."))
)
(define
(convert in_filename WebP Avif)
(let* (
(image (car (gimp-file-load RUN-NONINTERACTIVE in_filename in_filename)))
(drawable (car (gimp-image-flatten image)))
(outWebP (string-append (filename-basename in_filename) ".webP"))
(outAvif (string-append (filename-basename in_filename) ".avif"))
)
; small output files sizes without this line, huge with:
(gimp-image-convert-indexed image CONVERT-DITHER-FS CONVERT-PALETTE-WEB 0 0 1 "")
(cond ((equal? WebP 1)
(gimp-message "exporting as .webP")
(file-webp-save2 RUN-NONINTERACTIVE image drawable outWebP outWebP 0 0 90 100 0 0 0 0 0 0 0 0 0 0)))
(cond ((equal? Avif 1)
(gimp-message "exporting as .avif")
(file-heif-av1-save RUN-NONINTERACTIVE image drawable outAvif outAvif 50 0)))
(gimp-image-delete image)
)
)windows下的调用:
gimp-console-2.10 -idf -b "(convert \"IMG.jpg\" 1 1)" -b "(gimp-quit 0)"发布于 2022-07-17 13:30:24
转换为索引是无稽之谈,因为输出格式不支持它。颜色索引可能会减少PNG上的图像大小(这是我所知道的颜色索引和全RGB格式的唯一格式)。
我不认为WebP/Avif比Jpeg有多大好处,因为它的最终视觉质量是一样的。换句话说,JPEG选项也同样有效:降低质量或增加色度次采样。
另外,对于批处理转换图像,ImageMagick比Gimp更容易编写代码。
https://stackoverflow.com/questions/73010267
复制相似问题