Ejemplo n.º 1
0
 def get_image_data(self, quality=90):
     if not self.is_modified:
         return self.original_image_data
     fmt = self.original_image_format or 'JPEG'
     if fmt.lower() not in set(map(lambda x:bytes(x).decode('ascii'), QImageWriter.supportedImageFormats())):
         return qimage_to_magick(self.current_image).export(fmt)
     return pixmap_to_data(self.current_image, format=fmt, quality=90)
Ejemplo n.º 2
0
 def get_image_data(self, quality=90):
     if not self.is_modified:
         return self.original_image_data
     fmt = self.original_image_format or 'JPEG'
     if fmt.lower() not in set(
             map(lambda x: bytes(x).decode('ascii'),
                 QImageWriter.supportedImageFormats())):
         return qimage_to_magick(self.current_image).export(fmt)
     return pixmap_to_data(self.current_image, format=fmt, quality=90)
Ejemplo n.º 3
0
 def get_image_data(self, quality=90):
     if not self.is_modified:
         return self.original_image_data
     fmt = self.original_image_format or 'JPEG'
     if fmt.lower() not in set(map(lambda x:bytes(x).decode('ascii'), QImageWriter.supportedImageFormats())):
         if fmt.lower() == 'gif':
             data = image_to_data(self.current_image, fmt='PNG', png_compression_level=0)
             from PIL import Image
             i = Image.open(BytesIO(data))
             buf = BytesIO()
             i.save(buf, 'gif')
             return buf.getvalue()
         else:
             raise ValueError('Cannot save %s format images' % fmt)
     return pixmap_to_data(self.current_image, format=fmt, quality=90)