-
-
Notifications
You must be signed in to change notification settings - Fork 852
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
Possible invalid/missing EXIF IFD end directory link #1921
Comments
Yeah this seems ambiguous and the expected result, to me, unexpected. IFDs are specific to TIFF files. @IldarKhayrutdinov @brianpopow @dlemstra would any of you be able to confirm? |
Yeah and the EXIF is written as a TIFF chunk if I read things properly; so should adhere to the same layout and specification I think. |
Indeed, at the end of exif are write 2 bytes
According to the Exif specification, next IFD offset size is 4 bytes. PR: #1923 |
@IldarKhayrutdinov Thanks very much for confirming!! |
Prerequisites
DEBUG
andRELEASE
modeDescription
The IFD does not contain the final 4 byte 0 after the last directory which makes it hard to determine if there are any other linked directories or not.
From the TIFF specification (https://www.itu.int/itudoc/itu-t/com16/tiff-fx/docs/tiff6.pdf):
(the emphasis on the final sentence in brackets is mine).
Steps to Reproduce
Binary dump of above shows the beginning of the EXIF/TIFF chunk (showing the byte order marker bytes) which is where the data offsets will start from (
30
:Below shows the first offset (which is always 8 from the start offset):
Then we start the 12 byte data chunks for each bit of metadata from offset
38
; the first 2 bytes shows the directory count:Next 10 bytes is the component size, count and the last 4 bytes will be the offset where the actual data lives which is
1A
or 26 + 30 start offset = 56:Actual data in UCS2 (double-byte) encoding:
After the 12 byte chunk we should get a 4 byte marker to next IFD or 4 bytes of 0 to show no more IFDs exist; here we get
2E
:But the 4 bytes at offset
2E
(46 + 30 = 76) is not the start of a new IFD its 2 byte null and then a 2 byte JPEG marker FFDB for a quantization table:This looks to me to be a bit of a bug; the 4 bytes at offset 50 should be 4 x
0
s.But I may be incorrect; there does seem to be a bit of ambiguity amongst the various specs I have read where in some places the 12 byte chunks + 4 byte
next IFD
reference is fixed and always applicable (as in the TIFF spec above), and sometimes it seems to imply that perhaps it is only applicable toIF0
IFDs.Using metadata2go to edit and re-save the metadata, you can see that after the 12 byte chunk it writes out 4 byte 0 for the end of IFD which is what I was expecting:
Image saved by ImageSharp:
Image fixed by metadata2go:
System Configuration
The text was updated successfully, but these errors were encountered: