Open CampbellMG opened 5 years ago
Thank you so much! I'm shrinking images clientside and needed to clone the EXIF data to the shrunk image, this bug was causing PHP issues and not allowing me to read the GPS data. This fixed my issue, I know its not a perfect solution but thank you so much!
What should be happening:
As per the TIFF documentation, each IFD should end with:
OFFSET - Count TYPE - Description
0002h + "NUM"*12 - 1 dword - Offset of next IFD in file, 0 if none follow
The key part here is the 0 if none follow.
What is actually happening:
Piexifjs is not writing this value at all meaning several EXIF parsers (such as PHP's Pel library) will attempt to read the "four bytes over" information as an offset for the next IFD.
To reproduce the issue:
Alternatively, you can compare the raw binary before and after parsing the image with piexifjs and you will notice it strips out the
00 00 00 00
that separates the entries (key, type, length & value) from the overflow values (greater than 4 bytes).I have implemented a temporary fix with the following:
However, this adds two trailing zeros after the 0th IFD as the library seems to be including this value only on the first.
I am very new to TIFF and EXIF standards so take all of this with a grain of salt. Is there a more permanent solution to this issue?