PIL and line drawing

rzed jello at comics.com
Fri May 20 11:59:35 EDT 2005


"Fredrik Lundh" <fredrik at pythonware.com> wrote in
news:mailman.244.1116593366.8733.python-list at python.org: 

> Leonard J. Reder wrote:
> 
>> I am using PIL to annotate some images with lines.  I could not
>> find anyway to make the line that is drawn from the ImageDraw
>> object thicker.  Does anyone have a suggestion or solution for
>> solving this without to much hacking?
> 
> if you have 1.1.5, you can use the width option to control
> the line width. see:
> 

I'm glad to see that addition. I was surprised to see that 'width' 
is actually doubled in the resulting line, though. I suppose the 
code adds and subtracts the specified width from the specified 
coordinate point(?). I'd love to see width added to arc, circles, 
etc., though if it is, I'd much prefer that it not be centered on 
the coordinate point, but added only to the outer edge (or 
subtracted from the inner edge); it would make placement much 
easier, I'd think. 

At the moment, whenever I need to generate thick-lined circles and 
rectangles, I have to create a second image of the desired color, 
then another mask image to contain a black rectangle (say) of the 
required outer size, then within that a white rectangle of the 
inner size, then use that mask to paste the color onto the original 
image. The results are satisfactory, but the method seems clunky at 
best. Maybe there's a better way. Even if this were the exact 
method used, I'd rather see it automated in C than manually done in 
Python.

>     http://effbot.org/imagingbook/imagedraw.htm
> 
>> Thanks for any replies,
> 
> tip: you may get quicker/better responses if you use the
> image-sig mailing list (if you're using a newsreader, point
> it to gmane.comp.python.image)
> 


-- 
rzed



More information about the Python-list mailing list