How to use the exifread.heic.HEICExifFinder function in ExifRead

To help you get started, we’ve selected a few ExifRead examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ianare / exif-py / exifread / __init__.py View on Github external
# by default do not fake an EXIF beginning
    fake_exif = 0

    # determine whether it's a JPEG or TIFF
    data = f.read(12)
    if data[0:2] in [b'II', b'MM']:
        # it's a TIFF file
        logger.debug("TIFF format recognized in data[0:2]")
        f.seek(0)
        endian = f.read(1)
        f.read(1)
        offset = 0
    elif data[4:12] == b'ftypheic':
        f.seek(0)
        heic = HEICExifFinder (f)
        offset, endian = heic.find_exif()
    elif data[0:2] == b'\xFF\xD8':
        # it's a JPEG file
        logger.debug("JPEG format recognized data[0:2]=0x%X%X", ord_(data[0]), ord_(data[1]))
        base = 2
        logger.debug("data[2]=0x%X data[3]=0x%X data[6:10]=%s",
                     ord_(data[2]), ord_(data[3]), data[6:10])
        while ord_(data[2]) == 0xFF and data[6:10] in (b'JFIF', b'JFXX', b'OLYM', b'Phot'):
            length = ord_(data[4]) * 256 + ord_(data[5])
            logger.debug(" Length offset is %s", length)
            f.read(length - 8)
            # fake an EXIF beginning of file
            # I don't think this is used. --gd
            data = b'\xFF\x00' + f.read(10)
            fake_exif = 1
            if base > 2: