示例#1
0
    def __init__(self, data=b'', contentType='', filename=None):
        super(NamedBlobImage, self).__init__(data,
                                             contentType=contentType,
                                             filename=filename)

        # Allow override of the image sniffer
        if contentType:
            self.contentType = contentType
        exif_data = get_exif(self.data)
        if exif_data is not None:
            log.debug('Image contains Exif Informations. '
                      'Test for Image Orientation and Rotate if necessary.'
                      'Exif Data: %s', exif_data)
            orientation = exif_data['0th'].get(piexif.ImageIFD.Orientation, 1)
            if 1 < orientation <= 8:
                try:
                    self.data, self._width, self._height, self.exif = \
                        rotate_image(self.data)
                except KeyboardInterrupt:
                    raise
                except Exception:
                    log.warning(
                        'Error rotating image %s based on exif data.',
                        filename, exc_info=1)
            else:
                self.exif = exif_data
示例#2
0
    def __init__(self, data=b'', contentType='', filename=None):
        self.contentType, self._width, self._height = getImageInfo(data)
        self.filename = filename
        self._setData(data)

        # Allow override of the image sniffer
        if contentType:
            self.contentType = contentType

        exif_data = get_exif(data)
        if exif_data is not None:
            log.debug('Image contains Exif Informations. '
                      'Test for Image Orientation and Rotate if necessary.'
                      'Exif Data: %s', exif_data)
            orientation = exif_data['0th'].get(piexif.ImageIFD.Orientation, 1)
            if 1 < orientation <= 8:
                self.data, self._width, self._height, self.exif = rotate_image(
                    self.data)
            self.exif_data = exif_data
示例#3
0
    def __init__(self, data='', contentType='', filename=None):
        super(NamedBlobImage, self).__init__(data,
                                             contentType=contentType,
                                             filename=filename)

        # Allow override of the image sniffer
        if contentType:
            self.contentType = contentType
        exif_data = get_exif(self.data)
        if exif_data is not None:
            log.debug('Image contains Exif Informations. '
                      'Test for Image Orientation and Rotate if necessary.'
                      'Exif Data: %s', exif_data)
            orientation = exif_data['0th'].get(piexif.ImageIFD.Orientation, 1)
            if 1 < orientation <= 8:
                self.data, self._width, self._height, self.exif = rotate_image(
                    self.data)
            else:
                self.exif = exif_data