ianare / exif-py

Easy to use Python module to extract Exif metadata from digital image files.
BSD 3-Clause "New" or "Revised" License
831 stars 191 forks source link

KeyError 'E' in process_file #188

Open krzysieqq opened 11 months ago

krzysieqq commented 11 months ago

When I tried to parse the below image, I got KeyError 'E' from the line logger.debug("Endian format is %s (%s)", endian, {. I've processed the image by running exifread.process_file(image, details=False, stop_tag="DateTimeOriginal") command.

/usr/local/lib/python3.8/site-packages/exifread/__init__.py, line 147, in process_file
        return {}
    except InvalidExif as err:
        logger.debug(err)
        return {}
    endian = chr(ord_(endian[0]))
    # deal with the EXIF info we found
    logger.debug("Endian format is %s (%s)", endian, { …
        'I': 'Intel',
        'M': 'Motorola',
        '\x01': 'Adobe Ducky',
        'd': 'XMP/Adobe unknown'
    }[endian])

3

rascalking commented 5 months ago

@krzysieqq I think github image processing mangled whatever in your original image was triggering this (I couldn't provoke the crash with a download of it, in any case). I don't suppose you have the original hosted somewhere else? I put in a PR, but the image I used for testing (which was a webp) I don't have rights to, and the samples repo (https://github.com/ianare/exif-samples) requires all images uploaded to be CC-licensed.