[Image-SIG] CAPTCHA antibot

Douglas Bagnall douglas at paradise.net.nz
Tue May 10 06:07:36 CEST 2005

Lorenzo Bolognini wrote:

> from PIL import Image, ImageDraw, ImageFont
> im = Image.new("RGB", (150,70), "#fff")
> draw = ImageDraw.Draw(im, "RGB")
> font = ImageFont.truetype("trebuc.ttf", 30)
> draw.text((20,20), "Hello World!", fill="#ff0000", font=font)
> im.save("C:\\pippo.png", "PNG")

> So the question is: how do I create a deform object?

ImageOps.deform is precisely this:

def deform(image, deformer, resample=Image.BILINEAR):
     "Deform image using the given deformer"
     return image.transform(
         image.size, Image.MESH, deformer.getmesh(image), resample

so a deformer object is something with a getmesh method that returns a
deformation mesh in response to an image.  Your deformer object could do
  something like find the pixel length of the word and return the
appropriate filter.  But you probably don't need that.  A simple quad
filter might be enough:

# corner co-ordinates, anticlockwise from top left
corners = (15,15, 18,60, 140,50, 130,10)
im.transform(im.size, Image.QUAD, corners,

> Trying to achieve something like this:
> http://www.google.com/accounts/

I think you mean https://www.google.com/accounts/NewAccount


More information about the Image-SIG mailing list