[Image-SIG] Conversion from RGB to CMYK

Fredrik Lundh fredrik at pythonware.com
Tue Jul 14 16:12:33 CEST 2009


2009/7/14 Andrea Cappelli <a.cappelli at asidev.com>:

> I'm a beginner with Python and I'm using PIL to convert a lot of images
> from RGB colorspace to CMYK in order to insert them in a catalogue to be
> printed by a typography
>
> i use the following piece of code
>
>        handle = PIL.open(filePath).convert("CMYK")
>        ## some stuff
>        handle.save(newFilePath)
>
> Everything seems ok, except than when I see the generated result (i
> produce a pdf using reportlab) with Acrobat Pro the K layer of my images
> is empty.
>
> Every point of color in CMYK has the K value equal to 0. Seems that PIL
> convert RGB to CMY, ignoring the K value. This is true except for black
> images (RGB=0,0,0), that are mapped to (0,0,0,100)

PIL's default conversion does the simplest thing possible; it doesn't
handle color profiles, undercolor removal, etc. that you need to take
into account if you're doing print stuff.   You can use something like
LittleCMS to do a better job (there's a binding included in the
upcoming 1.1.7 release, available from hg.effbot.org and there's at
least two separate Python bindings available as well).

Alternatively, you could embed a color profile in your PDF files and
leave the rest to Acrobat and the printer (I don't know how to do that
with ReportLab, though).

</F>


More information about the Image-SIG mailing list