It is currently Thu Sep 24, 2026 4:55 pm


All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: Trying to fix/update a batch-export-image script that I've found
PostPosted: Sat Aug 17, 2013 1:19 am  (#1) 
Offline
GimpChat Member

Joined: Aug 17, 2013
Posts: 8
Hello. I've found this script, that would supposedly export all open images in batch:

; 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)))
      (file-jpeg-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/Export all images"
"Save all opened images"
"Saul Goode"
"Saul Goode"
"11/21/2006"
""
)


I don't even know if it worked back then (2006), I guess it did, but nowadays it's export instead of "save". That little detail I've fixed (replacing gimp-save-image by file-jpeg-save, already in the code), but more work is needed to make it work, and I'm quite clueless.

The error message I receive is:

Quote:
Execution error for 'Export all images':
Error: (<unknown> : 142662924) Invalid number of arguments for file-jpeg-save (expected 14 but received 5)


It would be really good if we could get it to batch-export with automatic renaming/numbering, but I guess that would require a feature from the GTK file dialog itself, unfortunately. But even just popping-up the export dialogs all at once would be handier than doing it manually when you're editing multiple images.


Can anyone help me, please? Perhaps point me to some other script that sort of does something like that, so I could make a functional frankenstein-script with the inferred missing parts.


Share on Facebook Share on Twitter Share on Orkut Share on Digg Share on MySpace Share on Delicious Share on Technorati
Top
 Post subject: Re: Trying to fix/update a batch-export-image script that I've found
PostPosted: Sat Aug 17, 2013 2:29 am  (#2) 
Offline
GimpChat Member
User avatar

Joined: Nov 16, 2011
Posts: 5127
Location: Metro Vancouver, BC
Gimp 2.8+ uses Export for anything other than, native XCF.
Also you might like DBP (David's Batch Processor).

_________________
Image
Gimp 2.8.18, Linux, median user
Gimp Chat Tutorials Index
Spirit Bear (Kermode)


Top
 Post subject: Re: Trying to fix/update a batch-export-image script that I've found
PostPosted: Sat Aug 17, 2013 3:05 am  (#3) 
Offline
Script Coder
User avatar

Joined: Feb 18, 2011
Posts: 4826
Location: Bendigo Vic. Australia
This will export the image back in the images same encoding type 'png' 'jpg' e.t.c.
Take no heed to the (gimp-file-save) command it is the correct command in this situation in gimp this command is named export

; 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 0))
    (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/Export all images"
"Save all opened images"
"Saul Goode"
"Saul Goode"
"11/21/2006"
""
)

_________________
Image
No matter how much you push the envelope, it'll still be stationery.


Top
 Post subject: Re: Trying to fix/update a batch-export-image script that I've found
PostPosted: Sun Aug 18, 2013 4:21 pm  (#4) 
Offline
GimpChat Member

Joined: Aug 17, 2013
Posts: 8
Thanks for the replies.

I had not noticed it was still working if we opened extant files! I was expecting that it would save even newly created images (ideally not overwriting anything if you had opened one anyway, which it doesn't, but overwrites). I was trying to export multiple newly created images, and receiving an error message complaining about unknown file type (as there was no file type before), so I thought that the jpeg-specific "command" would circumvent that:

Quote:
Execution error for 'Export all images':
Error: (<unknown> : 164560140) Procedure execution of gimp-file-save failed: Unknown file type


Using jpeg-save gets rid of this message, but requires mysterious extra parameters.


I'll take a look at the other script and a "script resources" page I've found, and see if I can create the functionality I want.


Top
 Post subject: Re: Trying to fix/update a batch-export-image script that I've found
PostPosted: Sun Aug 18, 2013 7:48 pm  (#5) 
Offline
Script Coder
User avatar

Joined: Feb 18, 2011
Posts: 4826
Location: Bendigo Vic. Australia
Below↓ are all the Jpeg parameters, I hope it helps, but it may be better to use save as xcf

If you desire to save all opened images whether previously saved or not could you either specify a location or I could enter a menu item for you to select a location
(file-jpeg-save RUN-NONINTERACTIVE
                   img
               copy-layer
               path
               path
               1.00 ;quality
               0.00 ;smoothing
               1    ;optimize
               1    ;progressive
               ""   ;comment
               0    ;subsmp
               0    ;baseline
               0    ;restart
               0    ;dct
               )

_________________
Image
No matter how much you push the envelope, it'll still be stationery.


Top
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC - 5 hours [ DST ]



* Login  



Powered by phpBB3 © phpBB Group