Save all open - script

ForumsFor GIMP users ► Save all open - script

Sent: 2009-07-01 17:51:25 UTC (over 2 years ago)

From: Brandon

Save all open - script

Hi all. Obviosuly I am new at this but I have been doing research into scripts and such for a while.

My current task at work is that i have to cut small 10x10 pixel areas out of a bigger bmp file and save them all as individual files.

I have the cutting and pasting to new file down pat, but once i have a hundred or so open, i want to just save all of them at once. I found a script on this list 'saveall.scm' but since these are all new untitled bmp files it would return an error.

I have modified it and i think i have it closer but i have one/two lines way wrong and I cant seem to get it right. All i want is for the script to take all the open images, append a new number on it, .bmp, and save them in a specific folder.

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; 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)
(define outDir "C:\\Documents and Settings\\bms\\My Documents\\temp bitmaps\\Unicode 10x10")
(define outFile)
(define imgNum)
(let* ((i (car (gimp-image-list)))
(image))
(while (> i 0)
(set! image (vector-ref (cadr (gimp-image-list)) (- i 1)))
;; THE next two lines i edited, they dont work
(number->string i imgNum)
(file-bmp-save RUN-NONINTERACTIVE image (car (gimp-image-get-active-layer image)) (string-append outDir "\\" (car (gimp-image-get-name image)) "_" (imgNum) ".bmp") (string-append outDir "\\" (car (gimp-image-get-name image)) "_" (imgNum) ".bmp"))
(gimp-image-clean-all image)
(set! i (- i 1)))))

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

What did i do wrong?

_______________________________________________
Gimp-user mailing list
Gimp-user@lists.XCF.Berkeley.EDU
https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-user

Reply to this message

Sent: 2009-07-02 00:20:48 UTC (over 2 years ago)

From: norseman

Save all open - script

Brandon wrote:
> Hi all. Obviosuly I am new at this but I have been doing research into scripts and such for a while.
>
> My current task at work is that i have to cut small 10x10 pixel areas out of a bigger bmp file and save them all as individual files.
>
> I have the cutting and pasting to new file down pat, but once i have a hundred or so open, i want to just save all of them at once. I found a script on this list 'saveall.scm' but since these are all new untitled bmp files it would return an error.
>
> I have modified it and i think i have it closer but i have one/two lines way wrong and I cant seem to get it right. All i want is for the script to take all the open images, append a new number on it, .bmp, and save them in a specific folder.
>
> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
> ; 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)
> (define outDir "C:\\Documents and Settings\\bms\\My Documents\\temp bitmaps\\Unicode 10x10")
> (define outFile)
> (define imgNum)
> (let* ((i (car (gimp-image-list)))
> (image))
> (while (> i 0)
> (set! image (vector-ref (cadr (gimp-image-list)) (- i 1)))
> ;; THE next two lines i edited, they dont work
> (number->string i imgNum)
> > (while (> i 0)
> (set! image (vector-ref (cadr (gimp-image-list)) (- i 1)))
> (file-bmp-save RUN-NONINTERACTIVE image (car (gimp-image-get-active-layer image)) (string-append outDir "\\" (car (gimp-image-get-name image)) "_" (imgNum) ".bmp") (string-append outDir "\\" (car (gimp-image-get-name image)) "_" (imgNum) ".bmp"))
> (gimp-image-clean-all image)
> (set! i (- i 1)))))
>
> (script-fu-register "script-fu-save-all-images"
> "/File/Save ALL"
> "Save all opened images"
> "Saul Goode"
> "Saul Goode"
> "11/21/2006"
> ""
> )
>
> What did i do wrong?
>

_______________________________________________
> Gimp-user mailing list
> Gimp-user@lists.XCF.Berkeley.EDU
> https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-user
>
================
My first thought is: "Why not save them as they are created? Why wait?"
No answer needed. The "why" is not the point, that it doesn't do the
request is.

SO - why do you create the path/individual file name twice in one line?

(while
(> i 0
)
(set! image
(vector-ref
(cadr
(gimp-image-list
)
)
(- i 1
)
)
)
(file-bmp-save RUN-NONINTERACTIVE image
(car
(gimp-image-get-active-layer image
)
)
(string-append outDir "\\"
(car
(gimp-image-get-name image
)
) "_"
(imgNum
) ".bmp"
)
(string-append outDir "\\"
(car
(gimp-image-get-name image
)
) "_"
(imgNum
) ".bmp"
)
)
(gimp-image-clean-all image
)
(set! i
(- i 1
)
)
)
)) double check the paren counts. See if I got this right.

Steve

Reply to this message

Welcome!


Lost password?

Not a member? Sign up!

Random tutorials | Latest tutorials

  1. Cool glowing text Cool glowing text 40
  2. Smelting text / Creating blood text Smelting text / Creating blood text 37
  3. Crazy Ions Crazy Ions 4
  4. "Solar winds" graphics effect "Solar winds" graphics effect 7

Latest comments

A facebook page, could be great too! (about 14 hours ago in GIMP gets closer to the community with Google+!)

bah just use 2.7.4 (or 2.7.5 on Windows) (about 17 hours ago in Last stable 2.6 release: 2.6.12 has arrived)

Hmm, would prefer Diaspora, I don't use G+ myself, but I guess it h... (about 17 hours ago in GIMP gets closer to the community with Google+!)

Poll

Is GIMP an adequate application for you to create printed graphics like flyers, advertisments etc?

View results

Latest forum activities

Your Ad Here

facts & numbers

gimpusers.com RSS feed

48 identi.ca followers
745 Twitter followers

powered by bitfire it services