Skip to content

Captcha images for higher resolution displays#29

Open
thomasbilk wants to merge 1 commit intombi:masterfrom
thomasbilk:master
Open

Captcha images for higher resolution displays#29
thomasbilk wants to merge 1 commit intombi:masterfrom
thomasbilk:master

Conversation

@thomasbilk
Copy link
Copy Markdown

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

@mbi
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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