Page 1 of 1

Gimp's XCF conversion with layer selection

Posted: 2010-12-04T14:44:00-07:00
by ultr
Hello,

I need to convert XCF file and be able to choose which layer (by name or by number) should be visible.

My XCF image has 10 layers, and i would like to create images containing layers: 1+8, 1+9, 1+10, 2+8. 2+9, 2+10, ...
This can be done in a loop within a simple bash script, but does ImageMagick provide a way to export certain layers only?


Thanks,

ultr

Re: Gimp's XCF conversion with layer selection

Posted: 2010-12-04T15:45:55-07:00
by fmw42
see the usage of [#] at http://www.imagemagick.org/Usage/files/#read_mods

convert image[0] result

will extract the first layer (frame) or multi-frame or multi-layer images such as gif, tiff, etc

Re: Gimp's XCF conversion with layer selection

Posted: 2010-12-04T16:57:06-07:00
by ultr
Thanks for your reply.

I have some problems though.

First of all converting of source.xcf'[0]' and source.xcf'[1]' work, but source.xcf'[2]' and above do not:

Code: Select all

convert: subimage specification returns no images `source.xcf' @ error/constitute.c/ReadImage/609.
And it creates 2 result files: result0-1.png and result1-1.png. Strange.

I cannot figure out how to combine more than 1 layer into the result image as well.

And the semi-transparency is lost when converting to png file :/

Re: Gimp's XCF conversion with layer selection

Posted: 2010-12-04T17:28:17-07:00
by fmw42
There are some bugs with transparency in PNG getting lost that should be fixed in the now current release 6.6.6.3.

I don't know that you want or should quote the [#]. I have not had problems without doing that.

How is that you want to combine two images? Do you want to make two frames or layers or do you want to overlay them in some way. If the latter, then see convert ... -compose ... -composite

http://www.imagemagick.org/Usage/layers/


With regard to your xcf image, perhaps you should post a link to the image so that others can test with it. You did not show your commands either, so no one can see if there are any mistakes.

I don't believe that PNG supports multiple frames/layers, so that is why you get separate images with -0, -1 appended. Use gif or tiff for example or some other multi-frame supporting format.


Consider:

convert rose: rose: rose: rose: rose: rose5.gif
identify rose5.gif
rose5.gif[0] GIF 70x46 70x46+0+0 8-bit PseudoClass 256c 17.6KB 0.000u 0:00.009
rose5.gif[1] GIF 70x46 70x46+0+0 8-bit PseudoClass 256c 17.6KB 0.000u 0:00.009
rose5.gif[2] GIF 70x46 70x46+0+0 8-bit PseudoClass 256c 17.6KB 0.000u 0:00.009
rose5.gif[3] GIF 70x46 70x46+0+0 8-bit PseudoClass 256c 17.6KB 0.000u 0:00.009
rose5.gif[4] GIF 70x46 70x46+0+0 8-bit PseudoClass 256c 17.6KB 0.000u 0:00.000

So the above has created a 5 frame/layer image.


convert rose5.gif[1-3] rose1to3.gif
identify rose1to3.gif
rose1to3.gif[0] GIF 70x46 70x46+0+0 8-bit PseudoClass 256c 10.9KB 0.000u 0:00.010
rose1to3.gif[1] GIF 70x46 70x46+0+0 8-bit PseudoClass 256c 10.9KB 0.000u 0:00.010
rose1to3.gif[2] GIF 70x46 70x46+0+0 8-bit PseudoClass 256c 10.9KB 0.000u 0:00.010

So the above has made a 3 frame/layer image from frames 1,2,3

Re: Gimp's XCF conversion with layer selection

Posted: 2010-12-04T17:40:28-07:00
by ultr
I tested [#] with:
$ convert source.xcf[0] result0.png
$ convert source.xcf[1] result1.png
$ convert source.xcf[2] result2.png
And got the error here.

Source XCF has 10 layers, but identify shows only 2:

$ identify source.xcf
source.xcf[0] XCF 64x64 64x64+0+0 8-bit DirectClass 86.2KB 0.020u 0:00.009
source.xcf[1] XCF 64x64 64x64+0+0 8-bit DirectClass 0.010u 0:00.000


And what I want is to simply overlay the chosen layers.

Re: Gimp's XCF conversion with layer selection

Posted: 2010-12-04T17:42:45-07:00
by fmw42
There may be special gimp layers that IM does not recognize?

See the page I listed above for overlaying two images. Or see http://www.imagemagick.org/Usage/compose/#compose for overlaying just two images (with or without a mask image).

Re: Gimp's XCF conversion with layer selection

Posted: 2010-12-04T17:54:09-07:00
by ultr
Well, all the layers are similar. Same size, default overlay mode, etc.

I have found xcf2png tool which solves this particular problem.
xcf2png source.xcf layer0 layer1 layer5 > result.png


Anyway thanks for your help.

Re: Gimp's XCF conversion with layer selection

Posted: 2010-12-06T00:56:58-07:00
by anthony
I would post your image and a bug report in the Bugs forum.

If the image has 10 layers IM should see them. As such something is wrong in the XCF module.