Pergunta

Eu tenho uma série de .xcf imagens que desejo salvar como .png.Posso abrir cada arquivo e salvar como .png mas como há muitas imagens, levaria bastante tempo.

Existe uma maneira de converter todas as imagens de uma vez ou outra maneira de gastar menos tempo neste trabalho?

Agradeço antecipadamente.

Nenhuma solução correta

Outras dicas

Eu usaria o console Python dentro do GIMP para isso - se você estiver no Windows, dê uma olhada em como instalar a extensão Python para o GIMP 2.6 (no Linux ela vem instalada ou é uma questão de instalar o gimp-python pacote, provavelmente o mesmo no Mac OS)

No console Python do GIMP, você tem acesso a uma enorme API do GIMP que pode ser verificada na caixa de diálogo ajuda-> Navegador de procedimentos - além de ter todos os outros recursos do Python, incluindo manipulação de arquivos e strings.

Se você estiver no console Python-fu, é uma questão de fazer algo assim:

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)

(isso funcionará no diretório que o GIMP usa como padrão - concatene o diretório desejado com os caminhos de arquivo para trabalhar em outros diretórios).

Se você precisar fazer isso mais de uma vez, dê uma olhada nos plug-ins de exemplo que vêm com o gimp-Python e cole o código acima como o núcleo de um plug-in python para o GIMP para seu próprio uso.

Bem, se você tem imagemagick instalado, você pode fazer assim:

mogrify -format png *.xcf

Isso os converte automaticamente no mesmo diretório.Leia também man mogrify ou isto para outras opções.

Você pode criar rapidamente um plugin chamado SaveAll.Salve este código em algum arquivo com extensão .scm (por exemplo,salvar tudo.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" 
 "" 
 ) 

Coloque o arquivo na pasta Plugins com a mesma extensão (no Windows, é C: Arquivos de Programas Gimp 2 Share Gimp 2.0 scripts).

Então você nem precisa reiniciar o aplicativo. Filtros cardápio -> Script-Fu -> Atualizar scripts.Você terá Salvar tudo item no Arquivo menu (na parte inferior).Funciona rápido e fácil para mim.

Este script vem de aqui.

Há também outro script, mas eu não testei sozinho.

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

}

Este script funciona perfeitamente em gimp 2.8 Janelas 7.

UCHLIN WILKINSON SALVAR TODAS AS IMAGENS ABERTAS DO GIMP.

Útil se você estiver digitalizando muitas imagens e quiser apenas exportá-las de uma só vez.É baseado em um script de Saul Goode, estendido para solicitar o nome da base da imagem, diretório etc.

Salve-o como saveall.scm no diretório de scripts do Gimp.Por exemplo.~/.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)
 )
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top