TNThieding / exif

Read and modify image EXIF metadata using Python.
https://gitlab.com/TNThieding/exif
MIT License
52 stars 7 forks source link

AssertionError #19

Open Matiz7 opened 5 years ago

Matiz7 commented 5 years ago

with open(photo_path, 'rb') as image_file: ... my_image = Image(image_file) ... dir(my_image) ... Traceback (most recent call last): File "", line 2, in File "F:\Python37\lib\site-packages\exif_image.py", line 53, in init self._parse_segments(img_hex) File "F:\Python37\lib\site-packages\exif_image.py", line 41, in _parse_segments self._segments['APP1'] = App1MetaData(img_hex[app1_start_index:cursor]) File "F:\Python37\lib\site-packages\exif_app1_metadata.py", line 184, in init self._unpack_ifd_tags() File "F:\Python37\lib\site-packages\exif_app1_metadata.py", line 82, in _unpack_ifd_tags self._segment_hex.set_endianness(self._segment_hex.read(cursor, 2)) File "F:\Python37\lib\site-packages\exif_hex_interface.py", line 112, in set_endianness assert endian_constant in [EXIF_BIG_ENDIAN_HEADER, EXIF_LITTLE_ENDIAN_HEADER] AssertionError

paulkernstock commented 5 years ago

I see the same error upon creating an instance of Image of an .MP4 file.

Traceback (most recent call last):
  File "/Users/Paul/pyzel/pyzel.py", line 15, in <module>
    image = Image(img_file)
  File "/Users/Paul/Library/Caches/pypoetry/virtualenvs/pyzel-py3.7/lib/python3.7/site-packages/exif/_image.py", line 53, in __init__
    self._parse_segments(img_hex)
  File "/Users/Paul/Library/Caches/pypoetry/virtualenvs/pyzel-py3.7/lib/python3.7/site-packages/exif/_image.py", line 41, in _parse_segments
    self._segments['APP1'] = App1MetaData(img_hex[app1_start_index:cursor])
  File "/Users/Paul/Library/Caches/pypoetry/virtualenvs/pyzel-py3.7/lib/python3.7/site-packages/exif/_app1_metadata.py", line 184, in __init__
    self._unpack_ifd_tags()
  File "/Users/Paul/Library/Caches/pypoetry/virtualenvs/pyzel-py3.7/lib/python3.7/site-packages/exif/_app1_metadata.py", line 82, in _unpack_ifd_tags
    self._segment_hex.set_endianness(self._segment_hex.read(cursor, 2))
  File "/Users/Paul/Library/Caches/pypoetry/virtualenvs/pyzel-py3.7/lib/python3.7/site-packages/exif/_hex_interface.py", line 112, in set_endianness
    assert endian_constant in [EXIF_BIG_ENDIAN_HEADER, EXIF_LITTLE_ENDIAN_HEADER]
AssertionError
the-vishal commented 5 years ago

This is due to file formats of Image files you may be using. EXIF (Exchangeable Image File Format) is typically stored in JPG/JPEG formats. try changing the format to either of them it will surely work.