CentOS 下使用 GIMP 进行文件格式转换
一 安装与准备
sudo yum install gimp gimp-help gimp-data-extrassudo dnf install gimp gimp-help gimp-data-extrassudo dnf install ImageMagick),便于前置检查或与其他工具配合。二 图形界面转换步骤
三 命令行非交互转换
gimp -i -b '(let* ((image (car (gimp-file-load RUN-NONINTERACTIVE "input.jpg" "input.jpg")))
(drawable (car (gimp-image-get-active-layer image))))
(gimp-file-save RUN-NONINTERACTIVE image drawable "output.png" "output.png")
(gimp-image-delete image)
(gimp-quit 0))' -b '(gimp-quit 0)'
gimp -i -b '(let* ((files (cadr (file-glob "*.jpg" 1))))
(while (not (null? files))
(let* ((f (car files))
(img (car (gimp-file-load RUN-NONINTERACTIVE f f)))
(lay (car (gimp-image-get-active-layer img))))
(gimp-file-save RUN-NONINTERACTIVE img lay
(string-append (substring f 0 (- (string-length f) 4)) ".png")
(string-append (substring f 0 (- (string-length f) 4)) ".png"))
(gimp-image-delete img))
(set! files (cdr files))))
(gimp-quit 0)' -b '(gimp-quit 0)'
四 命令行批量转换的替代方案
convert input.jpg output.png
for f in *.jpg; do convert "$f" "${f%.jpg}.png"; done
mogrify -resize 800x600 *.jpg