Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Photoshop EXIF tags are not read #6025

Closed
dorphalsig opened this issue Feb 6, 2022 · 3 comments · Fixed by #6030
Closed

Photoshop EXIF tags are not read #6025

dorphalsig opened this issue Feb 6, 2022 · 3 comments · Fixed by #6030
Labels

Comments

@dorphalsig
Copy link

dorphalsig commented Feb 6, 2022

Hello, Hello!

I need to detect if a file has Photoshop clipping paths present using the corresponding EXIF tags (0x07d0 - 0xbb5) However Pillow seems to ignore these tags.

from PIL import Image

img=Image.open('mypsdTiff.tiff')
psd_paths = range(0x07d0, 0x0bb5)
exif_tags = list(img.getexif().keys())
print ("Yay!" if any(path in exif_tags for path in psd_paths) else "Nay!")

Result: "Nay!"
Expected Result: "Yay!"

The tag in the file is the 0x07d0. I did test it out with exiftool.

I have the feeling I have to add this range to PIL.TiffTags?

OS: Windows 11 (and Server 2008)
Python Version: 3.9 (and 3.10)
Pillow version: 9.01

@dorphalsig dorphalsig changed the title Photoshop EXIF Tags Photoshop EXIF Tags are not read Feb 6, 2022
@dorphalsig dorphalsig changed the title Photoshop EXIF Tags are not read Photoshop EXIF tags are not read Feb 6, 2022
@radarhere
Copy link
Member

Hi. Would you be able to attach a copy of mypsdTiff.tiff?

@dorphalsig
Copy link
Author

Hey radar, thanks for replying so quick. Here it is. In a ZIP file because else I couldn't upload it.
For reference:

  • exiftool can be found here to read the paths it needs a config file (photoshop_paths.config which is found under the configs_files dir

mypsdTiff.zip

@radarhere
Copy link
Member

Thanks.

If you run exiftool -v -v mypsdTiff.tiff, part of the output will be

  | 20) PhotoshopSettings (SubDirectory) -->
  |     - Tag 0x8649 (6736 bytes, int8u[6736] read as undef[6736])
  | + [Photoshop directory, 6736 bytes]
  | | IPTCDigest = ...}.....pv....N
  | | - Tag 0x0425 (16 bytes)
  | | PrintInfo2 = ...printOutput.PstSbool.InteenumInteClrm.printSixteenBitbool.printer[snip]
  | | - Tag 0x043a (279 bytes)
  | | PrintStyle = ...printOutputOptions.CptnboolClbrboolRgsMboolCrnCboolCntCboolLblsbo[snip]
  | | - Tag 0x043b (557 bytes)
  | | ResolutionInfo (SubDirectory) -->
  | | - Tag 0x03ed (16 bytes)
  | | + [BinaryData directory, 16 bytes]
  | | | XResolution = 19660800
  | | | - Tag 0x0000 (4 bytes, int32u[1])
  | | | DisplayedUnitsX = 1
  | | | - Tag 0x0002 (2 bytes, int16u[1])
  | | | YResolution = 19660800
  | | | - Tag 0x0004 (4 bytes, int32u[1])
  | | | DisplayedUnitsY = 1
  | | | - Tag 0x0006 (2 bytes, int16u[1])
  | | PrintScaleInfo (SubDirectory) -->
  | | - Tag 0x0426 (14 bytes)
  | | + [BinaryData directory, 14 bytes]
  | | | PrintStyle = 0
  | | | - Tag 0x0000 (2 bytes, int16u[1])
  | | | PrintPosition = 0 0
  | | | - Tag 0x0002 (8 bytes, float[2])
  | | | PrintScale = 1
  | | | - Tag 0x000a (4 bytes, float[1])
  | | BackgroundColor = ......
  | | - Tag 0x03f2 (10 bytes)
  | | GlobalAngle = .
  | | - Tag 0x040d (4 bytes)
  | | GlobalAltitude = .
  | | - Tag 0x0419 (4 bytes)
  | | PrintFlags = 0 0 0 0 0 0 0 0 1
  | | - Tag 0x03f3 (9 bytes, int8u[9])
  | | PrintFlagsInfo = ..
  | | - Tag 0x2710 (10 bytes)
  | | ColorHalftoningInfo = /ff.lff../ff......2.Z..5.-..
  | | - Tag 0x03f5 (72 bytes)
  | | ColorTransferFuncs = ............................................................[snip]
  | | - Tag 0x03f8 (112 bytes)
  | | TargetLayerID = 0
  | | - Tag 0x0400 (2 bytes, int16u[1])
  | | LayersGroupInfo = 0 0 0
  | | - Tag 0x0402 (6 bytes, int16u[3])
  | | LayerGroupsEnabledID = 1 1 1
  | | - Tag 0x0430 (3 bytes, int8u[3])
  | | LayerSelectionIDs = ..
  | | - Tag 0x042d (6 bytes)
  | | GridGuidesInfo = ..@.@
  | | - Tag 0x0408 (16 bytes)
  | | URL_List = 
  | | - Tag 0x041e (4 bytes)
  | | SliceInfo (SubDirectory) -->
  | | - Tag 0x041a (833 bytes)
  | | + [BinaryData directory, 833 bytes]
  | | | SlicesGroupName = din931
  | | | - Tag 0x0014 (12 bytes, ustr32[12])
  | | | NumSlices = 1
  | | | - Tag 0x0018 (4 bytes, int32u[1])
  | | PixelInfo (SubDirectory) -->
  | | - Tag 0x0428 (12 bytes)
  | | + [BinaryData directory, 12 bytes]
  | | | PixelAspectRatio = 1
  | | | - Tag 0x0004 (8 bytes, double[1])
  | | ICC_Untagged = 1
  | | - Tag 0x0411 (1 bytes, int8u[1])
  | | IDsBaseValue = 5
  | | - Tag 0x0414 (4 bytes, int32u[1])
  | | PhotoshopThumbnail = ..^.....v.......Adobe_CM....Adobed..........................[snip]
  | | - Tag 0x040c (2962 bytes)
  | | VersionInfo (SubDirectory) -->
  | | - Tag 0x0421 (97 bytes)
  | | + [BinaryData directory, 97 bytes]
  | | | HasRealMergedData = 1
  | | | - Tag 0x0004 (1 bytes, int8u[1])
  | | | WriterName = Adobe Photoshop
  | | | - Tag 0x0005 (30 bytes, ustr32[30])
  | | | ReaderName = Adobe Photoshop CC 2015.5
  | | | - Tag 0x0009 (50 bytes, ustr32[50])
  | | Photoshop_0x07d0 = ..+...N.....DD..v....?......T.....U.../..Sy..\.T.....U....e.X.[snip]
  | | - Tag 0x07d0, Name="Pfad 1" (1196 bytes)
  | | OriginPathInfo = ..null..keyRootDescriptorListVlLs.Objc.null..keyDescriptorListVl[snip]
  | | - Tag 0x0bb8, Name="OriginDataIRB" (154 bytes)

The information you're after is within the PhotoshopSettings subdirectory, tag 0x8649, a "Collection of Photoshop 'Image Resource Blocks'".

I've created PR #6030 to add a new method, getphotoshopblocks(), that extracts information from tag 0x8649. With that PR, the following code

from PIL import Image
img=Image.open('mypsdTiff.tiff')
psd_paths = range(0x07d0, 0x0bb5)
blocks = list(img.getphotoshopblocks().keys())
print("Yay!" if any(path in blocks for path in psd_paths) else "Nay!")

prints "Yay!"

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants