Couldn't get layers and its layer count

Started by minhnp, September 10, 2019, 12:57:45 AM

Previous topic - Next topic

minhnp

I have problem when i try to get layer name from a psd file. It contains 3 layers but exiftool return 0 layer.
I don't know if there's any special setting inside file but it seems normal. I've uploaded file here: https://drive.google.com/drive/folders/1dnLMlCURF9HcUVzo5s_vHgUVfDNVL5NR?usp=sharing
I used exiftool version 11.55 on Ubuntu and version 11.53 on Windows 10.
Command used: exiftool -u -json Filename > file.json


Hayo Baan

I analysed your psd and while it opens just fine in Photoshop and shows the layers, exiftool can indeed not find the layers. I'm not sure what the cause is, but somehow the file is invalid. If you validate the file with exiftool you get a number of warnings:
[ExifTool]      Validate                        : 5 Warnings (4 minor)
[ExifTool]      Warning                         : [minor] Odd offset for IFD0 tag 0x011a XResolution
[ExifTool]      Warning                         : [minor] Odd offset for IFD0 tag 0x011b YResolution
[ExifTool]      Warning                         : [minor] Odd offset for IFD0 tag 0x0131 Software
[ExifTool]      Warning                         : [minor] Odd offset for IFD0 tag 0x0132 ModifyDate
[ExifTool]      Warning                         : IFD1:ThumbnailLength is zero


I tried saving the file anew as psd, but the problems persisted. When saving as TIFF they actually got worse:
[ExifTool]      Validate                        : 5 Warnings (3 minor)
[ExifTool]      Warning                         : Non-standard format (undef) for IFD0 0x83bb IPTC-NAA
[ExifTool]      Warning                         : [minor] Non-standard IFD0 tag 0x935c ImageSourceData
[ExifTool]      Warning                         : Missing required TIFF ExifIFD tag 0xa000 FlashpixVersion
[ExifTool]      Warning                         : [minor] ExifIFD tag 0xa002 ExifImageWidth is not allowed in TIFF
[ExifTool]      Warning                         : [minor] ExifIFD tag 0xa003 ExifImageHeight is not allowed in TIFF


So there is an issue with this file and/or how Photoshop saves it. But at least in the tiff case I was able to get the layer information:
[Photoshop]     LayerCount                      : 3
[Photoshop]     LayerRectangles                 : 717 623 960 1195, 717 624 960 1116, 716 450 2019 1374
[Photoshop]     LayerBlendModes                 : Normal, Multiply, Normal
[Photoshop]     LayerOpacities                  : 100%, 100%, 100%
[Photoshop]     LayerNames                      : Layer 3, Layer 4, Layer 2
[Photoshop]     LayerUnicodeNames               : Layer 3, Layer 4, Layer 2
[Photoshop]     LayerModifyDates                : 2019:09:10 07:47:46+02:00, 2019:09:10 07:47:46+02:00, 2019:09:10 07:47:46+02:00
Hayo Baan – Photography
Web: www.hayobaan.nl

minhnp

Thank you, Hayo Bann!
I've tried to save as tif and exiftool can get all layers as your result but i don't really understand why PSD got that problem because i didn't do anything special with that image.
Btw, when i try to flatten the newly saved tif, exfiftool won't return any layer. I thought at least it must return the "Background": https://drive.google.com/drive/folders/1dnLMlCURF9HcUVzo5s_vHgUVfDNVL5NR?usp=sharing

Hayo Baan

I dug some further and found that

  • Even a freshly created psd has a validation error (IFD1:ThumbnailLength is zero).
  • A tiff saved from from Photoshop always seems to have a number of validation errors.
  • I can not get layer info from a layered psd if it doens't have a background layer, but I can when I add the background layer. So perhaps there's something exiftool can do to improve here?
Hayo Baan – Photography
Web: www.hayobaan.nl

Hayo Baan

I looked at this a bit more, and it looks like exiftool does not correctly decode information in the psd file. In the example I analysed, it's expecting to find the layer count (and the rest of the layer information) 26 bytes earlier in the block than it is (I compared the TIFF and the PSD data for this; the layer info block is the same so it's easy to compare). Not sure what the error in the code is, but I'm sure Phil should be able to fix this when he gets back.
Hayo Baan – Photography
Web: www.hayobaan.nl

minhnp

Thank you Hayo!
Looking for the next release from Phil.

Phil Harvey

The validation errors are mainly from the embedded TIFF metadata, and not related to the PSD file structure.

The layers for some PSD files are stored contrary to the Adobe file format documentation, but ExifTool has been patched using 3rd-party information to deal with these.  Unfortunately the 3rd-party information wasn't complete, and didn't work for this particular file.  However, I will patch the patch in ExifTool 11.66 so the layers will be read properly from the PSD sample you posted.

Thanks for this report.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

Phil Harvey

...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

minhnp