[Image-SIG] How to pass an image from python as C/C++ pointer
Tobias Hilbricht
hilbricht at linopus.de
Wed Dec 14 20:35:56 CET 2005
Dear readers of this list,
I am writing a softproof plugin for the open source vector drawing python
application Skencil by Bernhard Herzog, which runs on GNU/Linux and other
Unixes.
This softproof plugin uses the little color management suite (lcms or
littlecms) by Marti Maria to do profile based softproofing and will show the
softproof as an bitmap representation of the vector drawing.
lcms is written in C but provides python handles, and I could perform all
python tests of lcms.
However, I run into a problem passing image files to lcms using python. If I
do a test with the following file softtest.py I get the error message:
File "/home/tobias/Skencil-CMYK/testbed/softtest.py", line 15, in -toplevel-
cmsDoTransform(hTransform, im, imagesave, 500990)
TypeError: argument number 2: a 'C/C++ pointer' is expected,
'instance(<PpmImagePlugin.PpmImageFile instance at 0x40a7ba4c>)' is received
--------------------------------------------------------------------------
# softtest.py -- test softproofing with lcms
from lcms import *
import Image, ImageTk
im = Image.open('farbtest.ppm')
imagesave = im.save('farbtest-proof.ppm', 'ppm')
hInput = cmsOpenProfileFromFile("AdobeRGB1998.icc", "r")
hOutput = cmsOpenProfileFromFile("l568d65.icm", "r")
hProof = cmsOpenProfileFromFile("EuroscaleCoated.icc", "r")
hTransform = cmsCreateProofingTransform(hInput, TYPE_BGR_8, hOutput,
TYPE_BGR_8, hProof, INTENT_PERCEPTUAL, INTENT_PERCEPTUAL, 0)
cmsDoTransform(hTransform, im, imagesave, 500990)
cmsDeleteTransform(hTransform)
cmsCloseProfile(hInput)
cmsCloseProfile(hOutput)
cmsCloseProfile(hProof)
------------------------------------------------------------------------
How do I pass an image file as C/C++ pointer from python to lcms?
Thanks for any helpful hints in advance
Yours sincerely
Tobias Hilbricht
--
Dr. Tobias Hilbricht
Linopus Satz und Grafik
www.linopus.de
More information about the Image-SIG
mailing list