Sony picture - PHP Warning - Make, Model, MakerNotes

Started by 7tonin, June 10, 2020, 06:46:45 AM

Previous topic - Next topic

7tonin

Hello,
My webserver was facing a problem extracting thumbnail from an image. It looks there is/was a bug in PHP code https://bugs.php.net/bug.php?id=77563 but still occurring with my PHP Version 7.3.18
PHP Warning:  exif_thumbnail(image.jpg): IFD data too short: 0x000C offset 0x000C
PHP Warning:  exif_read_data(image.jpg): IFD data too short: 0x000C offset 0x000C

Notice that when editing image with Exiftool, a warning is send:
Warning: [minor] Maker notes could not be parsed - image.jpg

As with others softwares this image looks normal, I dig into metadata to find a solution. After a while, I manage to solve my webserver problem by changing Make tag value.
https://exiftool.org/faq.html#Q8

Former output values were: exiftool image.jpg (excerpt)
Make                            : SONY
Camera Model Name               : DSC-W55
Warning                         : Bad MakerNotes directory


Solving the webserver problem with this command line:
exiftool -make=Sony image.jpg

New output values are: exiftool image.jpg (excerpt)
Make                            : Sony
Camera Model Name               : DSC-W55
Warning                         : Bad MakerNotes directory


Then, no more PHP Warning.
Thanks a lot Exiftool  :D



Phil Harvey

I don't see how changing the Make would change the way the ThumbnailImage is loaded.  But there could be a structural problem that ExifTool fixes when you write any EXIF tag.  Does it fix the thumbnail problem if you, say, write -artist=me instead of changing the Make?

- 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 ($).

7tonin

I have writen -artist=me but this does not change the thumbnail loading problem.
If I put -make=SYNO instead of -make=SONY, it solves the issue too. So I would say PHP exif data reader has a problem with "SONY". The problem is that PHP does not find has many sections in both cases.

Below are the outputs in both cases. Outputs given by simple example code https://www.php.net/manual/en/function.exif-read-data.php#refsect1-function.exif-read-data-examples.
In second case, SYNO make case, one field looks stranger: IFD0.UndefinedTag:0xC4A5 : PrintIM0300


FILE.FileName : image.jpg
FILE.FileDateTime : 1591809895
FILE.FileSize : 205578
FILE.FileType : 2
FILE.MimeType : image/jpeg
FILE.SectionsFound : ANY_TAG, IFD0, EXIF
COMPUTED.html : width="355" height="472"
COMPUTED.Height : 472
COMPUTED.Width : 355
COMPUTED.IsColor : 1
COMPUTED.ByteOrderMotorola : 1
COMPUTED.ApertureFNumber : f/7.1
IFD0.ImageDescription :
IFD0.Make : SONY
IFD0.Model : DSC-W55
IFD0.Orientation : 1
IFD0.XResolution : 72/1
IFD0.YResolution : 72/1
IFD0.ResolutionUnit : 2
IFD0.Software : Microsoft Windows Photo Gallery 6.0.6000.16386
IFD0.DateTime : 2007:09:24 09:58:17
IFD0.Artist : me
IFD0.YCbCrPositioning : 2
EXIF.ExposureTime : 10/12500
EXIF.FNumber : 71/10
EXIF.ExposureProgram : 2
EXIF.ISOSpeedRatings : 1000
EXIF.ExifVersion : 0221
EXIF.DateTimeOriginal : 2007:09:23 14:40:11
EXIF.DateTimeDigitized : 2007:09:23 14:40:11
EXIF.ComponentsConfiguration : 
EXIF.CompressedBitsPerPixel : 4/1
EXIF.ExposureBiasValue : 0/10
EXIF.MaxApertureValue : 48/16
EXIF.MeteringMode : 2
EXIF.LightSource : 1
EXIF.Flash : 16
EXIF.FocalLength : 63/10



FILE.FileName : image.jpg
FILE.FileDateTime : 1591809117
FILE.FileSize : 205578
FILE.FileType : 2
FILE.MimeType : image/jpeg
FILE.SectionsFound : ANY_TAG, IFD0, THUMBNAIL, EXIF, INTEROP
COMPUTED.html : width="355" height="472"
COMPUTED.Height : 472
COMPUTED.Width : 355
COMPUTED.IsColor : 1
COMPUTED.ByteOrderMotorola : 1
COMPUTED.ApertureFNumber : f/7.1
COMPUTED.Thumbnail.FileType : 2
COMPUTED.Thumbnail.MimeType : image/jpeg

IFD0.ImageDescription :
IFD0.Make : SYNO
IFD0.Model : DSC-W55
IFD0.Orientation : 1
IFD0.XResolution : 72/1
IFD0.YResolution : 72/1
IFD0.ResolutionUnit : 2
IFD0.Software : Microsoft Windows Photo Gallery 6.0.6000.16386
IFD0.DateTime : 2007:09:24 09:58:17
IFD0.Artist : me
IFD0.YCbCrPositioning : 2
IFD0.Exif_IFD_Pointer : 328
IFD0.UndefinedTag:0xC4A5 : PrintIM0300

THUMBNAIL.Compression : 6
THUMBNAIL.XResolution : 1/96
THUMBNAIL.YResolution : 1/96
THUMBNAIL.ResolutionUnit : 2
THUMBNAIL.JPEGInterchangeFormat : 964
THUMBNAIL.JPEGInterchangeFormatLength : 20889
EXIF.ExposureTime : 10/12500
EXIF.FNumber : 71/10
EXIF.ExposureProgram : 2
EXIF.ISOSpeedRatings : 1000
EXIF.ExifVersion : 0221
EXIF.DateTimeOriginal : 2007:09:23 14:40:11
EXIF.DateTimeDigitized : 2007:09:23 14:40:11
EXIF.ComponentsConfiguration : 
EXIF.CompressedBitsPerPixel : 4/1
EXIF.ExposureBiasValue : 0/10
EXIF.MaxApertureValue : 48/16
EXIF.MeteringMode : 2
EXIF.LightSource : 1
EXIF.Flash : 16
EXIF.FocalLength : 63/10
EXIF.MakerNote : SONY DSC
EXIF.FlashPixVersion : 0100
EXIF.ColorSpace : 1
EXIF.ExifImageWidth : 355
EXIF.ExifImageLength : 472
EXIF.InteroperabilityOffset : 840
EXIF.FileSource : 
EXIF.SceneType : 
EXIF.CustomRendered : 0
EXIF.ExposureMode : 0
EXIF.WhiteBalance : 1
EXIF.SceneCaptureType : 0
EXIF.Contrast : 0
EXIF.Saturation : 0
EXIF.Sharpness : 0
EXIF.ImageUniqueID : F61688A21C28432DA09D3F3EAB817326
INTEROP.InterOperabilityIndex : R98
INTEROP.InterOperabilityVersion : 0100



And here is exiftool output, same in both cases, except "Make" field:
ExifTool Version Number         : 11.30
File Name                       : image.jpg
Directory                       : path/to
File Size                       : 201 kB
File Modification Date/Time     : 2020:06:10 19:24:55+02:00
File Access Date/Time           : 2020:06:10 19:24:55+02:00
File Inode Change Date/Time     : 2020:06:10 19:24:55+02:00
File Permissions                : rw-rw-r--
File Type                       : JPEG
File Type Extension             : jpg
MIME Type                       : image/jpeg
JFIF Version                    : 1.01
Exif Byte Order                 : Big-endian (Motorola, MM)
Image Description               :
Make                            : SONY
Camera Model Name               : DSC-W55
Orientation                     : Horizontal (normal)
X Resolution                    : 72
Y Resolution                    : 72
Resolution Unit                 : inches
Software                        : Microsoft Windows Photo Gallery 6.0.6000.16386
Modify Date                     : 2007:09:24 09:58:17
Artist                          : me
Y Cb Cr Positioning             : Co-sited
Exposure Time                   : 1/1250
F Number                        : 7.1
Exposure Program                : Program AE
ISO                             : 1000
Exif Version                    : 0221
Date/Time Original              : 2007:09:23 14:40:11
Create Date                     : 2007:09:23 14:40:11
Components Configuration        : Y, Cb, Cr, -
Compressed Bits Per Pixel       : 4
Exposure Compensation           : 0
Max Aperture Value              : 2.8
Metering Mode                   : Center-weighted average
Light Source                    : Daylight
Flash                           : Off, Did not fire
Focal Length                    : 6.3 mm
Warning                         : Bad MakerNotes directory
Flashpix Version                : 0100
Color Space                     : sRGB
Exif Image Width                : 355
Exif Image Height               : 472
Interoperability Index          : R98 - DCF basic file (sRGB)
Interoperability Version        : 0100
File Source                     : Digital Camera
Scene Type                      : Directly photographed
Custom Rendered                 : Normal
Exposure Mode                   : Auto
White Balance                   : Manual
Scene Capture Type              : Standard
Contrast                        : Normal
Saturation                      : Normal
Sharpness                       : Normal
Image Unique ID                 : F61688A21C28432DA09D3F3EAB817326
PrintIM Version                 : 0300
Compression                     : JPEG (old-style)
Thumbnail Offset                : 994
Thumbnail Length                : 20889
XMP Toolkit                     : Image::ExifTool 11.30
Subject                         : Any
Author                          : me
Current IPTC Digest             : 18fba6c4c9682eba9fc2a18ff1fafe29
Coded Character Set             : UTF8
Application Record Version      : 4
Keywords                        : Any
Image Width                     : 355
Image Height                    : 472
Encoding Process                : Baseline DCT, Huffman coding
Bits Per Sample                 : 8
Color Components                : 3
Y Cb Cr Sub Sampling            : YCbCr4:2:0 (2 2)
Aperture                        : 7.1
Image Size                      : 355x472
Megapixels                      : 0.168
Shutter Speed                   : 1/1250
Thumbnail Image                 : (Binary data 20889 bytes, use -b option to extract)
Focal Length                    : 6.3 mm
Light Value                     : 12.6


Phil Harvey

OK.  I agree.  This looks like some weird bug in the PHP code.

- 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 ($).

7tonin

Here is the associated PHP bug report https://bugs.php.net/bug.php?id=79687

NB: the field which looks stranger to me: IFD0.UndefinedTag:0xC4A5 : PrintIM0300
is well known: 0xc4a5    PrintIM    undef    IFD0    --> PrintIM Tags
(from https://exiftool.org/TagNames/EXIF.html)