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
def get_image(self, source): try: blob = Blob() blob.update(source.read()) img = Image(blob) except IOError: img = self._missing_image(source) return img
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
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)
def is_valid_image(self, raw_data): blob = Blob() blob.update(raw_data) im = Image(blob) return im.isValid()
def get_image(self, source): blob = Blob() blob.update(source.read()) return Image(blob)
def __init__(self, image_data: bytes): # try: blob = Blob() blob.update(image_data) self.img = pgImage() self.img.read(blob)