AW: [reportlab-users] cmyk-images

manuela kiesenhofer - next gmbh m.kiesenhofer at
Fri Apr 8 04:59:06 EDT 2005

> manuela kiesenhofer wrote:
>> hi,
>> my name is manuela kiesenhofer
>> and I am working in an internet agenency in linz, austria.
>> I've tested the reportlab opensource libary
>> and I think it's really great!!
>> the only problem is that it seems that the libary doesn't support
>> the usage of cmyk-jpgs or cmyk-tifs.
>> however, has anybody of you found a way to insert cmyk-images
>> into a pdf generated by reportlab?
>> cu, manu

>Heile Manuela, this may be my fault as I programmed the image inclusion
>stuff. JPEG is supposed to be a native format for PDF. Looking at the
>code I see

>	if info[2] == 1:
>		self.colorSpace = 'DeviceGray'
>	elif info[2] == 3:
>		self.colorSpace = 'DeviceRGB'
>	else: #maybe should generate an error, is this right for CMYK?
>		self.colorSpace = 'DeviceCMYK'

> so we are attempting to do CMYK provided this path is followed. The
> filename needs to have an extension .jpeg or .jpg for this to work.

> So 1) are you working from a recent source, 2) are you loading via a
> filename?

> If not send me a snippet of code and a sample jpeg and I'll attempt to
> figure out what's wrong.
> --
> Robin Becker

hi robin,

thanks for addressing my problem.

1. I'm working with width verion 1.20 (
2. I try to load the image by filename in two ways, here is my code example:


from reportlab.pdfgen import canvas
from reportlab.platypus import Image
from reportlab.lib.units import cm

# set pdf-filename
canvas = canvas.Canvas("cmyk_test.pdf", bottomup=1)

# fill pdf

# logo
# try one way
canvas.drawImage('data/meiseleder_balken_cmyk.jpg', x=0*cm,y=27*cm,
width=6*cm, height=1.5*cm)

# try another way
IMG = Image('data/meiseleder_balken_cmyk.jpg', width=6*cm, height=1.5*cm)
w,h = IMG.wrap(6*cm, 1.5*cm)
IMG.drawOn(canvas,0*cm, 25*cm)

# done


Unfortunately both jpgs are displayed in the pdf as black box.

cu, manu

More information about the reportlab-users mailing list