[reportlab-users] drawImage makes image roughly twice as big as it should be

Tim Roberts timr at probo.com
Wed Jan 25 12:42:56 EST 2006


On Wed, 25 Jan 2006 10:14:58 +0100 JP Glutting <jpglutting at oqua.udl.es>
wrote:

>I am trying to use drawImage to put a logo on all my reports. It works
>Ok, except that it is making the images larger than they really are, and
>they look lousy. I tried adding width and height specifically to the
>code, but it does not seem to change the output at all.
>
>Any hints? I am not sure where to look for the problem. The code looks
>like this:
>
>def myFirstPage(self, canvas, doc):
>       canvas.saveState()
>       canvas.drawImage("C:\\pybin\\Logo_UdL_w100.jpg", 75, 75,
>width=101, height=83)
>      .... [other stuff]
>
>The original code didn't specify "width" and "height", but produced the
>same result. I also have an image on the header of every other page that
>does the same thing - spells up and gets pixelated. The image has a true
>width and height of 101 x 83 pixels, but prints out at 197 x 144 (based
>on using the select tool in Adobe Reader 7.0.
>


Remember that all measurements in Reportlab are in points.  101 points
is an inch and a half.  The number of pixels depends on the resolution 
of the rendering device.  On a 600-dpi printer, it will be scaled up to
about 900 pixels.

If you really need to use a JPEG logo, you need to start with a
high-resolution file so that it scales well.  For best results, you
might try to create your logo using Reportlab graphics, or as an EPS
file, or some other vector format.

-- 
Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.



More information about the reportlab-users mailing list