Layered PSD conversion incorrect (corrupted output)

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Post Reply
jrz
Posts: 3
Joined: 2011-01-06T01:34:15-07:00
Authentication code: 8675308

Layered PSD conversion incorrect (corrupted output)

Post by jrz »

We have an image that refuses to convert correctly.
It is a PSD, and we've resaved it several times, but that didn't work.
I've updated to the latest version imagemagick (), but it still doesn't work.
The issue is in layers 6-10 (see the output)

The commands used are (simplified, in prod we use clippings masks too, but the problem is in some specific layers):
convert -flatten -thumbnail 1024x1024 badimage.psd badimage.png
convert -thumbnail 1024x1024 -flatten badimage.psd badimage_flattened.png

Versions tried (both mac os/x, using macports):
Version: ImageMagick 6.6.5-0 2010-10-31 Q16 http://www.imagemagick.org
and
Version: ImageMagick 6.6.6-3 2011-01-06 Q16 http://www.imagemagick.org

In Preview.app and ArtiosCAD the image shows up properly

Files and output are available at:
http://s3-eu-west-1.amazonaws.com/publi ... ge.psd.zip
http://s3-eu-west-1.amazonaws.com/publi ... 50_q16.zip
http://s3-eu-west-1.amazonaws.com/publi ... 63_q16.zip
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Layered PSD conversion incorrect (corrupted output)

Post by fmw42 »

I am not an expert on PSD. But from my experience IM has limited PSD capabilities with regard to other than image layers and even those don't always get extracted correctly. But the first layer of the PSD should be the flattened image (if it is a PSD from a current version of PS and one has saved it with the proper check boxes checked (such as transparency, etc).

However, your syntax is not current, though it may still work. For IM 6, the syntax should be

convert badimage.psd -flatten -thumbnail 1024x1024 badimage.png
convert badimage.psd -thumbnail 1024x1024 -flatten badimage_flattened.png

But if the first image is your flattened layers already then try

convert badimage.psd[0] badimage.png

As png does not support multi-layers, if you want to extract all the layers (so you can see what IM can do), then try

convert badimage.psd badimage.png

or

convert badimage.psd badimage_%d.png

or

convert badimage.psd +adjoin badimage.png
jrz
Posts: 3
Joined: 2011-01-06T01:34:15-07:00
Authentication code: 8675308

Re: Layered PSD conversion incorrect (corrupted output)

Post by jrz »

Actually, both methods give the same result.

We only want to create a preview of the psd, the full command is

convert -density 400 -size 1600x1200 badimage.psd -flatten -strip ( +clone -thumbnail 64x64 -colorspace RGB -quality 85 +write thumb.jpg +delete ) ( +clone -thumbnail 128x128 -colorspace RGB -quality 85 +write icon.jpg +delete ) ( +clone -thumbnail 800x600 -colorspace RGB -quality 85 +write preview.jpg +delete ) -thumbnail 10x10 -colorspace RGB -quality 10 remove.jpg

I only posted the separate layers to indicate where things go wrong.
zaratol
Posts: 43
Joined: 2010-04-21T08:30:43-07:00
Authentication code: 8675308

Re: Layered PSD conversion incorrect (corrupted output)

Post by zaratol »

If you only want a preview you should try badimage.psd[0] instead of badimage.psd as fmw42 described. It should work in most cases (Maximize Compatibility must be on!)

BTW: Is there a way to check a psd File if it was saved with this Option? If not you get this little B&W Image telling you it was not (This layerd Photoshop file was not saved with a composite image)
I'd rather make a switch before conversion rather then checking the result an do the conversion again.
jrz
Posts: 3
Joined: 2011-01-06T01:34:15-07:00
Authentication code: 8675308

Re: Layered PSD conversion incorrect (corrupted output)

Post by jrz »

Unfortunately, that will be a no-go (I think)

We use the same command for all file types (psd, tiff, eps, ai, etc). I think the psds are saved by default that way, but I think this stuff should be done automatically be imagemagick. There's no way for us to see if it's saved that way, and it should be imagemagick's responsibility to use that layer if it's available when all we want need is a preview.

How is the [0] handled for esp, ai and tiff?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Layered PSD conversion incorrect (corrupted output)

Post by fmw42 »

How is the [0] handled for esp, ai and tiff?
As far as I know only PSD has the flattened image as layer [0]. All the rest either have no layers or individual layers that have to be flattened. But you can test for PSD and do it differently from other image formats.

Have you tried the latest IM version 6.6.6.10? No guarantees that it will work. There are still some problems that I know about in PSD files, especially grayscale ones. see for example viewtopic.php?f=3&t=17039
Post Reply