Esempio n. 1
0
 def __init__(self, image, filename='', cache=1):
     # convert image to mode 'L' or 'RGB' if necessary
     if image.mode not in ('RGB', 'RGBA', 'L'):
         if image.mode == '1':
             mode = 'L'
         else:
             mode = 'RGB'
         image = image.convert(mode)
     else:
         image.load()
     self.image = image
     ExternalData.__init__(self, filename, cache)
Esempio n. 2
0
    def __init__(self, image, filename = '', cache = 1):
	# convert image to mode 'L' or 'RGB' if necessary
	if image.mode not in ('RGB', 'RGBA', 'L'):
	    if image.mode == '1':
		mode = 'L'
	    else:
		mode = 'RGB'
	    image = image.convert(mode)
	else:
	    image.load()
	self.image = image
	ExternalData.__init__(self, filename, cache)
Esempio n. 3
0
 def __init__(self, image, filename="", cache=1):
     # convert image to mode 'L' or 'RGB' if necessary
     if image.mode not in ("RGB", "RGBA", "L"):
         if image.mode == "1":
             mode = "L"
         else:
             mode = "RGB"
         image = image.convert(mode)
     else:
         image.load()
     self.image = image
     ExternalData.__init__(self, filename, cache)
Esempio n. 4
0
    def __init__(self, filename):
        self.info = info = dscparser.parse_eps_file(filename)
        self.filename = filename
        if info.BoundingBox:
            llx, lly, urx, ury = info.BoundingBox
            self.width = Point(urx - llx, 0)
            self.height = Point(0, ury - lly)
            self.start = (llx, lly)
            self.size = (urx - llx, ury - lly)
            self.image = None
            try:
                self.image = render_preview(filename, llx, lly, urx - llx,
                                            ury - lly)
            except IOError:
                pass
        else:
            raise TypeError, '%s has no BoundingBox' % filename

        ExternalData.__init__(self, filename)
Esempio n. 5
0
	def __init__(self, filename):
		self.info = info = dscparser.parse_eps_file(filename)
		self.filename = filename
		if info.BoundingBox:
			llx, lly, urx, ury = info.BoundingBox
			self.width = Point(urx - llx, 0)
			self.height = Point(0, ury - lly)
			self.start = (llx, lly)
			self.size = (urx - llx, ury - lly)
			self.image = None
			try:
				self.image = render_preview(filename, llx, lly,
											urx - llx, ury - lly)
			except IOError:
				pass
		else:
			raise TypeError, '%s has no BoundingBox' % filename

		ExternalData.__init__(self, filename)
Esempio n. 6
0
	def __init__(self, image, filename='', cache=1):
		self.orig_image = image.copy()

		if image.mode == '1':
			self.image_mode = BW_IMAGE
		elif image.mode == 'L':
			self.image_mode = GRAYSCALE_IMAGE
		elif image.mode == 'RGB':
			self.image_mode = RGB_IMAGE
		elif image.mode == 'RGBA':
			self.image_mode = RGBA_IMAGE
		elif image.mode == 'CMYK':
			self.image_mode = CMYK_IMAGE
			colormanager.add_to_image_pool(self)
			self.cached = 1
		else:
			self.image_mode = UNSUPPORTED

		if image.mode not in ('RGB', 'RGBA'):
			image.load()
			if image.mode == 'CMYK':
				if app.config.preferences.use_cms_for_bitmap:
					self.image = colormanager.ImageCMYKtoRGB(image)
				else:
					self.image = image.convert('RGB')
			else:
				self.image = image.convert('RGB')
		else:
			image.load()
			self.image = image

		if self.image_mode == UNSUPPORTED:
			self.orig_image = self.image.copy()
			self.image_mode = RGB_IMAGE

		ExternalData.__init__(self, filename, cache)
Esempio n. 7
0
    def __init__(self, image, filename='', cache=1):
        self.orig_image = image.copy()

        if image.mode == '1':
            self.image_mode = BW_IMAGE
        elif image.mode == 'L':
            self.image_mode = GRAYSCALE_IMAGE
        elif image.mode == 'RGB':
            self.image_mode = RGB_IMAGE
        elif image.mode == 'RGBA':
            self.image_mode = RGBA_IMAGE
        elif image.mode == 'CMYK':
            self.image_mode = CMYK_IMAGE
            colormanager.add_to_image_pool(self)
            self.cached = 1
        else:
            self.image_mode = UNSUPPORTED

        if image.mode not in ('RGB', 'RGBA'):
            image.load()
            if image.mode == 'CMYK':
                if app.config.preferences.use_cms_for_bitmap:
                    self.image = colormanager.ImageCMYKtoRGB(image)
                else:
                    self.image = image.convert('RGB')
            else:
                self.image = image.convert('RGB')
        else:
            image.load()
            self.image = image

        if self.image_mode == UNSUPPORTED:
            self.orig_image = self.image.copy()
            self.image_mode = RGB_IMAGE

        ExternalData.__init__(self, filename, cache)