Bug extracting images from PSD with negative top in v6.9.2

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
OlgerD
Posts: 15
Joined: 2015-06-01T21:53:02-07:00
Authentication code: 6789

Bug extracting images from PSD with negative top in v6.9.2

Post by OlgerD »

Hi There,
I use ImageMagick to create PSD files with images in multiple layers, open Photoshop, edit those PSD files (essentially align various layers) save it, and then extract and flatten the PSD file into a JPG. This works well in v6.9.0, but in v6.9.2 there's a bug.

Usually the toplayer in my PSD is a template and that layer is locked. The second layer is an image which needs to be aligned beneath an opening in the top layer. Think of a frame over a photo, where I position the photo under the frame.
Images aren't necessarily the same size, and can be portrait and landscape.
The script I use to flatten the PSD into a JPG uses the size of the template image to determine the crop factor. Ie, if I have a 1024x768 template and a 1400x3000 image, the end JPG will be of a size 1024x768.
The problem I encountered in v6.9.2 is that if the image is positioned so that the top of the image goes into a negative area above the template (ie I move the image upwards under the template to position it correctly, so that effectively the image has a negative top) I get a "pixel cache allocation failed" error from convert.
I eventually figured out that IM v6.9.2 for some reason translates this negative top border in the PSD file to a massive resolution. Something like 1400x32487287873253854 (not kidding). IM v 6.9.0 handles it correctly, so for the moment I've gone back to that.
Identify from IM v6.9.2 will also show this problem, whereas identify from IM v6.9.0 works correctly.

Cheers!
User avatar
dlemstra
Posts: 1570
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:

Re: Bug extracting images from PSD with negative top in v6.9.2

Post by dlemstra »

Can you reproduce this issue with the latest version? We fixed a bug on 18 September this year that could have this kind of behavior.
.NET + ImageMagick = Magick.NET https://github.com/dlemstra/Magick.NET, @MagickNET, Donate
olear
Posts: 58
Joined: 2015-05-24T10:56:42-07:00
Authentication code: 6789

Re: Bug extracting images from PSD with negative top in v6.9.2

Post by olear »

Code: Select all

Version: ImageMagick 6.9.2-4 Q32 x86_64 2015-10-12 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2015 ImageMagick Studio LLC
License: http://www.imagemagick.org/script/license.php
Features: Cipher DPC HDRI OpenMP 
Delegates (built-in): cairo fontconfig freetype pangocairo png rsvg xml zlib

Code: Select all

wget http://downloads.natron.fr/~olear/forum/pshero_0061.psd
convert pshero_0061.psd test.png
convert: pixel cache allocation failed `pshero_0061.psd' @ error/cache.c/OpenPixelCache/3559.
convert: memory allocation failed `pshero_0061.psd' @ error/psd.c/ReadPSDChannel/1094.
convert: no images defined `test.png' @ error/convert.c/ConvertImageCommand/3230.

Code: Select all

pshero_0061.psd[0] PSD 540x400 540x400+0+0 8-bit sRGB 1.213MB 0.000u 0:00.000
pshero_0061.psd[1] PSD 380x214 380x214+80+93 8-bit sRGB 1.213MB 0.000u 0:00.000
pshero_0061.psd[2] PSD 264x380 264x380+138+10 8-bit sRGB 1.213MB 0.000u 0:00.000
pshero_0061.psd[3] PSD 540x400 540x400+0+0 8-bit sRGB 1.213MB 0.000u 0:00.000
pshero_0061.psd[4] PSD 380x264 380x264+22+18 8-bit sRGB 1.213MB 0.000u 0:00.000
pshero_0061.psd[5] PSD 245x18446744069414584320 245x18446744069414584320+8+4294967286 8-bit sRGB 1.213MB 0.000u 0:00.000
pshero_0061.psd[6] PSD 202x219 202x219+112+26 8-bit sRGB 1.213MB 0.000u 0:00.000
pshero_0061.psd[7] PSD 238x140 238x140+35+30 8-bit sRGB 1.213MB 0.000u 0:00.000
pshero_0061.psd[8] PSD 231x121 231x121+30+61 8-bit sRGB 1.213MB 0.000u 0:00.000
pshero_0061.psd[9] PSD 12x51 12x51+39+127 8-bit sRGB 1.213MB 0.000u 0:00.000
pshero_0061.psd[10] PSD 58x57 58x57+216+76 8-bit sRGB 1.213MB 0.000u 0:00.000
pshero_0061.psd[11] PSD 206x17 206x17+251+96 8-bit sRGB 1.213MB 0.000u 0:00.000
pshero_0061.psd[12] PSD 219x21 219x21+251+97 8-bit sRGB 1.213MB 0.000u 0:00.000
pshero_0061.psd[13] PSD 14x25 14x25+284+91 8-bit sRGB 1.213MB 0.000u 0:00.000

Last version that work is 6.9.1-10.
User avatar
dlemstra
Posts: 1570
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:

Re: Bug extracting images from PSD with negative top in v6.9.2

Post by dlemstra »

This seems to be a 64-bit issue. I just pushed a patch to our GIT repository to fix this. This will be resolved in the next version of ImageMagick (6.9.2-5)
.NET + ImageMagick = Magick.NET https://github.com/dlemstra/Magick.NET, @MagickNET, Donate
olear
Posts: 58
Joined: 2015-05-24T10:56:42-07:00
Authentication code: 6789

Re: Bug extracting images from PSD with negative top in v6.9.2

Post by olear »

Thanks, latest git version works.
Post Reply