Esempio n. 1
0
    def get_image(self, source):
        blob = Blob()
        blob.update(source.read())
        image = Image(blob)
        orientation = image.orientation()

        if orientation in (OrientationType.UndefinedOrientation,
            OrientationType.TopLeftOrientation):
            pass
        elif orientation == OrientationType.TopRightOrientation:
            image.flop()
        elif orientation == OrientationType.BottomRightOrientation:
            image.rotate(180.)
        elif orientation == OrientationType.BottomLeftOrientation:
            image.flip()
        elif orientation == OrientationType.LeftTopOrientation:
            image.rotate(90.).flip()
        elif orientation == OrientationType.RightTopOrientation:
            image.rotate(90.)
        elif orientation == OrientationType.RightBottomOrientation:
            image.rotate(90.).flop()
        elif orientation == OrientationType.LeftBottomOrientation:
            image.rotate(270.)

        image.orientation(OrientationType.TopLeftOrientation)

        return image
Esempio n. 2
0
 def get_image(self, source):
     try:
         blob = Blob()
         blob.update(source.read())
         img = Image(blob)
     except IOError:
         img = self._missing_image(source)
     return img
Esempio n. 3
0
 def get_image(self, source):
     blob = Blob()
     blob.update(source.read())
     if source.name.lower().endswith('.gif'):
         image = ImageList()
         image.readImages(blob)
         image.coalesceImags()
     else:
         image = Image(blob)
     return image
Esempio n. 4
0
    def applyIcc(self):
        """ Fix icc profiles """
        try:
            self.img.profile('icm')
        except:
            if self.img.colorSpace() == ColorspaceType.CMYKColorspace:
                icc_data = Blob()
                icc_data.update(open(settings['resources_path'] + 'icc/USWebUncoated.icc', 'rb').read())
                self.img.profile('icm', icc_data)

            if self.img.type() == ImageType.GrayscaleType:
                icc_data = Blob()
                icc_data.update(open(settings['resources_path'] + 'icc/sGray.icc', 'rb').read())
                self.img.profile('icm', icc_data)

        self.img.profile('!icm,*', Blob())

        icc_data = Blob()
        icc_data.update(open(settings['resources_path'] + 'icc/sRGB_v2.1bs.icc', 'rb').read())
        self.img.profile('icm', icc_data)
Esempio n. 5
0
 def is_valid_image(self, raw_data):
     blob = Blob()
     blob.update(raw_data)
     im = Image(blob)
     return im.isValid()
Esempio n. 6
0
 def get_image(self, source):
     blob = Blob()
     blob.update(source.read())
     return Image(blob)
Esempio n. 7
0
 def is_valid_image(self, raw_data):
     blob = Blob()
     blob.update(raw_data)
     im = Image(blob)
     return im.isValid()
Esempio n. 8
0
 def get_image(self, source):
     blob = Blob()
     blob.update(source.read())
     return Image(blob)
Esempio n. 9
0
    def __init__(self, image_data: bytes):
#         try:
        blob = Blob()
        blob.update(image_data)
        self.img = pgImage()
        self.img.read(blob)