How can I draw text with different stroke and fill colors on images with python?

后端 未结 6 577
忘了有多久
忘了有多久 2020-12-09 10:33

How can I draw text with different stroke and fill colors on images with python?

Here is some text with red stroke and gray fill.

6条回答
  •  醉梦人生
    2020-12-09 10:55

    PIL doesn't support this but you can fake it: Render the text four or eight times with the outline color using one pixel offsets:

    x+1,y
    x-1,y
    x  ,y+1
    x  ,y-1 
    

    (four times version)

    x+1,y+1
    x  ,y+1
    x-1,y+1
    
    x+1,y
    x-1,y
    
    x+1,y-1
    x  ,y-1 
    x-1,y-1
    

    (eight times version)

    and then once at x,y with the fill color.

提交回复
热议问题