Ignoring "preview" layer while converting PSD to JPEG?

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
dsearles

Ignoring "preview" layer while converting PSD to JPEG?

Post by dsearles »

Is there a generic means of ignoring the "preview" layer in PSD files while flattening them to JPEG? When I do:

convert test.psd -flatten test.jpeg

I get a JPEG which is just the "preview" layer (as that is the last one in the file). If I do NOT use "-flatten", I get 2 JPEGs: one with the image layer (my test image has just a single layer) and another with the "preview" layer.

I realize I can do:

convert test.psd[0] test.jpeg

but I want to use this technique for PSDs I know nothing about. What I'd like is something like:

convert test.psd[0-(n-1)] -flatten test.jpg

Any ideas?
dsearles

Re: Ignoring "preview" layer while converting PSD to JPEG?

Post by dsearles »

Nevermind...

After reading the docs more thoroughly, I found I actually CAN do:

convert test.psd[0--2] -flatten test.jpg

Where the "-2" is the next to last layer ("-1" would be the last).
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Ignoring "preview" layer while converting PSD to JPEG?

Post by anthony »

That assumes psd files always contains a preview image, or the PSD
file only ever has one image in the file.

Can they have multiple images?

Is the preview optional for a multi-image form?

I would like to know for completeness in IM examples.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply