pel / pel

PHP Exif Library - library for reading and writing Exif headers in JPEG and TIFF files using PHP.

Home Page:https://github.com/pel/pel

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

DateTimeOriginal/DateTimeDigitized loss in re-processed images

alextram opened this issue · comments

I am using Pel for moving EXIF data from original files to GD-processed. And I've found the following problem. When I load files already processed by my script (GD+Pel), or even only by Photoshop "Save for Web" function, the DateTimeOriginal and DateTimeDigitized fields are not recognized by Pel (getEntry returns null). But results returned by exif_read_data show these fields correctly.

In other words, Pel does not recognize some data written to the file by itself...

Here are two images with this problem:
images.zip

wrote a file and then re-read it using exif_read_data and getting the following warnings the last 2 correspond to the problem you have

exif_read_data(14.jpg): Process tag(x0132=DateTime   ): Illegal format code 0x0000, suppose BYTE

exif_read_data(14.jpg): Process tag(x9003=DateTimeOri): Illegal format code 0x0000, suppose BYTE

exif_read_data(14.jpg): Process tag(x9004=DateTimeDig): Illegal format code 0x0000, suppose BYTE

I had the same issue! After using the Pel on an image, all the dates in the EXIF are no longer readable by any other software.

Tried to figure out the problem by looking at the images in a hex editor, but no luck.
Finally I tried version 0.9.9, and it WORKS as expected! (The problem is with version 0.9.10)
I suspect this commit 04ecb8a for introducing this problem.

Hey,
I currently have the same issue when reading the exif data with exif_read_data().
When looking into the returned exif data, \u0000 is added to the end of all date times:

"DateTime": "2021:03:08 12:21:17" -> "DateTime": "2021:03:08 12:21:17\u0000"
"DateTimeOriginal": "2021:03:04 17:40:58" -> "DateTimeOriginal": "2021:03:04 17:40:58\u0000"
"DateTimeDigitized": "2021:03:04 17:40:58" -> "DateTimeDigitized": "2021:03:04 17:40:58\u0000"

The Error printed by Pel is the following:

PHP Fatal error:  Uncaught lsolesen\pel\PelIllegalFormatException: Unknown format: 0x0 in I:\-----\vendor\lsolesen\pel\src\PelFormat.php:224
Stack trace:
#0 I:\-----\vendor\lsolesen\pel\src\PelIfd.php(723): lsolesen\pel\PelFormat::getSize(0)
#1 I:\-----\vendor\lsolesen\pel\src\PelIfd.php(649): lsolesen\pel\PelIfd->loadSingleValue(Object(lsolesen\pel\PelDataWindow), 10, 6, 306)
#2 I:\-----\vendor\lsolesen\pel\src\PelTiff.php(159): lsolesen\pel\PelIfd->load(Object(lsolesen\pel\PelDataWindow), 10)
#3 I:\-----\vendor\lsolesen\pel\src\PelExif.php(100): lsolesen\pel\PelTiff->load(Object(lsolesen\pel\PelDataWindow))
#4 I:\-----\vendor\lsolesen\pel\src\PelJpeg.php(216): lsolesen\pel\PelExif->load(Object(lsolesen\pel\PelDataWindow))
#5 I:\-----\vendor\lsolesen\pel\src\PelJpeg.php(292): lsolesen\pel\PelJpeg->load(Object(lsolesen\pel\PelDataWindow))
#6 I:\-----\vendor\lsolesen\pel\src\PelJpeg.php(122): lsolesen\pel\PelJpeg->loadFile('issue/a16198794...')

I am also unable to retrieve DATE_TIME_ORIGINAL using:
getEntry(PelTag::DATE_TIME_ORIGINAL)
on both processed and raw jpgs from camera. I just get null. Using DATE_TIME (without original) gives correct result in non-processed photos, but sometimes results in completely wrong date (not date if image capture) or correct date, but wrong time on processed photos. Tested on several photos captured on Canon EOS 40D and 7D Mark II. I get correct "DateTimeOriginal" using exif_read_data() function.

Please test with latest release 0.9.12

Version 0.9.12 has the same issue.

The DATE_TIME_ORIGINAL is present in the lsolesen\pel\PelIfd Object:

image

But getEntry(PelTag::DATE_TIME_ORIGINAL) returns null.