Export all layers to distinct files
Message-ID:<slrngeq4k4.6dl.google@ID-171443.user.uni-berlin.de>
Subject:
Export all layers to distinct files?
Date:Wed, 8 Oct 2008 22:00:01 +0100
Is there a command to save out all the component layers of a gimp file into individual images? -- -Toby Add the word afiduluminag to the subject to circumvent my email filters.
Message-ID:<871vyqn3j9.fld@apaflo.com>
Subject:
Re: Export all layers to distinct files?
Date:Wed, 8 Oct 2008 23:08:26 +0100
Toby Newman <google@asktoby.com> wrote: >Is there a command to save out all the component layers of a gimp file >into individual images? No, but that is relatively easy to do. It would also be relatively easy to write a Script-Fu or Python script to do it. The difficulty is most just working out conventions like what to name the files produced... Note that if saving all of your layers to work on later is what you actually want, just save it to XCF format. When you reload the XCF file, all of your layers will still exist. (What does not exist is an edit history, so you cannot undo the last edit made in order to revert to something previous.) To actually save each layer to a file, one method would be to go to the "Layers" window and turn off visibility of all layers except the one you want to save, then go to the Image menu and select "Flatten image". You can then save the image as you see it to whatever filename you choose. After saving it, go to the "Edit" menu and click on the "Undo" option which will reverse the "Image flatten" command to restore the original multiple layers. You can then change which layer is visible, and repeat the process. -- Floyd L. Davidson <http://www.apaflo.com/floyd_davidson> Ukpeagvik (Barrow, Alaska) floyd@apaflo.com
Message-ID:<87hc7kkg1s.fsf@gmail.com>
Subject:
Re: Export all layers to distinct files?
Date:Fri, 10 Oct 2008 09:30:55 +0100
floyd@apaflo.com (Floyd L. Davidson) writes:
> To actually save each layer to a file, one method would
> be to go to the "Layers" window and turn off visibility
> of all layers except the one you want to save, then go
> to the Image menu and select "Flatten image".
This is unnecessary, simply go to the layers window, pick a layer
and drag it onto the toolbox. This will paste the layer as a new
image.
Or use something like the script below (yes, I had some time on my
hands...). It will save each layer to a png file; if the image is not
yet attached to a file, it will put the files in the ~/.gimp-n.n/tmp
directory. They are named after the master image and the layer name:
;; -*- mode: Gimp; -*-
(define (script-fu-save-layers-to-files image dont-ask display-images)
(let ((basename (car (gimp-image-get-filename image))))
(when (string=? basename "")
(set! basename (string-append
(car (gimp-temp-name ""))
(car (gimp-image-get-name 61)))))
(let loop ((layers (vector->list (cadr (gimp-image-get-layers image)))))
(unless (null? layers)
(gimp-edit-copy (car layers))
(let ((img (car (gimp-edit-paste-as-new)))
(new-name (string-append
basename
(car (gimp-drawable-get-name (car layers)))
".png")))
(file-png-save dont-ask
img
(aref (cadr (gimp-image-get-layers img)) 0)
new-name
new-name
TRUE 9 FALSE TRUE FALSE FALSE TRUE)
(if (= FALSE display-images)
;; clean up afterwards if we are not going to
;; display the images anyway:
(gimp-image-delete img)
(gimp-display-new img)))
(loop (cdr layers))))))
(script-fu-register "script-fu-save-layers-to-files"
_"Save all layers to a different file"
_"Saves all layers to separate .png files"
"Niels Giesen (niels.giesen@gmail.com)"
"Niels Giesen"
"2008-10-10"
""
SF-IMAGE "Image" 1
SF-TOGGLE _"Don't ask options for each layer" TRUE
SF-TOGGLE _"Display images?" FALSE)
(script-fu-menu-register "script-fu-save-layers-to-files"
_"<Image>/Filters/Generic")
Save to ~/.gimp-n.n/scripts/script-fu-save-layers-to-files.scm
...though I am sure something like this must have been done before...
Regards,
Niels Giesen.
http://niels.kicks-ass.org
http://niels.kicks-ass.org/gimpmode/
Message-ID:<GJLHk.581$8_3.422@flpi147.ffdc.sbc.com>
Subject:
Re: Export all layers to distinct files?
Date:Fri, 10 Oct 2008 17:53:44 +0100
Niels Giesen wrote: > floyd@apaflo.com (Floyd L. Davidson) writes: > >> To actually save each layer to a file, one method would >> be to go to the "Layers" window and turn off visibility >> of all layers except the one you want to save, then go >> to the Image menu and select "Flatten image". > > This is unnecessary, simply go to the layers window, pick a layer > and drag it onto the toolbox. This will paste the layer as a new > image. > > Or use something like the script below (yes, I had some time on my > hands...). It will save each layer to a png file; if the image is not > yet attached to a file, it will put the files in the ~/.gimp-n.n/tmp > directory. They are named after the master image and the layer name: > > ;; -*- mode: Gimp; -*- > (define (script-fu-save-layers-to-files image dont-ask display-images) > (let ((basename (car (gimp-image-get-filename image)))) > (when (string=? basename "") > (set! basename (string-append > (car (gimp-temp-name "")) > (car (gimp-image-get-name 61))))) > (let loop ((layers (vector->list (cadr (gimp-image-get-layers > image))))) > (unless (null? layers) > (gimp-edit-copy (car layers)) > (let ((img (car (gimp-edit-paste-as-new))) > (new-name (string-append > basename > (car (gimp-drawable-get-name (car layers))) > ".png"))) > (file-png-save dont-ask > img > (aref (cadr (gimp-image-get-layers img)) 0) > new-name > new-name > TRUE 9 FALSE TRUE FALSE FALSE TRUE) > (if (= FALSE display-images) > ;; clean up afterwards if we are not going to > ;; display the images anyway: > (gimp-image-delete img) > (gimp-display-new img))) > (loop (cdr layers)))))) > > (script-fu-register "script-fu-save-layers-to-files" > _"Save all layers to a different file" > _"Saves all layers to separate .png files" > "Niels Giesen (niels.giesen@gmail.com)" > "Niels Giesen" > "2008-10-10" > "" > SF-IMAGE "Image" 1 > SF-TOGGLE _"Don't ask options for each layer" TRUE > SF-TOGGLE _"Display images?" FALSE) > > (script-fu-menu-register "script-fu-save-layers-to-files" > _"<Image>/Filters/Generic") > > Save to ~/.gimp-n.n/scripts/script-fu-save-layers-to-files.scm > > ...though I am sure something like this must have been done before... > > Regards, > > Niels Giesen. > > http://niels.kicks-ass.org > http://niels.kicks-ass.org/gimpmode/ Tried the script. Simple three layer image with a 5x5 circle filled with red, green and blue on separate layers. I got the following error messages: GIMP Message Error while executing (script-fu-save-layers-to-files 1 TRUE TRUE) Error: Procedure execution of gimp-image-get-name failed on invalid input arguments Save all layers to a different file Message Procedure 'gimp-image-get-name' has been called with an invalid ID for argument 'image'. Most likely a plug-in is trying to work on an image that doesn't exist any longer. Using Gimp-2.4.7 on openSUSE-10.3
Message-ID:<87iqrzhr34.fsf@gmail.com>
Subject:
Re: Export all layers to distinct files?
Date:Sat, 11 Oct 2008 20:25:19 +0100
Michael Soibelman <in-the@ether.net> writes:
> Niels Giesen wrote:
>
>> Michael Soibelman <in-the@ether.net> writes:
>>
>>
>>> Tried the script. Simple three layer image with a 5x5 circle filled with
>>> red, green and blue on separate layers. I got the following error
>>> messages:
>>>
>>>
>>> GIMP Message
>>> Error while executing
>>> (script-fu-save-layers-to-files 1 TRUE TRUE)
>>>
>>> Error: Procedure execution of gimp-image-get-name failed on invalid input
>>> arguments
>>> Save all layers to a different file Message
>>> Procedure 'gimp-image-get-name' has been called with an invalid ID for
>>> argument 'image'. Most likely a plug-in is trying to work on an image
>>> that doesn't exist any longer.
>>>
>>> Using Gimp-2.4.7 on openSUSE-10.3
>>>
>>
>> Ech, replace 61 with image in the script. So
>>
>> (car (gimp-image-get-name 61)))))
>>
>> becomes
>>
>> (car (gimp-image-get-name image)))))
>>
>> Good reminder to always try code with a clean program before
>> posting (image 61 was still lying around...). Sorry about that.
>>
>>
>
> O.K. That worked. Now, for a nice improvement it would be nice if the
> saved images would use the layer names as the saved images names. Somehow
> Untitled-2.0, Untitled-3.0 & Untitled-4.0 doesn't seem to do it. My test
> image has layers red, blue & green so red, blue & green would better
> represent my choice. Any way you could modify this script to use the layer
> names as the saved images names ???
>
> Thanks for your effort. A little tweaking and voila'... Quite usefull.
The script already saved the layers to a pretty long and ugly (but
unique, so that it is safe) name made out of the source image and the
layer name, so that is different. But apparently you do not see this
in the UI until you set it.
I modified the script so in the UI you'll see the layer name as the
image name. However when you save it, it will then save to a different
name, and hence to a different file.
What is your take on the correct approach?
Also note the difference between splitting an image that already has a
file association and an image that has not (such as a generated logo):
the first saves next to the source image, while the second puts it,
for lack of something better, in ~/.gimp-n.n/tmp/
If we'd let the script only split, not save, things would be easier.
How are you going to use it?
;; -*- mode: Gimp; -*-
(define (script-fu-save-layers-to-files image dont-ask display-images)
(let ((basename (car (gimp-image-get-filename image))))
(when (string=? basename "")
(set! basename (string-append
(car (gimp-temp-name ""))
(car (gimp-image-get-name image)))))
(let loop ((layers (vector->list (cadr (gimp-image-get-layers image)))))
(unless (null? layers)
(gimp-edit-copy (car layers))
(let* ((img (car (gimp-edit-paste-as-new)))
(layer-name (car (gimp-drawable-get-name (car layers))))
(new-name (string-append
basename
layer-name
".png")))
(gimp-image-set-filename img layer-name)
(file-png-save dont-ask
img
(aref (cadr (gimp-image-get-layers img)) 0)
new-name
new-name
TRUE 9 FALSE TRUE FALSE FALSE TRUE)
(if (= FALSE display-images)
;; clean up afterwards if we are not going to
;; display the images anyway:
(gimp-image-delete img)
(gimp-display-new img)))
(loop (cdr layers))))))
(script-fu-register "script-fu-save-layers-to-files"
_"Save all layers to a different file"
_"Saves all layers to separate .png files"
"Niels Giesen (niels.giesen@gmail.com)"
"Niels Giesen"
"2008-10-10"
""
SF-IMAGE "Image" 1
SF-TOGGLE _"Don't ask options for each layer" TRUE
SF-TOGGLE _"Display images?" FALSE)
(script-fu-menu-register "script-fu-save-layers-to-files"
_"<Image>/Filters/Generic")
Message-ID:<nC7Ik.2288$Ei5.683@flpi143.ffdc.sbc.com>
Subject:
Re: Export all layers to distinct files?
Date:Sat, 11 Oct 2008 21:03:06 +0100
Niels Giesen wrote: > Michael Soibelman <in-the@ether.net> writes: > >> Niels Giesen wrote: >> >>> Michael Soibelman <in-the@ether.net> writes: >>> >>> >>>> Tried the script. Simple three layer image with a 5x5 circle filled >>>> with >>>> red, green and blue on separate layers. I got the following error >>>> messages: >>>> >>>> >>>> GIMP Message >>>> Error while executing >>>> (script-fu-save-layers-to-files 1 TRUE TRUE) >>>> >>>> Error: Procedure execution of gimp-image-get-name failed on invalid >>>> input arguments >>>> Save all layers to a different file Message >>>> Procedure 'gimp-image-get-name' has been called with an invalid ID for >>>> argument 'image'. Most likely a plug-in is trying to work on an image >>>> that doesn't exist any longer. >>>> >>>> Using Gimp-2.4.7 on openSUSE-10.3 >>>> >>> >>> Ech, replace 61 with image in the script. So >>> >>> (car (gimp-image-get-name 61))))) >>> >>> becomes >>> >>> (car (gimp-image-get-name image))))) >>> >>> Good reminder to always try code with a clean program before >>> posting (image 61 was still lying around...). Sorry about that. >>> >>> >> >> O.K. That worked. Now, for a nice improvement it would be nice if the >> saved images would use the layer names as the saved images names. >> Somehow >> Untitled-2.0, Untitled-3.0 & Untitled-4.0 doesn't seem to do it. My test >> image has layers red, blue & green so red, blue & green would better >> represent my choice. Any way you could modify this script to use the >> layer names as the saved images names ??? >> >> Thanks for your effort. A little tweaking and voila'... Quite usefull. > > The script already saved the layers to a pretty long and ugly (but > unique, so that it is safe) name made out of the source image and the > layer name, so that is different. But apparently you do not see this > in the UI until you set it. > > I modified the script so in the UI you'll see the layer name as the > image name. However when you save it, it will then save to a different > name, and hence to a different file. > > What is your take on the correct approach? > > Also note the difference between splitting an image that already has a > file association and an image that has not (such as a generated logo): > the first saves next to the source image, while the second puts it, > for lack of something better, in ~/.gimp-n.n/tmp/ > > If we'd let the script only split, not save, things would be easier. > How are you going to use it? > > ;; -*- mode: Gimp; -*- > (define (script-fu-save-layers-to-files image dont-ask display-images) > (let ((basename (car (gimp-image-get-filename image)))) > (when (string=? basename "") > (set! basename (string-append > (car (gimp-temp-name "")) > (car (gimp-image-get-name image))))) > (let loop ((layers (vector->list (cadr (gimp-image-get-layers > image))))) > (unless (null? layers) > (gimp-edit-copy (car layers)) > (let* ((img (car (gimp-edit-paste-as-new))) > (layer-name (car (gimp-drawable-get-name (car layers)))) > (new-name (string-append > basename > layer-name > ".png"))) > (gimp-image-set-filename img layer-name) > (file-png-save dont-ask > img > (aref (cadr (gimp-image-get-layers img)) 0) > new-name > new-name > TRUE 9 FALSE TRUE FALSE FALSE TRUE) > (if (= FALSE display-images) > ;; clean up afterwards if we are not going to > ;; display the images anyway: > (gimp-image-delete img) > (gimp-display-new img))) > (loop (cdr layers)))))) > > (script-fu-register "script-fu-save-layers-to-files" > _"Save all layers to a different file" > _"Saves all layers to separate .png files" > "Niels Giesen (niels.giesen@gmail.com)" > "Niels Giesen" > "2008-10-10" > "" > SF-IMAGE "Image" 1 > SF-TOGGLE _"Don't ask options for each layer" TRUE > SF-TOGGLE _"Display images?" FALSE) > > (script-fu-menu-register "script-fu-save-layers-to-files" > _"<Image>/Filters/Generic") Don't sweat it bro' I'm busy today so I'll look at it later. Otherwise it should be o.k... After I fiddle around with it I'll offer any feedback or comments at that point. Anyway, looks like you are pretty good with scripts for Gimp.... Which reminds me of a plugin I'd like to see added to Gimp. The idea is this. Create a plugin that keeps a list of all available plugins at the plugin registry. You can check/uncheck any plugins to add/delete them from your active plugins. All in alphabetic or 'group' order for easy searching/selecting. This way you don't have to go to the web site, download and then install.. This would probably be the most handy plugin ever.. Think of it as the 'plugin for plugins' plugin.... (pfp ?) Anyway, if you could do that I think you will become quite well liked by Gimp users everywhere...or at least I'd appreciate it... I'll leave the tough work to you if you think you can do it.. A little dash of wget and some local repository structure and your on your way... P.S. Just hoping as I've wished for such a thing for many years.. If you could pull this off you'd be on your way to international stardom... Thanks again for the original plugin. I'll be using it.
Message-ID:<87abdajocf.fsf@gmail.com>
Subject:
Re: Export all layers to distinct files?
Date:Sun, 12 Oct 2008 07:53:52 +0100
Michael Soibelman <in-the@ether.net> writes: > Don't sweat it bro' I'm busy today so I'll look at it later. Otherwise it > should be o.k... After I fiddle around with it I'll offer any feedback or > comments at that point. > > Anyway, looks like you are pretty good with scripts for Gimp.... Which > reminds me of a plugin I'd like to see added to Gimp. The idea is this. > Create a plugin that keeps a list of all available plugins at the plugin > registry. You can check/uncheck any plugins to add/delete them from your > active plugins. All in alphabetic or 'group' order for easy > searching/selecting. This way you don't have to go to the web site, > download and then install.. This would probably be the most handy plugin > ever.. Think of it as the 'plugin for plugins' plugin.... (pfp ?) > > Anyway, if you could do that I think you will become quite well liked by > Gimp users everywhere...or at least I'd appreciate it... I'll leave the > tough work to you if you think you can do it.. A little dash of wget and > some local repository structure and your on your way... First of all, I have got better things to do, and the web interface does not bother me that much, so no, I won't do it. Now, as some random thoughts regarding your proposed plug-in: "On your way", maybe, but: The Scheme used in the Gimp is pretty dumbed down and has no access to libgimp (although I can remember having read plans to give it access). Merely the act of listing many checkboxes does not work correctly (window decorations and buttons are gone, the latest do not even show up, I guess that no-one ever has wanted to use so many options). In other words: even if it could be done in Script-FU, it would be very clunky. This means such a thing would have to be scripted in Python or as a stand-alone app in anyones favourite language. Hell, I guess you could even do it in bash. You'd probably also want to have the features such as tags present in the registry, meaning you'd have to have a decent API to work with, otherwise it's scripting against HTML that might be subject to change. I am not aware of such an API. Also note that with something that would let users add plug-ins so easily, quality control is a must. If only to ward against malicious content. Which means constant human intervention. Are you willing to take that upon you? Anyway, I think such a project would basically mirror the registry website, not add a lot more, and take quite some time to develop and maintain. Though if it were present, I'd probably use it too. > P.S. Just hoping as I've wished for such a thing for many years.. If you > could pull this off you'd be on your way to international stardom... > > Thanks again for the original plugin. I'll be using it. You're welcome.
Message-ID:<slrngeq4k4.6dl.google@ID-171443.user.uni-berlin.de>
Subject:
Export all layers to distinct files?
Date:Wed, 8 Oct 2008 22:00:01 +0100
Is there a command to save out all the component layers of a gimp file into individual images? -- -Toby Add the word afiduluminag to the subject to circumvent my email filters.
Message-ID:<871vyqn3j9.fld@apaflo.com>
Subject:
Re: Export all layers to distinct files?
Date:Wed, 8 Oct 2008 23:08:26 +0100
Toby Newman <google@asktoby.com> wrote: >Is there a command to save out all the component layers of a gimp file >into individual images? No, but that is relatively easy to do. It would also be relatively easy to write a Script-Fu or Python script to do it. The difficulty is most just working out conventions like what to name the files produced... Note that if saving all of your layers to work on later is what you actually want, just save it to XCF format. When you reload the XCF file, all of your layers will still exist. (What does not exist is an edit history, so you cannot undo the last edit made in order to revert to something previous.) To actually save each layer to a file, one method would be to go to the "Layers" window and turn off visibility of all layers except the one you want to save, then go to the Image menu and select "Flatten image". You can then save the image as you see it to whatever filename you choose. After saving it, go to the "Edit" menu and click on the "Undo" option which will reverse the "Image flatten" command to restore the original multiple layers. You can then change which layer is visible, and repeat the process. -- Floyd L. Davidson <http://www.apaflo.com/floyd_davidson> Ukpeagvik (Barrow, Alaska) floyd@apaflo.com
Message-ID:<87hc7kkg1s.fsf@gmail.com>
Subject:
Re: Export all layers to distinct files?
Date:Fri, 10 Oct 2008 09:30:55 +0100
floyd@apaflo.com (Floyd L. Davidson) writes:
> To actually save each layer to a file, one method would
> be to go to the "Layers" window and turn off visibility
> of all layers except the one you want to save, then go
> to the Image menu and select "Flatten image".
This is unnecessary, simply go to the layers window, pick a layer
and drag it onto the toolbox. This will paste the layer as a new
image.
Or use something like the script below (yes, I had some time on my
hands...). It will save each layer to a png file; if the image is not
yet attached to a file, it will put the files in the ~/.gimp-n.n/tmp
directory. They are named after the master image and the layer name:
;; -*- mode: Gimp; -*-
(define (script-fu-save-layers-to-files image dont-ask display-images)
(let ((basename (car (gimp-image-get-filename image))))
(when (string=? basename "")
(set! basename (string-append
(car (gimp-temp-name ""))
(car (gimp-image-get-name 61)))))
(let loop ((layers (vector->list (cadr (gimp-image-get-layers image)))))
(unless (null? layers)
(gimp-edit-copy (car layers))
(let ((img (car (gimp-edit-paste-as-new)))
(new-name (string-append
basename
(car (gimp-drawable-get-name (car layers)))
".png")))
(file-png-save dont-ask
img
(aref (cadr (gimp-image-get-layers img)) 0)
new-name
new-name
TRUE 9 FALSE TRUE FALSE FALSE TRUE)
(if (= FALSE display-images)
;; clean up afterwards if we are not going to
;; display the images anyway:
(gimp-image-delete img)
(gimp-display-new img)))
(loop (cdr layers))))))
(script-fu-register "script-fu-save-layers-to-files"
_"Save all layers to a different file"
_"Saves all layers to separate .png files"
"Niels Giesen (niels.giesen@gmail.com)"
"Niels Giesen"
"2008-10-10"
""
SF-IMAGE "Image" 1
SF-TOGGLE _"Don't ask options for each layer" TRUE
SF-TOGGLE _"Display images?" FALSE)
(script-fu-menu-register "script-fu-save-layers-to-files"
_"<Image>/Filters/Generic")
Save to ~/.gimp-n.n/scripts/script-fu-save-layers-to-files.scm
...though I am sure something like this must have been done before...
Regards,
Niels Giesen.
http://niels.kicks-ass.org
http://niels.kicks-ass.org/gimpmode/
Message-ID:<GJLHk.581$8_3.422@flpi147.ffdc.sbc.com>
Subject:
Re: Export all layers to distinct files?
Date:Fri, 10 Oct 2008 17:53:44 +0100
Niels Giesen wrote: > floyd@apaflo.com (Floyd L. Davidson) writes: > >> To actually save each layer to a file, one method would >> be to go to the "Layers" window and turn off visibility >> of all layers except the one you want to save, then go >> to the Image menu and select "Flatten image". > > This is unnecessary, simply go to the layers window, pick a layer > and drag it onto the toolbox. This will paste the layer as a new > image. > > Or use something like the script below (yes, I had some time on my > hands...). It will save each layer to a png file; if the image is not > yet attached to a file, it will put the files in the ~/.gimp-n.n/tmp > directory. They are named after the master image and the layer name: > > ;; -*- mode: Gimp; -*- > (define (script-fu-save-layers-to-files image dont-ask display-images) > (let ((basename (car (gimp-image-get-filename image)))) > (when (string=? basename "") > (set! basename (string-append > (car (gimp-temp-name "")) > (car (gimp-image-get-name 61))))) > (let loop ((layers (vector->list (cadr (gimp-image-get-layers > image))))) > (unless (null? layers) > (gimp-edit-copy (car layers)) > (let ((img (car (gimp-edit-paste-as-new))) > (new-name (string-append > basename > (car (gimp-drawable-get-name (car layers))) > ".png"))) > (file-png-save dont-ask > img > (aref (cadr (gimp-image-get-layers img)) 0) > new-name > new-name > TRUE 9 FALSE TRUE FALSE FALSE TRUE) > (if (= FALSE display-images) > ;; clean up afterwards if we are not going to > ;; display the images anyway: > (gimp-image-delete img) > (gimp-display-new img))) > (loop (cdr layers)))))) > > (script-fu-register "script-fu-save-layers-to-files" > _"Save all layers to a different file" > _"Saves all layers to separate .png files" > "Niels Giesen (niels.giesen@gmail.com)" > "Niels Giesen" > "2008-10-10" > "" > SF-IMAGE "Image" 1 > SF-TOGGLE _"Don't ask options for each layer" TRUE > SF-TOGGLE _"Display images?" FALSE) > > (script-fu-menu-register "script-fu-save-layers-to-files" > _"<Image>/Filters/Generic") > > Save to ~/.gimp-n.n/scripts/script-fu-save-layers-to-files.scm > > ...though I am sure something like this must have been done before... > > Regards, > > Niels Giesen. > > http://niels.kicks-ass.org > http://niels.kicks-ass.org/gimpmode/ Tried the script. Simple three layer image with a 5x5 circle filled with red, green and blue on separate layers. I got the following error messages: GIMP Message Error while executing (script-fu-save-layers-to-files 1 TRUE TRUE) Error: Procedure execution of gimp-image-get-name failed on invalid input arguments Save all layers to a different file Message Procedure 'gimp-image-get-name' has been called with an invalid ID for argument 'image'. Most likely a plug-in is trying to work on an image that doesn't exist any longer. Using Gimp-2.4.7 on openSUSE-10.3
Message-ID:<87iqrzhr34.fsf@gmail.com>
Subject:
Re: Export all layers to distinct files?
Date:Sat, 11 Oct 2008 20:25:19 +0100
Michael Soibelman <in-the@ether.net> writes:
> Niels Giesen wrote:
>
>> Michael Soibelman <in-the@ether.net> writes:
>>
>>
>>> Tried the script. Simple three layer image with a 5x5 circle filled with
>>> red, green and blue on separate layers. I got the following error
>>> messages:
>>>
>>>
>>> GIMP Message
>>> Error while executing
>>> (script-fu-save-layers-to-files 1 TRUE TRUE)
>>>
>>> Error: Procedure execution of gimp-image-get-name failed on invalid input
>>> arguments
>>> Save all layers to a different file Message
>>> Procedure 'gimp-image-get-name' has been called with an invalid ID for
>>> argument 'image'. Most likely a plug-in is trying to work on an image
>>> that doesn't exist any longer.
>>>
>>> Using Gimp-2.4.7 on openSUSE-10.3
>>>
>>
>> Ech, replace 61 with image in the script. So
>>
>> (car (gimp-image-get-name 61)))))
>>
>> becomes
>>
>> (car (gimp-image-get-name image)))))
>>
>> Good reminder to always try code with a clean program before
>> posting (image 61 was still lying around...). Sorry about that.
>>
>>
>
> O.K. That worked. Now, for a nice improvement it would be nice if the
> saved images would use the layer names as the saved images names. Somehow
> Untitled-2.0, Untitled-3.0 & Untitled-4.0 doesn't seem to do it. My test
> image has layers red, blue & green so red, blue & green would better
> represent my choice. Any way you could modify this script to use the layer
> names as the saved images names ???
>
> Thanks for your effort. A little tweaking and voila'... Quite usefull.
The script already saved the layers to a pretty long and ugly (but
unique, so that it is safe) name made out of the source image and the
layer name, so that is different. But apparently you do not see this
in the UI until you set it.
I modified the script so in the UI you'll see the layer name as the
image name. However when you save it, it will then save to a different
name, and hence to a different file.
What is your take on the correct approach?
Also note the difference between splitting an image that already has a
file association and an image that has not (such as a generated logo):
the first saves next to the source image, while the second puts it,
for lack of something better, in ~/.gimp-n.n/tmp/
If we'd let the script only split, not save, things would be easier.
How are you going to use it?
;; -*- mode: Gimp; -*-
(define (script-fu-save-layers-to-files image dont-ask display-images)
(let ((basename (car (gimp-image-get-filename image))))
(when (string=? basename "")
(set! basename (string-append
(car (gimp-temp-name ""))
(car (gimp-image-get-name image)))))
(let loop ((layers (vector->list (cadr (gimp-image-get-layers image)))))
(unless (null? layers)
(gimp-edit-copy (car layers))
(let* ((img (car (gimp-edit-paste-as-new)))
(layer-name (car (gimp-drawable-get-name (car layers))))
(new-name (string-append
basename
layer-name
".png")))
(gimp-image-set-filename img layer-name)
(file-png-save dont-ask
img
(aref (cadr (gimp-image-get-layers img)) 0)
new-name
new-name
TRUE 9 FALSE TRUE FALSE FALSE TRUE)
(if (= FALSE display-images)
;; clean up afterwards if we are not going to
;; display the images anyway:
(gimp-image-delete img)
(gimp-display-new img)))
(loop (cdr layers))))))
(script-fu-register "script-fu-save-layers-to-files"
_"Save all layers to a different file"
_"Saves all layers to separate .png files"
"Niels Giesen (niels.giesen@gmail.com)"
"Niels Giesen"
"2008-10-10"
""
SF-IMAGE "Image" 1
SF-TOGGLE _"Don't ask options for each layer" TRUE
SF-TOGGLE _"Display images?" FALSE)
(script-fu-menu-register "script-fu-save-layers-to-files"
_"<Image>/Filters/Generic")
Message-ID:<nC7Ik.2288$Ei5.683@flpi143.ffdc.sbc.com>
Subject:
Re: Export all layers to distinct files?
Date:Sat, 11 Oct 2008 21:03:06 +0100
Niels Giesen wrote: > Michael Soibelman <in-the@ether.net> writes: > >> Niels Giesen wrote: >> >>> Michael Soibelman <in-the@ether.net> writes: >>> >>> >>>> Tried the script. Simple three layer image with a 5x5 circle filled >>>> with >>>> red, green and blue on separate layers. I got the following error >>>> messages: >>>> >>>> >>>> GIMP Message >>>> Error while executing >>>> (script-fu-save-layers-to-files 1 TRUE TRUE) >>>> >>>> Error: Procedure execution of gimp-image-get-name failed on invalid >>>> input arguments >>>> Save all layers to a different file Message >>>> Procedure 'gimp-image-get-name' has been called with an invalid ID for >>>> argument 'image'. Most likely a plug-in is trying to work on an image >>>> that doesn't exist any longer. >>>> >>>> Using Gimp-2.4.7 on openSUSE-10.3 >>>> >>> >>> Ech, replace 61 with image in the script. So >>> >>> (car (gimp-image-get-name 61))))) >>> >>> becomes >>> >>> (car (gimp-image-get-name image))))) >>> >>> Good reminder to always try code with a clean program before >>> posting (image 61 was still lying around...). Sorry about that. >>> >>> >> >> O.K. That worked. Now, for a nice improvement it would be nice if the >> saved images would use the layer names as the saved images names. >> Somehow >> Untitled-2.0, Untitled-3.0 & Untitled-4.0 doesn't seem to do it. My test >> image has layers red, blue & green so red, blue & green would better >> represent my choice. Any way you could modify this script to use the >> layer names as the saved images names ??? >> >> Thanks for your effort. A little tweaking and voila'... Quite usefull. > > The script already saved the layers to a pretty long and ugly (but > unique, so that it is safe) name made out of the source image and the > layer name, so that is different. But apparently you do not see this > in the UI until you set it. > > I modified the script so in the UI you'll see the layer name as the > image name. However when you save it, it will then save to a different > name, and hence to a different file. > > What is your take on the correct approach? > > Also note the difference between splitting an image that already has a > file association and an image that has not (such as a generated logo): > the first saves next to the source image, while the second puts it, > for lack of something better, in ~/.gimp-n.n/tmp/ > > If we'd let the script only split, not save, things would be easier. > How are you going to use it? > > ;; -*- mode: Gimp; -*- > (define (script-fu-save-layers-to-files image dont-ask display-images) > (let ((basename (car (gimp-image-get-filename image)))) > (when (string=? basename "") > (set! basename (string-append > (car (gimp-temp-name "")) > (car (gimp-image-get-name image))))) > (let loop ((layers (vector->list (cadr (gimp-image-get-layers > image))))) > (unless (null? layers) > (gimp-edit-copy (car layers)) > (let* ((img (car (gimp-edit-paste-as-new))) > (layer-name (car (gimp-drawable-get-name (car layers)))) > (new-name (string-append > basename > layer-name > ".png"))) > (gimp-image-set-filename img layer-name) > (file-png-save dont-ask > img > (aref (cadr (gimp-image-get-layers img)) 0) > new-name > new-name > TRUE 9 FALSE TRUE FALSE FALSE TRUE) > (if (= FALSE display-images) > ;; clean up afterwards if we are not going to > ;; display the images anyway: > (gimp-image-delete img) > (gimp-display-new img))) > (loop (cdr layers)))))) > > (script-fu-register "script-fu-save-layers-to-files" > _"Save all layers to a different file" > _"Saves all layers to separate .png files" > "Niels Giesen (niels.giesen@gmail.com)" > "Niels Giesen" > "2008-10-10" > "" > SF-IMAGE "Image" 1 > SF-TOGGLE _"Don't ask options for each layer" TRUE > SF-TOGGLE _"Display images?" FALSE) > > (script-fu-menu-register "script-fu-save-layers-to-files" > _"<Image>/Filters/Generic") Don't sweat it bro' I'm busy today so I'll look at it later. Otherwise it should be o.k... After I fiddle around with it I'll offer any feedback or comments at that point. Anyway, looks like you are pretty good with scripts for Gimp.... Which reminds me of a plugin I'd like to see added to Gimp. The idea is this. Create a plugin that keeps a list of all available plugins at the plugin registry. You can check/uncheck any plugins to add/delete them from your active plugins. All in alphabetic or 'group' order for easy searching/selecting. This way you don't have to go to the web site, download and then install.. This would probably be the most handy plugin ever.. Think of it as the 'plugin for plugins' plugin.... (pfp ?) Anyway, if you could do that I think you will become quite well liked by Gimp users everywhere...or at least I'd appreciate it... I'll leave the tough work to you if you think you can do it.. A little dash of wget and some local repository structure and your on your way... P.S. Just hoping as I've wished for such a thing for many years.. If you could pull this off you'd be on your way to international stardom... Thanks again for the original plugin. I'll be using it.
Message-ID:<87abdajocf.fsf@gmail.com>
Subject:
Re: Export all layers to distinct files?
Date:Sun, 12 Oct 2008 07:53:52 +0100
Michael Soibelman <in-the@ether.net> writes: > Don't sweat it bro' I'm busy today so I'll look at it later. Otherwise it > should be o.k... After I fiddle around with it I'll offer any feedback or > comments at that point. > > Anyway, looks like you are pretty good with scripts for Gimp.... Which > reminds me of a plugin I'd like to see added to Gimp. The idea is this. > Create a plugin that keeps a list of all available plugins at the plugin > registry. You can check/uncheck any plugins to add/delete them from your > active plugins. All in alphabetic or 'group' order for easy > searching/selecting. This way you don't have to go to the web site, > download and then install.. This would probably be the most handy plugin > ever.. Think of it as the 'plugin for plugins' plugin.... (pfp ?) > > Anyway, if you could do that I think you will become quite well liked by > Gimp users everywhere...or at least I'd appreciate it... I'll leave the > tough work to you if you think you can do it.. A little dash of wget and > some local repository structure and your on your way... First of all, I have got better things to do, and the web interface does not bother me that much, so no, I won't do it. Now, as some random thoughts regarding your proposed plug-in: "On your way", maybe, but: The Scheme used in the Gimp is pretty dumbed down and has no access to libgimp (although I can remember having read plans to give it access). Merely the act of listing many checkboxes does not work correctly (window decorations and buttons are gone, the latest do not even show up, I guess that no-one ever has wanted to use so many options). In other words: even if it could be done in Script-FU, it would be very clunky. This means such a thing would have to be scripted in Python or as a stand-alone app in anyones favourite language. Hell, I guess you could even do it in bash. You'd probably also want to have the features such as tags present in the registry, meaning you'd have to have a decent API to work with, otherwise it's scripting against HTML that might be subject to change. I am not aware of such an API. Also note that with something that would let users add plug-ins so easily, quality control is a must. If only to ward against malicious content. Which means constant human intervention. Are you willing to take that upon you? Anyway, I think such a project would basically mirror the registry website, not add a lot more, and take quite some time to develop and maintain. Though if it were present, I'd probably use it too. > P.S. Just hoping as I've wished for such a thing for many years.. If you > could pull this off you'd be on your way to international stardom... > > Thanks again for the original plugin. I'll be using it. You're welcome.
Message-ID:<slrngeq4k4.6dl.google@ID-171443.user.uni-berlin.de>
Subject:
Export all layers to distinct files?
Date:Wed, 8 Oct 2008 22:00:01 +0100
Is there a command to save out all the component layers of a gimp file into individual images? -- -Toby Add the word afiduluminag to the subject to circumvent my email filters.
Message-ID:<871vyqn3j9.fld@apaflo.com>
Subject:
Re: Export all layers to distinct files?
Date:Wed, 8 Oct 2008 23:08:26 +0100
Toby Newman <google@asktoby.com> wrote: >Is there a command to save out all the component layers of a gimp file >into individual images? No, but that is relatively easy to do. It would also be relatively easy to write a Script-Fu or Python script to do it. The difficulty is most just working out conventions like what to name the files produced... Note that if saving all of your layers to work on later is what you actually want, just save it to XCF format. When you reload the XCF file, all of your layers will still exist. (What does not exist is an edit history, so you cannot undo the last edit made in order to revert to something previous.) To actually save each layer to a file, one method would be to go to the "Layers" window and turn off visibility of all layers except the one you want to save, then go to the Image menu and select "Flatten image". You can then save the image as you see it to whatever filename you choose. After saving it, go to the "Edit" menu and click on the "Undo" option which will reverse the "Image flatten" command to restore the original multiple layers. You can then change which layer is visible, and repeat the process. -- Floyd L. Davidson <http://www.apaflo.com/floyd_davidson> Ukpeagvik (Barrow, Alaska) floyd@apaflo.com
Message-ID:<87hc7kkg1s.fsf@gmail.com>
Subject:
Re: Export all layers to distinct files?
Date:Fri, 10 Oct 2008 09:30:55 +0100
floyd@apaflo.com (Floyd L. Davidson) writes:
> To actually save each layer to a file, one method would
> be to go to the "Layers" window and turn off visibility
> of all layers except the one you want to save, then go
> to the Image menu and select "Flatten image".
This is unnecessary, simply go to the layers window, pick a layer
and drag it onto the toolbox. This will paste the layer as a new
image.
Or use something like the script below (yes, I had some time on my
hands...). It will save each layer to a png file; if the image is not
yet attached to a file, it will put the files in the ~/.gimp-n.n/tmp
directory. They are named after the master image and the layer name:
;; -*- mode: Gimp; -*-
(define (script-fu-save-layers-to-files image dont-ask display-images)
(let ((basename (car (gimp-image-get-filename image))))
(when (string=? basename "")
(set! basename (string-append
(car (gimp-temp-name ""))
(car (gimp-image-get-name 61)))))
(let loop ((layers (vector->list (cadr (gimp-image-get-layers image)))))
(unless (null? layers)
(gimp-edit-copy (car layers))
(let ((img (car (gimp-edit-paste-as-new)))
(new-name (string-append
basename
(car (gimp-drawable-get-name (car layers)))
".png")))
(file-png-save dont-ask
img
(aref (cadr (gimp-image-get-layers img)) 0)
new-name
new-name
TRUE 9 FALSE TRUE FALSE FALSE TRUE)
(if (= FALSE display-images)
;; clean up afterwards if we are not going to
;; display the images anyway:
(gimp-image-delete img)
(gimp-display-new img)))
(loop (cdr layers))))))
(script-fu-register "script-fu-save-layers-to-files"
_"Save all layers to a different file"
_"Saves all layers to separate .png files"
"Niels Giesen (niels.giesen@gmail.com)"
"Niels Giesen"
"2008-10-10"
""
SF-IMAGE "Image" 1
SF-TOGGLE _"Don't ask options for each layer" TRUE
SF-TOGGLE _"Display images?" FALSE)
(script-fu-menu-register "script-fu-save-layers-to-files"
_"<Image>/Filters/Generic")
Save to ~/.gimp-n.n/scripts/script-fu-save-layers-to-files.scm
...though I am sure something like this must have been done before...
Regards,
Niels Giesen.
http://niels.kicks-ass.org
http://niels.kicks-ass.org/gimpmode/
Message-ID:<GJLHk.581$8_3.422@flpi147.ffdc.sbc.com>
Subject:
Re: Export all layers to distinct files?
Date:Fri, 10 Oct 2008 17:53:44 +0100
Niels Giesen wrote: > floyd@apaflo.com (Floyd L. Davidson) writes: > >> To actually save each layer to a file, one method would >> be to go to the "Layers" window and turn off visibility >> of all layers except the one you want to save, then go >> to the Image menu and select "Flatten image". > > This is unnecessary, simply go to the layers window, pick a layer > and drag it onto the toolbox. This will paste the layer as a new > image. > > Or use something like the script below (yes, I had some time on my > hands...). It will save each layer to a png file; if the image is not > yet attached to a file, it will put the files in the ~/.gimp-n.n/tmp > directory. They are named after the master image and the layer name: > > ;; -*- mode: Gimp; -*- > (define (script-fu-save-layers-to-files image dont-ask display-images) > (let ((basename (car (gimp-image-get-filename image)))) > (when (string=? basename "") > (set! basename (string-append > (car (gimp-temp-name "")) > (car (gimp-image-get-name 61))))) > (let loop ((layers (vector->list (cadr (gimp-image-get-layers > image))))) > (unless (null? layers) > (gimp-edit-copy (car layers)) > (let ((img (car (gimp-edit-paste-as-new))) > (new-name (string-append > basename > (car (gimp-drawable-get-name (car layers))) > ".png"))) > (file-png-save dont-ask > img > (aref (cadr (gimp-image-get-layers img)) 0) > new-name > new-name > TRUE 9 FALSE TRUE FALSE FALSE TRUE) > (if (= FALSE display-images) > ;; clean up afterwards if we are not going to > ;; display the images anyway: > (gimp-image-delete img) > (gimp-display-new img))) > (loop (cdr layers)))))) > > (script-fu-register "script-fu-save-layers-to-files" > _"Save all layers to a different file" > _"Saves all layers to separate .png files" > "Niels Giesen (niels.giesen@gmail.com)" > "Niels Giesen" > "2008-10-10" > "" > SF-IMAGE "Image" 1 > SF-TOGGLE _"Don't ask options for each layer" TRUE > SF-TOGGLE _"Display images?" FALSE) > > (script-fu-menu-register "script-fu-save-layers-to-files" > _"<Image>/Filters/Generic") > > Save to ~/.gimp-n.n/scripts/script-fu-save-layers-to-files.scm > > ...though I am sure something like this must have been done before... > > Regards, > > Niels Giesen. > > http://niels.kicks-ass.org > http://niels.kicks-ass.org/gimpmode/ Tried the script. Simple three layer image with a 5x5 circle filled with red, green and blue on separate layers. I got the following error messages: GIMP Message Error while executing (script-fu-save-layers-to-files 1 TRUE TRUE) Error: Procedure execution of gimp-image-get-name failed on invalid input arguments Save all layers to a different file Message Procedure 'gimp-image-get-name' has been called with an invalid ID for argument 'image'. Most likely a plug-in is trying to work on an image that doesn't exist any longer. Using Gimp-2.4.7 on openSUSE-10.3
Message-ID:<87iqrzhr34.fsf@gmail.com>
Subject:
Re: Export all layers to distinct files?
Date:Sat, 11 Oct 2008 20:25:19 +0100
Michael Soibelman <in-the@ether.net> writes:
> Niels Giesen wrote:
>
>> Michael Soibelman <in-the@ether.net> writes:
>>
>>
>>> Tried the script. Simple three layer image with a 5x5 circle filled with
>>> red, green and blue on separate layers. I got the following error
>>> messages:
>>>
>>>
>>> GIMP Message
>>> Error while executing
>>> (script-fu-save-layers-to-files 1 TRUE TRUE)
>>>
>>> Error: Procedure execution of gimp-image-get-name failed on invalid input
>>> arguments
>>> Save all layers to a different file Message
>>> Procedure 'gimp-image-get-name' has been called with an invalid ID for
>>> argument 'image'. Most likely a plug-in is trying to work on an image
>>> that doesn't exist any longer.
>>>
>>> Using Gimp-2.4.7 on openSUSE-10.3
>>>
>>
>> Ech, replace 61 with image in the script. So
>>
>> (car (gimp-image-get-name 61)))))
>>
>> becomes
>>
>> (car (gimp-image-get-name image)))))
>>
>> Good reminder to always try code with a clean program before
>> posting (image 61 was still lying around...). Sorry about that.
>>
>>
>
> O.K. That worked. Now, for a nice improvement it would be nice if the
> saved images would use the layer names as the saved images names. Somehow
> Untitled-2.0, Untitled-3.0 & Untitled-4.0 doesn't seem to do it. My test
> image has layers red, blue & green so red, blue & green would better
> represent my choice. Any way you could modify this script to use the layer
> names as the saved images names ???
>
> Thanks for your effort. A little tweaking and voila'... Quite usefull.
The script already saved the layers to a pretty long and ugly (but
unique, so that it is safe) name made out of the source image and the
layer name, so that is different. But apparently you do not see this
in the UI until you set it.
I modified the script so in the UI you'll see the layer name as the
image name. However when you save it, it will then save to a different
name, and hence to a different file.
What is your take on the correct approach?
Also note the difference between splitting an image that already has a
file association and an image that has not (such as a generated logo):
the first saves next to the source image, while the second puts it,
for lack of something better, in ~/.gimp-n.n/tmp/
If we'd let the script only split, not save, things would be easier.
How are you going to use it?
;; -*- mode: Gimp; -*-
(define (script-fu-save-layers-to-files image dont-ask display-images)
(let ((basename (car (gimp-image-get-filename image))))
(when (string=? basename "")
(set! basename (string-append
(car (gimp-temp-name ""))
(car (gimp-image-get-name image)))))
(let loop ((layers (vector->list (cadr (gimp-image-get-layers image)))))
(unless (null? layers)
(gimp-edit-copy (car layers))
(let* ((img (car (gimp-edit-paste-as-new)))
(layer-name (car (gimp-drawable-get-name (car layers))))
(new-name (string-append
basename
layer-name
".png")))
(gimp-image-set-filename img layer-name)
(file-png-save dont-ask
img
(aref (cadr (gimp-image-get-layers img)) 0)
new-name
new-name
TRUE 9 FALSE TRUE FALSE FALSE TRUE)
(if (= FALSE display-images)
;; clean up afterwards if we are not going to
;; display the images anyway:
(gimp-image-delete img)
(gimp-display-new img)))
(loop (cdr layers))))))
(script-fu-register "script-fu-save-layers-to-files"
_"Save all layers to a different file"
_"Saves all layers to separate .png files"
"Niels Giesen (niels.giesen@gmail.com)"
"Niels Giesen"
"2008-10-10"
""
SF-IMAGE "Image" 1
SF-TOGGLE _"Don't ask options for each layer" TRUE
SF-TOGGLE _"Display images?" FALSE)
(script-fu-menu-register "script-fu-save-layers-to-files"
_"<Image>/Filters/Generic")
Message-ID:<nC7Ik.2288$Ei5.683@flpi143.ffdc.sbc.com>
Subject:
Re: Export all layers to distinct files?
Date:Sat, 11 Oct 2008 21:03:06 +0100
Niels Giesen wrote: > Michael Soibelman <in-the@ether.net> writes: > >> Niels Giesen wrote: >> >>> Michael Soibelman <in-the@ether.net> writes: >>> >>> >>>> Tried the script. Simple three layer image with a 5x5 circle filled >>>> with >>>> red, green and blue on separate layers. I got the following error >>>> messages: >>>> >>>> >>>> GIMP Message >>>> Error while executing >>>> (script-fu-save-layers-to-files 1 TRUE TRUE) >>>> >>>> Error: Procedure execution of gimp-image-get-name failed on invalid >>>> input arguments >>>> Save all layers to a different file Message >>>> Procedure 'gimp-image-get-name' has been called with an invalid ID for >>>> argument 'image'. Most likely a plug-in is trying to work on an image >>>> that doesn't exist any longer. >>>> >>>> Using Gimp-2.4.7 on openSUSE-10.3 >>>> >>> >>> Ech, replace 61 with image in the script. So >>> >>> (car (gimp-image-get-name 61))))) >>> >>> becomes >>> >>> (car (gimp-image-get-name image))))) >>> >>> Good reminder to always try code with a clean program before >>> posting (image 61 was still lying around...). Sorry about that. >>> >>> >> >> O.K. That worked. Now, for a nice improvement it would be nice if the >> saved images would use the layer names as the saved images names. >> Somehow >> Untitled-2.0, Untitled-3.0 & Untitled-4.0 doesn't seem to do it. My test >> image has layers red, blue & green so red, blue & green would better >> represent my choice. Any way you could modify this script to use the >> layer names as the saved images names ??? >> >> Thanks for your effort. A little tweaking and voila'... Quite usefull. > > The script already saved the layers to a pretty long and ugly (but > unique, so that it is safe) name made out of the source image and the > layer name, so that is different. But apparently you do not see this > in the UI until you set it. > > I modified the script so in the UI you'll see the layer name as the > image name. However when you save it, it will then save to a different > name, and hence to a different file. > > What is your take on the correct approach? > > Also note the difference between splitting an image that already has a > file association and an image that has not (such as a generated logo): > the first saves next to the source image, while the second puts it, > for lack of something better, in ~/.gimp-n.n/tmp/ > > If we'd let the script only split, not save, things would be easier. > How are you going to use it? > > ;; -*- mode: Gimp; -*- > (define (script-fu-save-layers-to-files image dont-ask display-images) > (let ((basename (car (gimp-image-get-filename image)))) > (when (string=? basename "") > (set! basename (string-append > (car (gimp-temp-name "")) > (car (gimp-image-get-name image))))) > (let loop ((layers (vector->list (cadr (gimp-image-get-layers > image))))) > (unless (null? layers) > (gimp-edit-copy (car layers)) > (let* ((img (car (gimp-edit-paste-as-new))) > (layer-name (car (gimp-drawable-get-name (car layers)))) > (new-name (string-append > basename > layer-name > ".png"))) > (gimp-image-set-filename img layer-name) > (file-png-save dont-ask > img > (aref (cadr (gimp-image-get-layers img)) 0) > new-name > new-name > TRUE 9 FALSE TRUE FALSE FALSE TRUE) > (if (= FALSE display-images) > ;; clean up afterwards if we are not going to > ;; display the images anyway: > (gimp-image-delete img) > (gimp-display-new img))) > (loop (cdr layers)))))) > > (script-fu-register "script-fu-save-layers-to-files" > _"Save all layers to a different file" > _"Saves all layers to separate .png files" > "Niels Giesen (niels.giesen@gmail.com)" > "Niels Giesen" > "2008-10-10" > "" > SF-IMAGE "Image" 1 > SF-TOGGLE _"Don't ask options for each layer" TRUE > SF-TOGGLE _"Display images?" FALSE) > > (script-fu-menu-register "script-fu-save-layers-to-files" > _"<Image>/Filters/Generic") Don't sweat it bro' I'm busy today so I'll look at it later. Otherwise it should be o.k... After I fiddle around with it I'll offer any feedback or comments at that point. Anyway, looks like you are pretty good with scripts for Gimp.... Which reminds me of a plugin I'd like to see added to Gimp. The idea is this. Create a plugin that keeps a list of all available plugins at the plugin registry. You can check/uncheck any plugins to add/delete them from your active plugins. All in alphabetic or 'group' order for easy searching/selecting. This way you don't have to go to the web site, download and then install.. This would probably be the most handy plugin ever.. Think of it as the 'plugin for plugins' plugin.... (pfp ?) Anyway, if you could do that I think you will become quite well liked by Gimp users everywhere...or at least I'd appreciate it... I'll leave the tough work to you if you think you can do it.. A little dash of wget and some local repository structure and your on your way... P.S. Just hoping as I've wished for such a thing for many years.. If you could pull this off you'd be on your way to international stardom... Thanks again for the original plugin. I'll be using it.
Message-ID:<87abdajocf.fsf@gmail.com>
Subject:
Re: Export all layers to distinct files?
Date:Sun, 12 Oct 2008 07:53:52 +0100
Michael Soibelman <in-the@ether.net> writes: > Don't sweat it bro' I'm busy today so I'll look at it later. Otherwise it > should be o.k... After I fiddle around with it I'll offer any feedback or > comments at that point. > > Anyway, looks like you are pretty good with scripts for Gimp.... Which > reminds me of a plugin I'd like to see added to Gimp. The idea is this. > Create a plugin that keeps a list of all available plugins at the plugin > registry. You can check/uncheck any plugins to add/delete them from your > active plugins. All in alphabetic or 'group' order for easy > searching/selecting. This way you don't have to go to the web site, > download and then install.. This would probably be the most handy plugin > ever.. Think of it as the 'plugin for plugins' plugin.... (pfp ?) > > Anyway, if you could do that I think you will become quite well liked by > Gimp users everywhere...or at least I'd appreciate it... I'll leave the > tough work to you if you think you can do it.. A little dash of wget and > some local repository structure and your on your way... First of all, I have got better things to do, and the web interface does not bother me that much, so no, I won't do it. Now, as some random thoughts regarding your proposed plug-in: "On your way", maybe, but: The Scheme used in the Gimp is pretty dumbed down and has no access to libgimp (although I can remember having read plans to give it access). Merely the act of listing many checkboxes does not work correctly (window decorations and buttons are gone, the latest do not even show up, I guess that no-one ever has wanted to use so many options). In other words: even if it could be done in Script-FU, it would be very clunky. This means such a thing would have to be scripted in Python or as a stand-alone app in anyones favourite language. Hell, I guess you could even do it in bash. You'd probably also want to have the features such as tags present in the registry, meaning you'd have to have a decent API to work with, otherwise it's scripting against HTML that might be subject to change. I am not aware of such an API. Also note that with something that would let users add plug-ins so easily, quality control is a must. If only to ward against malicious content. Which means constant human intervention. Are you willing to take that upon you? Anyway, I think such a project would basically mirror the registry website, not add a lot more, and take quite some time to develop and maintain. Though if it were present, I'd probably use it too. > P.S. Just hoping as I've wished for such a thing for many years.. If you > could pull this off you'd be on your way to international stardom... > > Thanks again for the original plugin. I'll be using it. You're welcome.



RSS News Feed