PSB InvalidLength convert fail

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
ChrisHSandN
Posts: 3
Joined: 2017-06-05T01:49:26-07:00
Authentication code: 1151

PSB InvalidLength convert fail

Post by ChrisHSandN »

I am using convert to go from a psb file (Photoshop Big) to a tiff (so I can feed it into another piece of software)

Code: Select all

convert -debug all '/path/to/file.psb' TIFF64:'/path/to/file.tif' 
However it fails with the following errors:

Code: Select all

2017-06-02T17:13:34+01:00 0:51.480 11.180u 7.0.4 Exception convert[2125]: psd.c/ReadPSDChannelRLE/1123/Exception
  InvalidLength `/path/to/file.psb'
2017-06-02T17:13:34+01:00 0:51.480 11.180u 7.0.4 Exception convert[2125]: psd.c/ReadPSDImage/2162/Exception
  insufficient image data in file `/path/to/file.psb'
2017-06-02T17:13:34+01:00 0:51.480 11.180u 7.0.4 Resource convert[2125]: resource.c/RelinquishMagickResource/968/Resource
  Map: 1.6784GB/6.2565GiB/15.241GiB
In the code line:1119
https://github.com/ImageMagick/ImageMag ... ders/psd.c
It allows row_size to be 256 larger than length and this is commented as “arbitrary number”

I have hacked about in the psb.c code and outputted that my file has
length 38654
row_size 38381
when it fails

That’s about the limit of my understanding...

Is it possible this 256 number needs to be made larger in the code or am I hitting some kind of sanity check showing my file is violating something?

I have multiple files which exhibit the issue; all saved with Photoshop CS5 (but also lots which work fine)

Unfortunately the smallest file I have which fails is 1.6GB but I can possibly provide this if necessary.
ChrisHSandN
Posts: 3
Joined: 2017-06-05T01:49:26-07:00
Authentication code: 1151

Re: PSB InvalidLength convert fail

Post by ChrisHSandN »

As reference for anyone finding this thread in the future:

I tried commenting out the failing check in the imagemagick psd.c code but (unsurprisingly) although the convert then completed the resulting TIFF was corrupt.

As a workaround I have moved to using http://telegraphics.com.au/sw/product/psdparse as an intermediate step to convert the failing psb to a png first.
User avatar
dlemstra
Posts: 1570
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:

Re: PSB InvalidLength convert fail

Post by dlemstra »

Was psdparse able to read the file without any issues? Can you share a file on something like dropbox if it works there?
.NET + ImageMagick = Magick.NET https://github.com/dlemstra/Magick.NET, @MagickNET, Donate
ChrisHSandN
Posts: 3
Joined: 2017-06-05T01:49:26-07:00
Authentication code: 1151

Re: PSB InvalidLength convert fail

Post by ChrisHSandN »

I have found that I can create a much smaller failing psb by blanking all the pixels to white and saving it. Here is a much more manageable 26MB file:

https://www.dropbox.com/s/t5e82aot3yu5d ... h.psb?dl=0

This file works in psdparse but not in imagemagick.
User avatar
dlemstra
Posts: 1570
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:

Re: PSB InvalidLength convert fail

Post by dlemstra »

I can convert that image with both the latest version of ImageMagick 6 and 7 without any issues.
.NET + ImageMagick = Magick.NET https://github.com/dlemstra/Magick.NET, @MagickNET, Donate
Post Reply