[reportlab-users] Patch for inclusion of CMYK images as CMYK, not converted to RGB

Stevens, Ian IStevens at globeandmail.com
Tue Feb 3 13:16:05 EST 2009


Thanks for including the patch. There's a typo, though:

===================================================================
--- src/reportlab/pdfgen/pdfimages.py (revision 3416)
+++ src/reportlab/pdfgen/pdfimages.py (working copy)
@@ -100,11 +100,11 @@
# Use the colorspace in the image
if image.mode == 'CMYK':
myimage = image
- colorspace = 'DeviceCMYK'
+ colorSpace = 'DeviceCMYK'
bpp = 4
else:
myimage = image.convert('RGB')
- colorspace = 'RGB'
+ colorSpace = 'RGB'
bpp = 3
imgwidth, imgheight = myimage.size

I've noticed the reverse color on JPEG images before but since went with
TIFF. I'll see what I can come up with.

Ian.


> -----Original Message-----

> From: reportlab-users-bounces at reportlab.com

> [mailto:reportlab-users-bounces at reportlab.com] On Behalf Of

> Robin Becker

> Sent: February 3, 2009 5:46 AM

> To: Support list for users of Reportlab software

> Subject: Re: [reportlab-users] Patch for inclusion of CMYK

> images as CMYK, not converted to RGB

>

> Stevens, Ian wrote:

> > The following patch to pdfimage includes unconverted CMYK images in

> > the PDF to preserve colours. We have clients who pass their PDFs

> > through a preflight tool before sending it to press and want all

> > content to be CMYK. The patch uses PIL's Image.mode to

> decide whether

> > to convert the image. We've been using this on our

> production servers

> > since 2.1 without problem.

> >

> > Would it be possible to include this in the upcoming release?

> >

>

> Yes, I see no obvious problem here. I think it's more

> sensible to move the bpp setting into the first part of the

> patch though.

>

> We should probably think more about greyscale and other

> common image formats, but not today.

>

> As for CMYK in general we have had patches in the past

> related to CMYK in jpegs.

> I notice in the code where we load a CMYK image from jpeg

> that we set a decode array parameter which seems to reverse

> the sense of the colour values so instead of running 0-1 they

> run 1-0 instead. Anyone clever here know why we have to do

> that. I seem to remember when we started doing these patches

> that the tool (name

> forgotten) which was creating the CMYK images required this

> transform (otherwise all the colours were messed up).

>

> > Thanks,

> > Ian.

>

> --

> Robin Becker

> _______________________________________________

> reportlab-users mailing list

> reportlab-users at reportlab.com

> http://two.pairlist.net/mailman/listinfo/reportlab-users

>



More information about the reportlab-users mailing list