Size of APP1 incorrectly determined, breaking next section on adding new attributes
Adding further GPS properties to little_endian.jpg
breaks the file. It is still readable by exiftool, but as the quantization table is damaged viewers can't open it any longer.
with open("little_endian.jpg", 'rb') as image_file:
img = Image(image_file)
img.gps_altitude = 1512.563022080633
with open("little_endian_broken.jpg", 'wb') as new_image_file:
new_image_file.write(img.get_file())
The problem is that Image._parse_segments incorrectly determines the end of the section and erroneously counts the DQT Section Marker (FF DB) to the APP1 section.
img._segments["APP1"].get_segment_bytes()[-2:] # => FF DB
This can also be seen by seen directly at the end of the test baseline ADD_SHORT_LE_BASELINE
.
The next adding of an attribute (with external data) to the last IFD of APP1, in this case the GPS, appends the new external data to the APP1 block, destroying the quantization table. I'll prepare a merge request to fix this.
Edited by Patrick