Open hsq125 opened 2 years ago
@hsq125 I checked this file. According to the spec, DateTimeOriginal is a ascii string which must be \0 terminated and the tag length must include the \0 terminator. In your file the length (19) does not include the \0 terminator thus making it a invalid exif structure. Because of that, piexif cuts of the last character.
Other libraries are smart enough to handle this by reading the full length for the field and simply cutting of \0 bytes if necessary.
I encountered various files like this as well, so maybe piexif could implement this smarter handling as well, even though these files are against the spec.
For some image, the following code will truncate the DateTimleOriginal.
will produce
b'2021:08:06 16:10:4'
instead of
b'2021:08:06 16:10:41'
The test image can be downloaded here https://issue-report-resources.s3.eu-central-1.amazonaws.com/piexif/20_BIKE_C_4_002.jpg
Important to be noted that the date is correctly extracted by other tools such as exiftool on Linux.
Octave