Skip to content

Captcha images for higher resolution displays #29

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

thomasbilk
Copy link

Added the posibility to get an image in double size for higher resolution displays. Only works with ttf fonts.

@mbi
Copy link
Owner

mbi commented Feb 27, 2013

Thanks for this. Quick question, what is the use-case of this? Is the same captcha rendered twice, once in single resolution and once in double resolution, and the browser picks the most "fitting", … or will all images be rendered only once in double resolution and scaled down in CSS?

Thanks.

@thomasbilk
Copy link
Author

I am currently working on a mobile page where I use your fabulous app, noticed the low resolution of the captcha image, added this option and thought I could share it.

Currently the low resolution image is loaded and then replaced by the higher resolution image with this javascript code:

if (window.devicePixelRatio >= 1.5) {
  doc.find("img.captcha").each(function() {
    var img = $(this),
        url = this.src;
    img.on("load", function() {
      this.width /= 2;
      this.height /= 2;
    }).prop("src", url + "?retina");      
  });
}

An alternative would be to leave the image source empty, put the url in a data attribute and then let javascript set the correct source. This way only one image is generated and sent over the wire/air.

@mbi
Copy link
Owner

mbi commented Feb 27, 2013

Thanks, I think this makes sense. I'd rather do it via a data-attribute and have a proper "retina" URL, instead of passing a GET parameter.

I'll take a look around to see if there is any standard way of serving high-res images.

@mbi
Copy link
Owner

mbi commented Jun 28, 2013

Sorry for the delay, I'm trying to bake in support for double res images (in 126ca75), this will probably need some more thought…

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.

2 participants