3

With Google's Chart Image API (which was unfortunately deprecated April 2012), you can generate QR codes.

QR code

I'm sure I can change the size of the resulting image using the API, but I'd rather just use CSS and the width and height properties to make it a little bigger.
In Chrome at least, this results in nasty anti-aliasing (not preferable, since it needs to be parsable by machines). Is there a way to tell browsers not to anti-alias upscaled images?

Protector one
  • 6,926
  • 5
  • 62
  • 86

3 Answers3

5

This guy has the solution: http://nullsleep.tumblr.com/post/16417178705/how-to-disable-image-smoothing-in-modern-web-browsers

img { 
    image-rendering: optimizeSpeed;             /* PREFER SPEED OVER SMOOTHING  */
    image-rendering: -moz-crisp-edges;          /* Firefox                        */
    image-rendering: -o-crisp-edges;            /* Opera                          */
    image-rendering: -webkit-optimize-contrast; /* Chrome (and eventually Safari) */
    image-rendering: optimize-contrast;         /* CSS3 Proposed                  */
    -ms-interpolation-mode: nearest-neighbor;   /* IE8+                           */
  }

Sooo for you:

imgQR { 
    width:100px;
    height:100px;
    image-rendering: optimizeSpeed;             /* PREFER SPEED OVER SMOOTHING  */
    image-rendering: -moz-crisp-edges;          /* Firefox                        */
    image-rendering: -o-crisp-edges;            /* Opera                          */
    image-rendering: -webkit-optimize-contrast; /* Chrome (and eventually Safari) */
    image-rendering: optimize-contrast;         /* CSS3 Proposed                  */
    -ms-interpolation-mode: nearest-neighbor;   /* IE8+                           */
  }
scooterlord
  • 15,124
  • 11
  • 49
  • 68
Brian
  • 494
  • 6
  • 8
0

What you may be looking for is here:

https://developer.mozilla.org/en/css/image-rendering

For example, in Firefox, when adjusting the width and height, also add in

img{
width:100px;
height:100px;
 image-rendering: optimizeQuality;
}

However this does not seem to be supported in Chrome as of yet.

Amaerth
  • 178
  • 2
  • 13
  • I think you actually mean the crisp rendering properties. Unfortunately, those aren't widely supported. – Nathanael Jun 28 '12 at 17:28
  • Yes, you are correct. The quality may be improved, but I suppose that this solution won't resolve the anti-aliasing. – Amaerth Jun 28 '12 at 17:30
0

Try image-rendering: -webkit-optimize-contrast;. This works in Chrome (v23.0.1271.95) for me.

ErJab
  • 6,056
  • 10
  • 42
  • 54