[reportlab-users] reportlab and CMYK images, take 2

Oliver Bleutgen reportlab-users@reportlab.com
Thu, 02 Oct 2003 13:14:44 +0200


Ok,

I'll start a new thread here. Andy, I just saw a mail to the list from 
you which forwarded my answer to your mail, but without new content. 
Don't know if this was deliberate.

Robin Becker wrote:
 > .....
 >
 > You're right at present we handle only rgb images via PIL. As I
 > understand it PIL can handle other kinds of things including CMYK and I
 > guess you are right to say that converting to RGB would be wrong for
 > those images.

Well, at least the fact that this conversion is generally done for PIL 
images confused me a little bit. For what I'm wanting to do, I don't 
need PIL at all, I just used it to create a test CMYK image to pass it 
directly into reportlab. When I made a mistake, passed a wrong object, 
and got a traceback about a missing convert method, I got suspicious ;).

 > At present I'm sure we aren't planning an immediate effort to add cmyk
 > images, but for JPEGS I see that we allow for the colorspace to default
 > to 'DeviceCMYK' after testing for 1 or 3 color components.
 >
 > When loading from a bitmap type image I guess we ought to allow for
 > testing the number of image components & masking & etc etc etc sigh :(


Well, for my application I absolutely need to be sure that the images 
that get added to the pdf are not altered (modulo the size in which they 
are rendered). I'm willing to try come up with something here, the 
question is how to do it the best way.

First, a basic question, does it make sense to try to do that in a way 
that the resulting code could be fed back into reportlab? (Not that 
there's a high probability that someone would want that code, lol).  If 
not, I'd try to touch the reportlab code as little as possible.

Now to the technical aspects, from staring at the pdf specification and 
pdfimages.py, it seems that adding a CMYK jpg file is straightforward, 
and nearly done. One thing I stumbled across was an inconsistent use of 
self.colorSpace ( in __init__() and in format() ) vs. colorSpace in 
pg_imagedata(). Seems like a bug, though I don't know if it has 
detrimental effects.

Is it desirable and would it make sense to beef up reportlab's image 
capabilities? Are there any thoughts into what direction one should go 
with this?

cheers,
oliver