Esempio n. 1
0
	def adjust_image(self, img, profilestr):
		"""
		Adjust image with embedded profile to similar colorspace
		defined by current profile.
		profilestr - embedded profile as a python string.
		Returns new image instance.
		"""
		custom_profile = libcms.cms_open_profile_from_string(profilestr)
		cs_in = cs_out = IMAGE_TO_COLOR[img.mode]
		out_profile = self.handles[cs_in]
		intent = self.rgb_intent
		if cs_out == COLOR_CMYK:intent = self.cmyk_intent
		transform = libcms.cms_create_transform(custom_profile, cs_in,
							out_profile, cs_out, intent, self.flags)
		return libcms.cms_do_bitmap_transform(transform, img, cs_in, cs_out)
Esempio n. 2
0
 def adjust_image(self, img, profilestr):
     """
     Adjust image with embedded profile to similar colorspace
     defined by current profile.
     profilestr - embedded profile as a python string.
     Returns new image instance.
     """
     custom_profile = libcms.cms_open_profile_from_string(profilestr)
     cs_in = cs_out = IMAGE_TO_COLOR[img.mode]
     out_profile = self.handles[cs_in]
     intent = self.rgb_intent
     if cs_out == COLOR_CMYK: intent = self.cmyk_intent
     transform = libcms.cms_create_transform(custom_profile, cs_in,
                                             out_profile, cs_out, intent,
                                             self.flags)
     return libcms.cms_do_bitmap_transform(transform, img, cs_in, cs_out)
Esempio n. 3
0
 def get_transform(self, cs_in, cs_out):
     """
     Returns requested color transform using self.transforms dict.
     If requested transform is not initialized yet, creates it.
     """
     tr_type = cs_in + cs_out
     intent = self.rgb_intent
     if cs_out == COLOR_CMYK: intent = self.cmyk_intent
     if not self.transforms.has_key(tr_type):
         handle_in = self.handles[cs_in]
         handle_out = self.handles[cs_out]
         if cs_out == COLOR_DISPLAY: cs_out = COLOR_RGB
         tr = libcms.cms_create_transform(handle_in, cs_in, handle_out,
                                          cs_out, intent, self.flags)
         self.transforms[tr_type] = tr
     return self.transforms[tr_type]
Esempio n. 4
0
	def get_transform(self, cs_in, cs_out):
		"""
		Returns requested color transform using self.transforms dict.
		If requested transform is not initialized yet, creates it.
		"""
		tr_type = cs_in + cs_out
		intent = self.rgb_intent
		if cs_out == COLOR_CMYK:intent = self.cmyk_intent
		if not self.transforms.has_key(tr_type):
			handle_in = self.handles[cs_in]
			handle_out = self.handles[cs_out]
			if cs_out == COLOR_DISPLAY: cs_out = COLOR_RGB
			tr = libcms.cms_create_transform(handle_in, cs_in,
										handle_out, cs_out,
										intent, self.flags)
			self.transforms[tr_type] = tr
		return self.transforms[tr_type]