Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for Pillow 2.1.0 and above #50

Merged
merged 3 commits into from Dec 27, 2013
Merged

Fix for Pillow 2.1.0 and above #50

merged 3 commits into from Dec 27, 2013

Conversation

viaregio
Copy link
Contributor

Pillow changed the font rendering (python-pillow/Pillow#285). So I changed the calculation of the text size. Without this fix the text in the captcha is cut off at the bottom with newer Pillow versions.

@mbi
Copy link
Owner

mbi commented Oct 17, 2013

Awesome, thanks. Will this work with pillow < 2.1.0?

@viaregio
Copy link
Contributor Author

I have tested the code with PIL version 1.1.7 and Pillow 2.0.0. There are no cut off letters. With Pillow 2.0.0 you get a little extra whitespace below the letters.

@mktums
Copy link

mktums commented Oct 17, 2013

Please accept PR, and upload new version to PyPI.
Thank you.

@mbi
Copy link
Owner

mbi commented Oct 17, 2013

@viaregio @mktums I'm testing right now, I'm getting cut off letters on Pillow 2.2.1, though.

download

@viaregio
Copy link
Contributor Author

Interesting, my Pillow version is 2.2.1 also, maybe I should have deactivated the noise filter to get a clearer Image.

return [x + y + z for x, y, z in zip(font.getsize(text), font.getoffset(text), (1, 1))]

could fix this ramaining issue.

Still to small?
@mbi
Copy link
Owner

mbi commented Oct 17, 2013

Hmm, still not perfect :(
download 1

Here is how I'm testing by the way:

CAPTCHA_NOISE_FUNCTIONS = []
CAPTCHA_LETTER_ROTATION = (-30, 30)
CAPTCHA_CHALLENGE_FUNCT = lambda: ('LULUAWAWABBXX!', 'aaaa')

@mbi
Copy link
Owner

mbi commented Oct 17, 2013

It's mostly the capital W being annoying

download 3

CAPTCHA_CHALLENGE_FUNCT = lambda: ('WWWWWWWWWWW!', 'aaaa')

@mktums
Copy link

mktums commented Oct 17, 2013

Problem is that size calculates before rotation.

@mbi mbi mentioned this pull request Oct 17, 2013
@mbi
Copy link
Owner

mbi commented Oct 17, 2013

@mktums probably, but that'll work fine in Pillow 2.0 and PIL 1.1.7.

@mktums
Copy link

mktums commented Oct 17, 2013

Well, we can't use old Pillow, so problem is still here.

Image size must be calculated with the distance of the text from the top of the image in mind.
@mktums
Copy link

mktums commented Oct 22, 2013

@viaregio
screen shot 2013-10-22 at 3 04 59 pm

I think it's OK, but doesn't image now seems too big?

@mbi
Copy link
Owner

mbi commented Oct 22, 2013

@mktums @viaregio is that with Pillow 2.0, Pillow 2.2 or PIL?

EDIT: Im OK with some extra white space, more than I'm ok with truncated letters…

@mktums
Copy link

mktums commented Oct 22, 2013

@mbi @viaregio Pillow 2.2.1, will recheck now for fresh installation…

Update: yes, Pillow 2.2.1, clean install, captcha cloned from @viaregio's repo.

@Nihisil
Copy link

Nihisil commented Nov 6, 2013

Hello! How it is going on? When it will be in main branch?

@mbi
Copy link
Owner

mbi commented Nov 6, 2013

We're quite yet ready to merge this as-is.

@asaji
Copy link

asaji commented Nov 15, 2013

For the time being i was able to get it running perfectly fine on Pillow 2.0

pip uninstall Pillow
pip install Pillow==2.0

Live example: http://dermtermsapp.com/register/

@Nihisil
Copy link

Nihisil commented Nov 20, 2013

@asaji captcha doesn't fit with Pillow==2.1+

For Pillow==2.0 all is working very well

@mennanov
Copy link

How soon can we expect that fix merged into master and updated at PyPI?

@mbi mbi merged commit 1a4e917 into mbi:master Dec 27, 2013
@mbi
Copy link
Owner

mbi commented Dec 27, 2013

Merged, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants