exif-py
exif-py copied to clipboard
Error: int too big to convert
I used the code below to add the non-existing gps_img_direction and got a stacktace. The image concerned is attached.
from exif import Image
image = Image("i.jpg")
image.set('gps_img_direction', 0)
Traceback (most recent call last):
File "C:\Python311\Lib\site-packages\exif\_app1_metadata.py", line 611, in __setattr__
ifd_tag = self.ifd_tags[attribute_id]
KeyError: 17
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Python311\Lib\site-packages\plum\transform.py", line 72, in pack
self.__pack__(value, pieces, None)
File "C:\Python311\Lib\site-packages\plum\int.py", line 174, in __pack__
pieces.append(value.to_bytes(nbytes, byteorder, signed=signed))
OverflowError: int too big to convert
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Python311\Lib\site-packages\plum\transform.py", line 90, in pack_and_dump
self.__pack__(value, pieces, dump.add_record(fmt=self.__format_name__))
File "C:\Python311\Lib\site-packages\plum\int.py", line 180, in __pack__
piece = value.to_bytes(nbytes, byteorder, signed=signed)
OverflowError: int too big to convert
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "<pyshell#7>", line 1, in <module>
image.set('gps_img_direction', 0)
File "C:\Python311\Lib\site-packages\exif\_image.py", line 254, in set
setattr(self, attribute, value)
File "C:\Python311\Lib\site-packages\exif\_image.py", line 116, in __setattr__
setattr(self._segments["APP1"], key.lower(), value)
File "C:\Python311\Lib\site-packages\exif\_app1_metadata.py", line 614, in __setattr__
self._add_tag(key, value)
File "C:\Python311\Lib\site-packages\exif\_app1_metadata.py", line 381, in _add_tag
app1_len += added_bytes
File "C:\Python311\Lib\site-packages\plum\view.py", line 218, in __iadd__
self.set(self.unpack() + other)
File "C:\Python311\Lib\site-packages\plum\view.py", line 187, in set
membytes = fob.pack(value)
File "C:\Python311\Lib\site-packages\plum\transform.py", line 75, in pack
self.pack_and_dump(value)
File "C:\Python311\Lib\site-packages\plum\transform.py", line 92, in pack_and_dump
raise exceptions.PackError(dump=dump, exception=exc) from exc
plum.exceptions.PackError:
+--------+-------+-------+--------+
| Offset | Value | Bytes | Format |
+--------+-------+-------+--------+
| | 65555 | | uint16 |
+--------+-------+-------+--------+
OverflowError occurred during pack operation:
int too big to convert