Page 1 of 1

PSB InvalidLength convert fail

Posted: 2017-06-05T02:05:27-07:00
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.

Re: PSB InvalidLength convert fail

Posted: 2017-06-21T02:57:58-07:00
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.

Re: PSB InvalidLength convert fail

Posted: 2017-06-21T13:50:36-07:00
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?

Re: PSB InvalidLength convert fail

Posted: 2017-06-23T02:43:37-07:00
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.

Re: PSB InvalidLength convert fail

Posted: 2017-06-23T14:16:14-07:00
by dlemstra
I can convert that image with both the latest version of ImageMagick 6 and 7 without any issues.