一次另存为多个文件(GIMP)

问题描述 投票:0回答:6

我有一系列 .xcf 图像,我想将其另存为 .png。我可以打开每个文件并另存为 .png 但由于图像很多,因此需要相当长的时间。

有没有办法一次性转换所有图像,或者有其他方法可以减少我在这项工作上花费的时间?

提前谢谢您。

image png gimp xcf
6个回答
4
投票

如果你安装了

imagemagick
,你可以这样做:

mogrify -format png *.xcf

这会在同一目录中自动转换它们。另请阅读

man mogrify
或此了解其他选项。


4
投票

为此,我会使用 GIMP 内的 Python 控制台 - 如果您碰巧在 Windows 中,请查看如何安装 GIMP 2.6 的 Python 扩展(在 Linux 上,它要么是未安装的,要么是安装 gimp 的问题) python 包,在 Mac OS 上可能相同)

从 GIMP 的 Python 控制台中,您可以访问巨大的 GIMP API,您可以通过查看帮助 -> 程序浏览器对话框进行检查 - 除了具有 Python 的所有其他功能(包括文件和字符串操作)之外。

你是=在Python-fu控制台中,做这样的事情是很重要的:

import glob
for fname in glob.glob("*.xcf"):
    img = pdb.gimp_file_load(fname, fname)
    img.flatten()
    new_name = fname[:-4] + ".png"
    pdb.gimp_file_save(img, img.layers[0], new_name, new_name)

(这将在 GIMP 默认使用的目录上工作 - 将 desried 目录连接到文件路径以在其他目录上工作)。

如果您多次需要这样做,请查看 gimp-Python 附带的示例插件,并将上面的代码粘贴为 GIMP 的 python 插件的核心以供您自己使用。


3
投票

您可以快速创建一个名为 SaveAll 的插件。将此代码保存到扩展名为 .scm 的文件中(例如 saveall.scm):

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 
; This program is free software; you can redistribute it and/or modify 
; it under the terms of the GNU General Public License as published by 
; the Free Software Foundation; either version 2 of the License, or 
; (at your option) any later version. 
; 
; This program is distributed in the hope that it will be useful, 
; but WITHOUT ANY WARRANTY; without even the implied warranty of 
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
; GNU General Public License for more details. 

(define (script-fu-save-all-images) 
  (let* ((i (car (gimp-image-list))) 
         (image)) 
    (while (> i 0) 
      (set! image (vector-ref (cadr (gimp-image-list)) (- i 1))) 
      (gimp-file-save RUN-NONINTERACTIVE 
                      image 
                      (car (gimp-image-get-active-layer image)) 
                      (car (gimp-image-get-filename image)) 
                      (car (gimp-image-get-filename image))) 
      (gimp-image-clean-all image) 
      (set! i (- i 1))))) 

(script-fu-register "script-fu-save-all-images" 
 "<Image>/File/Save ALL" 
 "Save all opened images" 
 "Saul Goode" 
 "Saul Goode" 
 "11/21/2006" 
 "" 
 ) 

将文件放入具有相同扩展名的plugins文件夹中 (在 Windows 上为 C:\Program Files\GIMP 2\share\gimp .0\scripts)。

然后您甚至不必重新启动应用程序。 过滤器菜单 -> Script-Fu -> 更新脚本。您将在 File 菜单(位于最底部)中看到 Save ALL 项目。对我来说它工作起来又快又简单。

这个脚本来自这里

还有另一个脚本,但我自己没有测试过。


0
投票

是的,有一种方法,而且不需要编程技能。只需安装免费的批量图像操作插件


-1
投票
{
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; This program is free software; you 
; can redistribute it and/or modify 
; it under the terms of the GNU 
; General Public License as published 
; by the Free Software Foundation; 
; either version 2 of the License, or 
; (at your option) any later version. 
; 
; This program is distributed in the
; hope that it will be useful, 
; but WITHOUT ANY WARRANTY;
; without even the implied warranty of 
; MERCHANTABILITY or FITNESS 
; FOR A PARTICULAR PURPOSE.  
; See the GNU General Public License
;  for more details. 

(define (script-fu-save-all-images inDir inSaveType 
inFileName inFileNumber) 
  (let* (
          (i (car (gimp-image-list)))
          (ii (car (gimp-image-list))) 
          (image)
          (newFileName "")
          (saveString "")
          (pathchar (if (equal? 
                 (substring gimp-dir 0 1) "/") "/" "\\"))
        )
    (set! saveString
      (cond 
        (( equal? inSaveType 0 ) ".jpg" )
        (( equal? inSaveType 1 ) ".bmp" )
        (( equal? inSaveType 2 ) ".png" )
        (( equal? inSaveType 3 ) ".tif" )
      )
    ) 
    (while (> i 0) 
      (set! image (vector-ref (cadr (gimp-image-list)) (- i 1)))
      (set! newFileName (string-append inDir 
              pathchar inFileName 
              (substring "00000" (string-length 
              (number->string (+ inFileNumber i))))
              (number->string (+ inFileNumber i)) saveString))
      (gimp-file-save RUN-NONINTERACTIVE 
                      image
                      (car (gimp-image-get-active-layer image))
                      newFileName
                      newFileName
      ) 
      (gimp-image-clean-all image) 
      (set! i (- i 1))
    )
  )
) 

(script-fu-register "script-fu-save-all-images" 
 "<Image>/File/Save ALL As" 
 "Save all opened images as ..." 
 "Lauchlin Wilkinson (& Saul Goode)" 
 "Lauchlin Wilkinson (& Saul Goode)" 
 "2014/04/21" 
 ""
 SF-DIRNAME    "Save Directory" ""
 SF-OPTION     "Save File Type" (list "jpg" "bmp" "png" "tif")
 SF-STRING     "Save File Base Name" "IMAGE"
 SF-ADJUSTMENT "Save File Start Number" 
      (list 0 0 9000 1 100 0 SF-SPINNER)
 )

}

-2
投票

此脚本在

gimp 2.8
Windows 7 中完美运行。

UCHLIN WILKINSON 保存 GIMP 中所有打开的图像。

如果您正在扫描大量图像并且只想一次性导出它们,这会很方便。它基于 Saul Goode 的脚本,扩展为提示图像基本名称、目录等。

将其保存为 Gimp 脚本目录中的 saveall.scm。例如。 〜/.gimp-2.8/scripts/

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; This program is free software; you 
; can redistribute it and/or modify 
; it under the terms of the GNU 
; General Public License as published 
; by the Free Software Foundation; 
; either version 2 of the License, or 
; (at your option) any later version. 
; 
; This program is distributed in the
; hope that it will be useful, 
; but WITHOUT ANY WARRANTY;
; without even the implied warranty of 
; MERCHANTABILITY or FITNESS 
; FOR A PARTICULAR PURPOSE.  
; See the GNU General Public License
;  for more details. 

(define (script-fu-save-all-images inDir inSaveType 
inFileName inFileNumber) 
  (let* (
          (i (car (gimp-image-list)))
          (ii (car (gimp-image-list))) 
          (image)
          (newFileName "")
          (saveString "")
          (pathchar (if (equal? 
                 (substring gimp-dir 0 1) "/") "/" "\\"))
        )
    (set! saveString
      (cond 
        (( equal? inSaveType 0 ) ".jpg" )
        (( equal? inSaveType 1 ) ".bmp" )
        (( equal? inSaveType 2 ) ".png" )
        (( equal? inSaveType 3 ) ".tif" )
      )
    ) 
    (while (> i 0) 
      (set! image (vector-ref (cadr (gimp-image-list)) (- i 1)))
      (set! newFileName (string-append inDir 
              pathchar inFileName 
              (substring "00000" (string-length 
              (number->string (+ inFileNumber i))))
              (number->string (+ inFileNumber i)) saveString))
      (gimp-file-save RUN-NONINTERACTIVE 
                      image
                      (car (gimp-image-get-active-layer image))
                      newFileName
                      newFileName
      ) 
      (gimp-image-clean-all image) 
      (set! i (- i 1))
    )
  )
) 

(script-fu-register "script-fu-save-all-images" 
 "<Image>/File/Save ALL As" 
 "Save all opened images as ..." 
 "Lauchlin Wilkinson (& Saul Goode)" 
 "Lauchlin Wilkinson (& Saul Goode)" 
 "2014/04/21" 
 ""
 SF-DIRNAME    "Save Directory" ""
 SF-OPTION     "Save File Type" (list "jpg" "bmp" "png" "tif")
 SF-STRING     "Save File Base Name" "IMAGE"
 SF-ADJUSTMENT "Save File Start Number" 
      (list 0 0 9000 1 100 0 SF-SPINNER)
 )
© www.soinside.com 2019 - 2024. All rights reserved.