hMatoba / Piexif

Exif manipulation with pure python script.
MIT License
367 stars 81 forks source link

Dumping negative ImageIFD.TimeZoneOffset causes struct.error: argument out of range #135

Open davetapley opened 2 years ago

davetapley commented 2 years ago

Per ISO/DIS 12234-2:

Time Zone Offset (in hours) of DateTimeOriginal tag-value relative to Greenwich Mean Time

and:

The allowed values are -12 to +11.

but: https://github.com/hMatoba/Piexif/blob/3422fbe7a12c3ebcc90532d8e1f4e3be32ece80c/piexif/_exif.py#L104

then: https://github.com/hMatoba/Piexif/blob/3422fbe7a12c3ebcc90532d8e1f4e3be32ece80c/piexif/_dump.py#L206-L209

and: https://github.com/hMatoba/Piexif/blob/3422fbe7a12c3ebcc90532d8e1f4e3be32ece80c/piexif/_dump.py#L173-L174

where L is unsigned long, causing ⬇️ for dump with any negative offset.

struct.error: argument out of range
davetapley commented 2 years ago

Fix for this will go in after https://github.com/hMatoba/Piexif/issues/122