Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Not all exif tags being read with getexif #5988

Closed
theahura opened this issue Jan 26, 2022 · 7 comments
Closed

Not all exif tags being read with getexif #5988

theahura opened this issue Jan 26, 2022 · 7 comments
Labels

Comments

@theahura
Copy link

theahura commented Jan 26, 2022

What did you do?

See code below. I opened an image and parsed the exif tags using getexif()

What did you expect to happen?

I expected a complete set of exif tags to be presented and parsed.

What actually happened?

Some exif tags were parsed, but most were not.

What are your OS, Python and Pillow versions?

  • OS: Ubuntu 20
  • Python: 3.8.10
  • Pillow: 9.0.0
import PIL
import PIL.Image
from PIL.ExifTags import TAGS

image = PIL.Image.open('./exif.jpg')
print([TAGS[k] for k in image.getexif()])

The code above outputs

['PrintImageMatching', 'ResolutionUnit', 'ExifOffset', 'Make', 'Model', 'Software', 'Orientation', 'DateTime', 'YCbCrPositioning', 'Copyright', 'XResolution', 'YResolution']

for the image:
exif

When I look at the image in the default ubuntu image viewer, I can see far more tags.
image

If I downgrade PIL to 8.0.0 and run the exact same code, I get:

['ExifVersion', 'ComponentsConfiguration', 'CompressedBitsPerPixel', 'DateTimeOriginal', 'DateTimeDigitized', 'ShutterSpeedValue', 'ApertureValue', 'BrightnessValue', 'ExposureBiasValue', 'MaxApertureValue', 'MeteringMode', 'LightSource', 'Flash', 'FocalLength', 'ColorSpace', 'ExifImageWidth', 'ExifImageHeight', 'FocalPlaneXResolution', 'FocalPlaneYResolution', 'FocalPlaneResolutionUnit', 'SubjectDistanceRange', 'Make', 'Model', 'SensingMethod', 'Orientation', 'FileSource', 'ExposureTime', 'ExifInteroperabilityOffset', 'YCbCrPositioning', 'FNumber', 'SceneType', 'Copyright', 'XResolution', 'YResolution', 'ExposureProgram', 'PrintImageMatching', 'CustomRendered', 'ISOSpeedRatings', 'ResolutionUnit', 'ExposureMode', 'FlashPixVersion', 'WhiteBalance', 'Software', 'DateTime', 'SceneCaptureType', 'Sharpness', 'ExifOffset', 'MakerNote']

This is a much more complete set of exif tags.

@radarhere radarhere added the Exif label Jan 26, 2022
@radarhere
Copy link
Member

Hi. I think this is a duplicate of #5894. See #5894 (comment) for a full explanation.

@radarhere
Copy link
Member

Testing, I think that print([TAGS[k] for k in image.getexif().get_ifd(0x8769)]) will provide you with your missing tags.

@theahura
Copy link
Author

theahura commented Jan 26, 2022

Thanks for the super fast response. I'm still not seeing all of the TAGS I would expect based on viewing the image in my default image viewer, in particular any of the GPS tags. Are those also separated somehow? How do I get everything possible?

@radarhere
Copy link
Member

radarhere commented Jan 26, 2022

Well, I would say that GPS is also an IFD - https://www.awaresystems.be/imaging/tiff/tifftags/gpsifd.html, and that you should do

print([TAGS[k] for k in image.getexif().get_ifd(0x8825)])

except that when I try that with your image, it is empty.

If I run exiftool on your image for comparison, I'm also not seeing an GPS info.

ExifTool Version Number         : 12.30
File Name                       : exif.jpg
Directory                       : .
File Size                       : 30 KiB
File Modification Date/Time     : 2022:01:26 11:19:18+11:00
File Access Date/Time           : 2022:01:26 11:45:58+11:00
File Inode Change Date/Time     : 2022:01:26 11:45:58+11:00
File Permissions                : -rw-r--r--
File Type                       : JPEG
File Type Extension             : jpg
MIME Type                       : image/jpeg
JFIF Version                    : 1.01
Exif Byte Order                 : Little-endian (Intel, II)
Make                            : FUJIFILM
Camera Model Name               : A850
Orientation                     : Horizontal (normal)
X Resolution                    : 72
Y Resolution                    : 72
Resolution Unit                 : inches
Software                        : Digital Camera FUJIFILM A850 Ver1.01
Modify Date                     : 2009:02:18 11:52:58
Y Cb Cr Positioning             : Co-sited
Copyright                       : 
Exposure Time                   : 1/50
F Number                        : 2.8
Exposure Program                : Program AE
ISO                             : 400
Exif Version                    : 0220
Date/Time Original              : 2009:02:18 11:52:58
Create Date                     : 2009:02:18 11:52:58
Components Configuration        : Y, Cb, Cr, -
Compressed Bits Per Pixel       : 2
Shutter Speed Value             : 1/50
Aperture Value                  : 2.9
Brightness Value                : 5
Exposure Compensation           : 0
Max Aperture Value              : 2.8
Metering Mode                   : Multi-segment
Light Source                    : Unknown
Flash                           : Off, Did not fire
Focal Length                    : 6.1 mm
Version                         : 0130
Internal Serial Number          : AA-8M  2008:07:31 AD058UL80888
Quality                         : NORMAL
White Balance                   : Auto
Saturation                      : 0 (normal)
Fuji Flash Mode                 : Off
Flash Exposure Comp             : 0
Macro                           : On
Focus Mode                      : Auto
AF Mode                         : No
Focus Pixel                     : 1632 1224
Slow Sync                       : Off
Picture Mode                    : Auto
Exposure Count                  : 1
Auto Bracketing                 : Off
Sequence Number                 : 0
Color Mode                      : Standard
Blur Warning                    : None
Focus Warning                   : Good
Exposure Warning                : Good
Flashpix Version                : 0100
Color Space                     : sRGB
Exif Image Width                : 3264
Exif Image Height               : 2448
Interoperability Index          : R98 - DCF basic file (sRGB)
Interoperability Version        : 0100
Focal Plane X Resolution        : 6129
Focal Plane Y Resolution        : 6129
Focal Plane Resolution Unit     : cm
Sensing Method                  : One-chip color area
File Source                     : Digital Camera
Scene Type                      : Directly photographed
Custom Rendered                 : Normal
Exposure Mode                   : Auto
Scene Capture Type              : Standard
Sharpness                       : Normal
Subject Distance Range          : Unknown
PrintIM Version                 : 0250
Compression                     : JPEG (old-style)
Thumbnail Offset                : 1910
Thumbnail Length                : 5765
Image Width                     : 400
Image Height                    : 238
Encoding Process                : Progressive DCT, Huffman coding
Bits Per Sample                 : 8
Color Components                : 3
Y Cb Cr Sub Sampling            : YCbCr4:2:0 (2 2)
Aperture                        : 2.8
Image Size                      : 400x238
Megapixels                      : 0.095
Scale Factor To 35 mm Equivalent: 6.5
Shutter Speed                   : 1/50
Thumbnail Image                 : (Binary data 5765 bytes, use -b option to extract)
Circle Of Confusion             : 0.005 mm
Field Of View                   : 48.8 deg
Focal Length                    : 6.1 mm (35 mm equivalent: 39.6 mm)
Hyperfocal Distance             : 2.87 m
Light Value                     : 6.6

What program is making you think that there is GPS data in this image?

@theahura
Copy link
Author

theahura commented Jan 26, 2022

Interesting. We have an automated test suite that's been using this image as an example for months. One of the things the test checks is the presence (and value) of GPSLat/Long. The image normally lives on S3, but I downloaded it locally and reuploaded it here -- I wonder if that stripped the tag for some reason? 🤔

I notice that you use a different ifd tag for the GPSInfo -- is there a list of those tags somewhere in PIL such that I could loop through and accumulate all of the exif that's present?

@radarhere
Copy link
Member

In my estimation, those are the important ones - EXIF and GPS.

Pillow also supports Interop (0xA005) and Makernote (0x927C but only for Fujifilm and Nintendo).

@theahura
Copy link
Author

theahura commented Jan 26, 2022

Perfect. Thanks a ton for the help!
(And really just awesome response time <3 )

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

No branches or pull requests

2 participants