Сохранить как несколько файлов одновременно (GIMP)

У меня есть серия изображений .xcf, которые я хочу сохранить как .png. Я могу открыть каждый файл и сохранить его в формате .png, но поскольку изображений много, это займет достаточно много времени.

Есть ли способ конвертировать все изображения одновременно или я должен потратить меньше времени на эту работу?

Заранее спасибо.

5 ответов

Я бы использовал консоль Python внутри GIMP для этого - если вы оказались в Windows, посмотрите, как установить расширение Python для GIMP 2.6 (в Linux оно либо не установлено, либо является вопросом установки gimp-python пакет, наверное, такой же на Mac OS)

В консоли Python GIMP у вас есть доступ к огромному 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 использует по умолчанию - объединить требуемый каталог с путями к файлам для работы с другими каталогами).

Если вам нужно сделать это несколько раз, взгляните на примеры плагинов, которые поставляются с gimp-Python, и вставьте приведенный выше код в качестве ядра для плагина Python для GIMP для собственного использования.

Хорошо, если у вас есть imagemagick установлен, вы можете сделать это следующим образом:

mogrify -format png *.xcf

Это автоматически преобразует их в тот же каталог. Также прочитайте man mogrify или это для других вариантов.

Вы можете быстро создать плагин под названием 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" 
 "" 
 ) 

Поместите файл в папку плагинов с тем же расширением (в Windows это C:\Program Files\GIMP 2\share\gimp\2.0\scripts).

Тогда вам даже не нужно перезапускать приложение. Меню фильтров -> Script-Fu -> Обновление скриптов. У вас будет пункт Сохранить ВСЕ в меню Файл (в самом низу). Это работает быстро, легко для меня.

Этот сценарий пришел отсюда.

Есть и другой сценарий, но я не проверял его сам.

{
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; 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)
 )

}

Этот скрипт отлично работает в gimp 2.8 Windows 7.

УЧЛИН УИЛКИНСОН СОХРАНИТЕ ВСЕ ОТКРЫТЫЕ ИЗОБРАЖЕНИЯ ИЗ GIMP.

Удобно, если вы сканируете много изображений и хотите просто экспортировать их за один раз. Он основан на сценарии Сола Гуда, расширенном для запроса имени базы изображений, каталога и т. Д.

Сохраните его как saveall.scm в вашем каталоге скриптов Gimp. Например, ~/.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)
 )
Другие вопросы по тегам