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

JP Glutting jpglutting at oqua.udl.es
Thu Jan 26 02:34:48 EST 2006


Tim Roberts wrote:

>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.
>
>  
>
Thanks. I ended up just using a much larger image, and it scales down 
well - it just takes up a lot more space in the document. The drawImage 
function maps one point to one pixel by default: "If width and height 
are not given, the "natural" width and height in pixels is used at a 
scale of 1 point to 1 pixel."

Unfortunately, I can't create my own logo, since it is the official logo 
of the university, and I am not handy enough to re-create it, but I will 
try to get a copy in EPS format.

Cheers,
JP

-- 
____________________________________________________

Oficina de Qualitat	 	Tel: 973 703 103			
Universitat de Lleida	   	Fax: 973 702 036	

Pl. Víctor Siurana, 1	
25003 Lleida	
____________________________________________________	



More information about the reportlab-users mailing list