[reportlab-users] Standard graphics: (85w x 32h pixels)
Sat, 4 Jan 2003 12:11:10 +0100
> That needs some explanation.
> The code Robin posted was generated by our visual drawing editor,
> which is currently commercial code, and which needs some extra
> hooks in the drawing. It should nevertheless be runnable.
> What matters is the property assignments.
> However, our logo has a default size of 130x86 so you may need
> to place it within a larger rectangle or it will look kind of
Right, and as the editor won't let you do this "magically" (I believe)
you have to write that code yourself anyway! So what one really wants
is something more like the code below.
from reportlab.lib.corp import RL_CorpLogo
from reportlab.graphics.shapes import Drawing, Rect
"A drawing for making RL logo icons of specific sizes for web
# Exercise: add customizable strings like "powered by" etc.!
def __init__(self, width=400, height=200, *args, **kw):
apply(Drawing.__init__, (self, width, height) + args, kw)
self.width = width
self.height = height
frameRatio = (0.0 + width) / height
# create ReportLab vector logo
logo = RL_CorpLogo()
logoRatio = (0.0 + logo.width) / logo.height
# add a background, reusing logo background color
rect = Rect(0, 0, width, height,
# center logo with appropriate ratio in desired frame
if logoRatio < frameRatio:
logo.width = self.width/frameRatio*logoRatio
logo.height = self.height
logo.x = (self.width-logo.width)/2.0
logo.width = self.width
logo.height = self.height/logoRatio*frameRatio
logo.y = (self.height-logo.height)/2.0
# add logo
RL_WebIcon(85, 32).save(formats=['png'], outDir='.',
Dinu C. Gherman
Make your own Bush speech: http://www.lemonbovril.co.uk/bushspeech