Oddities creating Exif Profile #1240
-
I have an issue with handling ExifProfiles, where adding a profile to a JPEG image and then reading it Using The app targets .NET Framework 4.8.2 and is built with Visual Studio 2022 Community 17.3.2 I start with a tiny JPEG from Photoshop (created from new, saved with "Export As" with "Save metadata" unchecked).
Then I create an Exif profile with this code:
Using exifProfile.ToByteArray() to get it as a byte array I get:
I read this as:
(I'm not sure what the final 4 null bytes are??) The exifProfile.Values property gives me one "ImageDescription" value as I expect; the exifProfile.InvalidTags Now I open the starting image file, set the Exif profile into it and save it:
Here's how the resulting file starts:
Last step is to open the resulting file again, extract the Exif profile and examine it:
I'm expecting to get exactly the Exif profile that I added. The result from exifProfile.ToByteArray() is:
which is identical to what I created, and the exifProfile.Values property again gives But now the exifProfile.InvalidTags property contains one value 42 (x2A) So it looks as if the ExifProfile object I get reading from the file will give me a correct The ExifProfile object created directly gives a correct analysis of the contents. The x2A value for the invalid tag is interesting: The only occurrence of that byte value in the file is [Attached files are the starting image with no Exif profile, and the file after I added one] All advice gratefuly received Thanks |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
This does look like a bug and thanks for providing so much information. It made it much easier to investigate what is happening. Those last 4 bytes is for the offset of the thumbnail image and because this profile has no thumbnail this is zero. But when the profile is read it tries to read the thumbnail from offset zero and that fails. This will be fixed in the next release. |
Beta Was this translation helpful? Give feedback.
This does look like a bug and thanks for providing so much information. It made it much easier to investigate what is happening. Those last 4 bytes is for the offset of the thumbnail image and because this profile has no thumbnail this is zero. But when the profile is read it tries to read the thumbnail from offset zero and that fails. This will be fixed in the next release.