[Image-SIG] Clipped text, still.

Ned Batchelder ned at nedbatchelder.com
Tue Jan 16 13:10:02 CET 2007

OK, here's some code, and some output.  (My emails seem to be 
consistently held for moderation; I apologize for the apparent delays in 

This code (in a Django view function):

    im = Image.new("RGB", (300, 300), '#ffffc0')
    draw = ImageDraw.Draw(im)
    font = ImageFont.truetype('timesbi.ttf', 50)
    draw.text((100, 100), "jigf", font=font, fill='black')
    response = HttpResponse(mimetype='image/png')
    im.save(response, 'PNG')
    return response

produces two different results, attached.  One is with PIL 1.1.5, the 
other with 1.1.6.  1.1.5 produces the text in the proper place, but with 
the bulbs of the j and f wrapped around to the other end of the text.  
1.1.6 doesn't wrap the bulbs, but has clipped the j severely, and has 
mis-positioned the text so as to keep the entire f in the drawing.

Is this not something other people are seeing?


Scott David Daniels wrote:
> Ned Batchelder wrote:
>>>> I tried installing 1.1.6, mostly to see the improvements in clipped 
>>>> text.   PIL 1.1.5 would clip pieces of text ... and wrap those pixels....
>>>> So "joe" might lose part of the bulb of the j and display it below the e.
>>>> But 1.1.6 still clips the bulb.  It no longer transports the lost 
>>>> pixels to the other end of the string....
>  > Scott David Daniels wrote:
>  >> Sounds like you are running into the edge of the writing area,
>  >> but expect PIL to ignore the clipping boundary for letters that
>  >> are partially inside the clipped area.
>> In this case, there is no clipping boundary, and there are plenty of 
>> pixels to accommodate the extremeties of the letters.  The wrapping has 
>> been fixed, but the clipping still occurs.  Is this true or not?
> Well, it sounds to me like you need to provide code, not simply
> describe what might be going on.  There's no reason to debug a
> description if you can make a simple small example (and that
> example will be needed for a regression test in any case).
> -- Scott David Daniels
> Scott.Daniels at Acm.Org
> _______________________________________________
> Image-SIG maillist  -  Image-SIG at python.org
> http://mail.python.org/mailman/listinfo/image-sig

Ned Batchelder, http://nedbatchelder.com

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/image-sig/attachments/20070116/ed6c3a28/attachment-0001.htm 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: jigf_116.png
Type: image/png
Size: 6947 bytes
Desc: not available
Url : http://mail.python.org/pipermail/image-sig/attachments/20070116/ed6c3a28/attachment-0002.png 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: jigf_115.png
Type: image/png
Size: 7270 bytes
Desc: not available
Url : http://mail.python.org/pipermail/image-sig/attachments/20070116/ed6c3a28/attachment-0003.png 

More information about the Image-SIG mailing list