[reportlab-users] Non-JPEG CMYK images
IStevens at globeandmail.com
Mon Feb 25 18:10:55 EST 2008
In addition to complaining about RGB text, our printer is complaining
about RGB images. The thing is, these are TIFF images which are
actually CMYK. Reportlab is converting them to RGB in
reportlab.pdfgen.pdfimages.PDFImage.PIL_imagedata(). I couldn't find a
way to stop this, but I came across an old discussion at
ml. The CMYK support for JPEG images has long since been completed, but
is obviously incomplete for PIL images, which are just converted to RGB.
I probably don't have a full grasp of the implications of CMYK support
for PIL images, but would it make sense to treat them as JPEG images are
currently treated? (ie. use the colorspace within the image itself) I
made a naive change to the code and it seems to have fixed the PDF
colorspace for our CMYK images. (ie. they are now as CMYK in the PDF,
What follows is the patch I'm using. I don't know exactly what PIL
image modes of '1', 'L', 'RGBX' or 'RGBA' mean in this context, so those
modes get converted to 'RGB':
< myimage = image.convert('RGB')
> # Use the colorspace in the image
> mode = image.mode
> if mode == 'CMYK':
> myimage = image
> colorSpace = 'DeviceCMYK'
> myimage = image.convert('RGB')
> colorSpace = 'RGB'
< imagedata=['BI /W %d /H %d /BPC 8 /CS /RGB /F [/A85 /Fl] ID' %
> imagedata=['BI /W %d /H %d /BPC 8 /CS /%s /F [/A85 /Fl] ID' %
(imgwidth, imgheight, colorSpace)]
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the reportlab-users