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

Incorrect JPEG EXIF write #5490

Closed
AdrienF opened this issue May 11, 2021 · 2 comments · Fixed by #5495
Closed

Incorrect JPEG EXIF write #5490

AdrienF opened this issue May 11, 2021 · 2 comments · Fixed by #5495

Comments

@AdrienF
Copy link

AdrienF commented May 11, 2021

What did you do?

Open an image with, save it with its exif data.

What did you expect to happen?

The content of the exif in both image should be the same using standard tool like exiftool.

What actually happened?

Some fields raise a parsing waning in exiftool (ie CFAPattern), and other have their value changed (ie ExifVersion).

What are your OS, Python and Pillow versions?

  • OS: Ubuntu 20.04
  • Python: 3.8.5
  • Pillow: 8.2.0
from PIL import Image
#open a jpeg image
im = Image.open("/tmp/img_original.jpg")
# save it with original parameters, but it doesn't change the problem to use default values
im.save("/tmp/as_is.jpg", exif=im.getexif(), quality=95, progressive=True, subsampling="4:4:4")

input image:
img_original

Output image:
as_is

Input exif (extracted using exiftool -s img_original.jpg > original.exif):

ExifToolVersion                 : 11.88
FileName                        : img_original.jpg
Directory                       : .
FileSize                        : 38 kB
FileModifyDate                  : 2021:05:11 17:22:33+02:00
FileAccessDate                  : 2021:05:11 17:22:59+02:00
FileInodeChangeDate             : 2021:05:11 17:22:33+02:00
FilePermissions                 : rw-rw-r--
FileType                        : JPEG
FileTypeExtension               : jpg
MIMEType                        : image/jpeg
JFIFVersion                     : 1.01
ExifByteOrder                   : Little-endian (Intel, II)
ImageDescription                : 1056 783
Make                            : REDACTED
Model                           : REDACTED
Orientation                     : Horizontal (normal)
XResolution                     : 300
YResolution                     : 300
ResolutionUnit                  : inches
Software                        : GIMP 2.10.18
ModifyDate                      : 2021:05:11 17:20:27
Copyright                       : REDACTED
ExposureTime                    : 1/1106
ExposureProgram                 : Not Defined
ISO                             : 100
ExifVersion                     : 0230
DateTimeOriginal                : 2021:04:29 16:00:00
ComponentsConfiguration         : Y, Cb, Cr, -
BrightnessValue                 : 1
SubjectDistance                 : 0 m
MeteringMode                    : Unknown
LightSource                     : Unknown
Flash                           : No Flash
UserComment                     : 1056 783
FlashpixVersion                 : 0100
ColorSpace                      : sRGB
ExifImageWidth                  : 1920
ExifImageHeight                 : 692
SensingMethod                   : One-chip color area
SceneType                       : Directly photographed
CFAPattern                      : [Red,Green][Green,Blue]
CustomRendered                  : Normal
WhiteBalance                    : Auto
GainControl                     : None
Contrast                        : Normal
Saturation                      : Normal
Sharpness                       : Normal
SubjectDistanceRange            : Unknown
GPSVersionID                    : 0.0.2.3
GPSLatitudeRef                  : North
GPSLongitudeRef                 : East
GPSTimeStamp                    : 07:31:14
GPSDateStamp                    : 2021:31:26
Compression                     : JPEG (old-style)
PhotometricInterpretation       : YCbCr
SamplesPerPixel                 : 3
ThumbnailOffset                 : 1062
ThumbnailLength                 : 4486
ProfileCMMType                  : Little CMS
ProfileVersion                  : 4.3.0
ProfileClass                    : Display Device Profile
ColorSpaceData                  : RGB
ProfileConnectionSpace          : XYZ
ProfileDateTime                 : 2021:05:11 15:20:00
ProfileFileSignature            : acsp
PrimaryPlatform                 : Apple Computer Inc.
CMMFlags                        : Not Embedded, Independent
DeviceManufacturer              : 
DeviceModel                     : 
DeviceAttributes                : Reflective, Glossy, Positive, Color
RenderingIntent                 : Perceptual
ConnectionSpaceIlluminant       : 0.9642 1 0.82491
ProfileCreator                  : Little CMS
ProfileID                       : 0
ProfileDescription              : GIMP built-in sRGB
ProfileCopyright                : Public Domain
MediaWhitePoint                 : 0.9642 1 0.82491
ChromaticAdaptation             : 1.04788 0.02292 -0.05022 0.02959 0.99048 -0.01707 -0.00925 0.01508 0.75168
RedMatrixColumn                 : 0.43604 0.22249 0.01392
BlueMatrixColumn                : 0.14305 0.06061 0.71393
GreenMatrixColumn               : 0.38512 0.7169 0.09706
RedTRC                          : (Binary data 32 bytes, use -b option to extract)
GreenTRC                        : (Binary data 32 bytes, use -b option to extract)
BlueTRC                         : (Binary data 32 bytes, use -b option to extract)
ChromaticityChannels            : 3
ChromaticityColorant            : Unknown (0)
ChromaticityChannel1            : 0.64 0.33002
ChromaticityChannel2            : 0.3 0.60001
ChromaticityChannel3            : 0.15001 0.06
DeviceMfgDesc                   : GIMP
DeviceModelDesc                 : sRGB
Comment                         : 1056 783
ImageWidth                      : 1920
ImageHeight                     : 692
EncodingProcess                 : Progressive DCT, Huffman coding
BitsPerSample                   : 8
ColorComponents                 : 3
YCbCrSubSampling                : YCbCr4:4:4 (1 1)
ImageSize                       : 1920x692
Megapixels                      : 1.3
ShutterSpeed                    : 1/1106
ThumbnailImage                  : (Binary data 4486 bytes, use -b option to extract)
GPSDateTime                     : 2021:31:26 07:31:14Z
GPSLatitude                     : 48 deg 42' 40.32" N
GPSLongitude                    : 6 deg 10' 26.76" E
GPSPosition                     : 48 deg 42' 40.32" N, 6 deg 10' 26.76" E

Output EXIF:

ExifToolVersion                 : 11.88
FileName                        : as_is.jpg
Directory                       : .
FileSize                        : 33 kB
FileModifyDate                  : 2021:05:11 17:30:28+02:00
FileAccessDate                  : 2021:05:11 17:30:28+02:00
FileInodeChangeDate             : 2021:05:11 17:30:28+02:00
FilePermissions                 : rw-rw-r--
FileType                        : JPEG
FileTypeExtension               : jpg
MIMEType                        : image/jpeg
JFIFVersion                     : 1.01
ExifByteOrder                   : Little-endian (Intel, II)
ImageDescription                : 1056 783
Make                            : REDACTED
Model                           : REDACTED
Orientation                     : Horizontal (normal)
XResolution                     : 300
YResolution                     : 300
ResolutionUnit                  : inches
Software                        : GIMP 2.10.18
ModifyDate                      : 2021:05:11 17:20:27
Copyright                       : REDACTED
ExposureTime                    : 1/1106
ExposureProgram                 : Not Defined
ISO                             : 100
ExifVersion                     : 48 50 51 48
DateTimeOriginal                : 2021:04:29 16:00:00
ComponentsConfiguration         : Y, Cb, Cr, -
BrightnessValue                 : 1
SubjectDistance                 : 0 m
MeteringMode                    : Unknown
LightSource                     : Unknown
Flash                           : No Flash
UserComment                     : 1056 783
FlashpixVersion                 : 48 49 48 48
ColorSpace                      : sRGB
ExifImageWidth                  : 1920
ExifImageHeight                 : 692
SensingMethod                   : One-chip color area
SceneType                       : Directly photographed
Warning                         : [minor] Invalid CFAPattern
CFAPattern                      : <invalid pattern size>
CustomRendered                  : Normal
WhiteBalance                    : Auto
GainControl                     : None
Contrast                        : Normal
Saturation                      : Normal
Sharpness                       : Normal
SubjectDistanceRange            : Unknown
GPSVersionID                    : 0.0.2.3
GPSLatitudeRef                  : North
GPSLongitudeRef                 : East
GPSTimeStamp                    : 07:31:14
GPSDateStamp                    : 2021:31:26
ImageWidth                      : 1920
ImageHeight                     : 692
EncodingProcess                 : Progressive DCT, Huffman coding
BitsPerSample                   : 8
ColorComponents                 : 3
YCbCrSubSampling                : YCbCr4:4:4 (1 1)
ImageSize                       : 1920x692
Megapixels                      : 1.3
ShutterSpeed                    : 1/1106
GPSDateTime                     : 2021:31:26 07:31:14Z
GPSLatitude                     : 48 deg 42' 40.32" N
GPSLongitude                    : 6 deg 10' 26.76" E
GPSPosition                     : 48 deg 42' 40.32" N, 6 deg 10' 26.76" E
@radarhere
Copy link
Member

I've created #5495 to specify the tag types for CFAPattern, ExifVersion and FlashpixVersion. Once that is done, here is the output from exiftool -s, where those tags match your original values.

ExifToolVersion                 : 12.16
FileName                        : out.jpg
Directory                       : .
FileSize                        : 26 KiB
FileModifyDate                  : 2021:05:14 18:55:40+10:00
FileAccessDate                  : 2021:05:14 18:55:40+10:00
FileInodeChangeDate             : 2021:05:14 18:55:40+10:00
FilePermissions                 : rw-r--r--
FileType                        : JPEG
FileTypeExtension               : jpg
MIMEType                        : image/jpeg
JFIFVersion                     : 1.01
ExifByteOrder                   : Little-endian (Intel, II)
ImageDescription                : 1056 783
Make                            : REDACTED
Model                           : REDACTED
Orientation                     : Horizontal (normal)
XResolution                     : 300
YResolution                     : 300
ResolutionUnit                  : inches
Software                        : GIMP 2.10.18
ModifyDate                      : 2021:05:11 17:20:27
Copyright                       : REDACTED
ExposureTime                    : 1/1106
ExposureProgram                 : Not Defined
ISO                             : 100
ExifVersion                     : 0230
DateTimeOriginal                : 2021:04:29 16:00:00
ComponentsConfiguration         : Y, Cb, Cr, -
BrightnessValue                 : 1
SubjectDistance                 : 0 m
MeteringMode                    : Unknown
LightSource                     : Unknown
Flash                           : No Flash
UserComment                     : 1056 783
FlashpixVersion                 : 0100
ColorSpace                      : sRGB
ExifImageWidth                  : 1920
ExifImageHeight                 : 692
SensingMethod                   : One-chip color area
SceneType                       : Directly photographed
CFAPattern                      : [Red,Green][Green,Blue]
CustomRendered                  : Normal
WhiteBalance                    : Auto
GainControl                     : None
Contrast                        : Normal
Saturation                      : Normal
Sharpness                       : Normal
SubjectDistanceRange            : Unknown
GPSVersionID                    : 0.0.2.3
GPSLatitudeRef                  : North
GPSLongitudeRef                 : East
GPSTimeStamp                    : 07:31:14
GPSDateStamp                    : 2021:31:26
ImageWidth                      : 1920
ImageHeight                     : 692
EncodingProcess                 : Baseline DCT, Huffman coding
BitsPerSample                   : 8
ColorComponents                 : 3
YCbCrSubSampling                : YCbCr4:2:0 (2 2)
ImageSize                       : 1920x692
Megapixels                      : 1.3
ShutterSpeed                    : 1/1106
GPSDateTime                     : 2021:31:26 07:31:14Z
GPSLatitude                     : 48 deg 42' 40.32" N
GPSLongitude                    : 6 deg 10' 26.76" E
GPSPosition                     : 48 deg 42' 40.32" N, 6 deg 10' 26.76" E

Does that solve the problem for you?

@AdrienF
Copy link
Author

AdrienF commented May 19, 2021 via email

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

Successfully merging a pull request may close this issue.

2 participants