How to use the exifread.classes.IfdTag 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 / classes.py View on Github external
"""
        for i in range(1, len(value)):
            tag = mn_tags.get(i, ('Unknown', ))
            name = tag[0]
            if len(tag) > 1:
                val = tag[1].get(value[i], 'Unknown')
            else:
                val = value[i]
            try:
                logger.debug(" %s %s %s", i, name, hex(value[i]))
            except TypeError:
                logger.debug(" %s %s %s", i, name, value[i])

            # it's not a real IFD Tag but we fake one to make everybody
            # happy. this will have a "proprietary" type
            self.tags['MakerNote ' + name] = IfdTag(str(val), None, 0, None,
                                                    None, None)
github ianare / exif-py / exifread / classes.py View on Github external
tag_format = tag[1]
            tag_size = struct.calcsize(tag_format)
            if len(camera_info) < offset + tag_size:
                continue
            packed_tag_value = camera_info[offset:offset + tag_size]
            tag_value = struct.unpack(tag_format, packed_tag_value)[0]

            tag_name = tag[0]
            if len(tag) > 2:
                if callable(tag[2]):
                    tag_value = tag[2](tag_value)
                else:
                    tag_value = tag[2].get(tag_value, tag_value)
            logger.debug(" %s %s", tag_name, tag_value)

            self.tags['MakerNote ' + tag_name] = IfdTag(str(tag_value), None,
                                                        0, None, None, None)
github ianare / exif-py / exifread / classes.py View on Github external
# call mapping function
                            printable = tag_entry[1](values)
                        elif type(tag_entry[1]) is tuple:
                            ifd_info = tag_entry[1]
                            try:
                                logger.debug('%s SubIFD at offset %d:', ifd_info[0], values[0])
                                self.dump_ifd(values[0], ifd_info[0], tag_dict=ifd_info[1], stop_tag=stop_tag)
                            except IndexError:
                                logger.warn('No values found for %s SubIFD', ifd_info[0])
                        else:
                            printable = ''
                            for i in values:
                                # use lookup table for this tag
                                printable += tag_entry[1].get(i, repr(i))

                self.tags[ifd_name + ' ' + tag_name] = IfdTag(printable, tag,
                                                              field_type,
                                                              values, field_offset,
                                                              count * type_length)
                try:
                    tag_value = repr(self.tags[ifd_name + ' ' + tag_name])
                # fix for python2's handling of unicode values
                except UnicodeEncodeError:
                    tag_value = unicode(self.tags[ifd_name + ' ' + tag_name])
                logger.debug(' %s: %s', tag_name, tag_value)

            if tag_name == stop_tag:
                break
github ianare / exif-py / exifread / classes.py View on Github external
def parse_xmp(self, xmp_string):
        import xml.dom.minidom

        logger.debug('XMP cleaning data')

        xml = xml.dom.minidom.parseString(xmp_string)
        pretty = xml.toprettyxml()
        cleaned = []
        for line in pretty.splitlines():
            if line.strip():
                cleaned.append(line)
        self.tags['Image ApplicationNotes'] = IfdTag('\n'.join(cleaned), None,
                                                     1, None, None, None)