ExifTool Forum

ExifTool => Bug Reports / Feature Requests => Topic started by: minhnp on September 10, 2019, 12:57:45 AM

Title: Couldn't get layers and its layer count
Post by: minhnp on September 10, 2019, 12:57:45 AM
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

Title: Re: Couldn't get layers and its layer count
Post by: Hayo Baan on September 10, 2019, 02:10:32 AM
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
Title: Re: Couldn't get layers and its layer count
Post by: minhnp on September 10, 2019, 03:35:50 AM
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
Title: Re: Couldn't get layers and its layer count
Post by: Hayo Baan on September 10, 2019, 04:48:27 AM
I dug some further and found that
Title: Re: Couldn't get layers and its layer count
Post by: Hayo Baan on September 11, 2019, 06:15:22 AM
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.
Title: Re: Couldn't get layers and its layer count
Post by: minhnp on September 12, 2019, 12:48:07 AM
Thank you Hayo!
Looking for the next release from Phil.
Title: Re: Couldn't get layers and its layer count
Post by: Phil Harvey on September 27, 2019, 10:25:19 AM
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
Title: Re: Couldn't get layers and its layer count
Post by: Phil Harvey on September 30, 2019, 09:14:19 AM
ExifTool 11.66 is now available.

- Phil
Title: Re: Couldn't get layers and its layer count
Post by: minhnp on October 07, 2019, 06:23:54 AM
Thank you Phil!
It works perfectly.