Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python CAPTCHA-like image disortion

I would like to disort some images the same way standard CAPTCHA disorts fonts. How would I achieve it in python? What libraries/algorithms I should use? Any proof-of-concept?

DISCLAIMER: I was googling for some time before I asked this question but I couldn't find any satisfying answer. I'm new to the field so I can't provide any code proving my 'research effort'...

like image 753
mnowotka Avatar asked Mar 10 '26 18:03

mnowotka


1 Answers

I think you are looking for PyCaptcha http://svn.navi.cx/misc/trunk/pycaptcha/

The actual code to distort is here: http://svn.navi.cx/misc/trunk/pycaptcha/Captcha/Visual/Distortions.py

The work is done by PIL's transform function, like this:

image.transform(image.size, Image.MESH, mesh, self.filtering)

The rest of the code is there essentially to generate the mesh that is used.

like image 131
Alex I Avatar answered Mar 13 '26 15:03

Alex I



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!