Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable antialising when scaling images [duplicate]

Possible Duplicate:
How to stretch images with no antialiasing

Is it in any way possible to disable antialiasing when scaling up an image ?

Right now, i get something that looks like this :

What i get

Using the following css code :

#bib {     width: 104px;     height: 104px;     background-image: url(/media/buttonart_back.png);     background-size: 1132px 1360px;     background-repeat: no-repeat; } 

What I would like, is something like this :

What i seek

In short, any CSS flag to disable anti-aliasing from when scaling up images, preserving hard edges.

Any javascript hacks or similar are welcome too.

(Yes, I am aware that php and imagemagick can do this as well, but would prefer a css based solution.)

UPDATE The following have been suggested :

image-rendering: -moz-crisp-edges; image-rendering: -moz-crisp-edges; image-rendering: -o-crisp-edges; image-rendering: -webkit-optimize-contrast; -ms-interpolation-mode: nearest-neighbor; 

But that doesn't seem to work on background images.

like image 436
Nils Munch Avatar asked Dec 28 '12 10:12

Nils Munch


People also ask

How do I resize an image without anti-aliasing?

In the Photoshop resize dialog, just choose Resample image: Nearest Neighbor.

Does anti-aliasing reduce image quality?

Supersample Anti-Aliasing (SSAA)It makes your GPU render games at a higher resolution, and then it down-samples the image. The higher resolution increases the number of pixels, making the image look sharper. But again, the downside is that it requires a high-end and powerful GPU with additional video memory.

How do I turn off anti-aliasing in Photoshop?

That's just how they work in PS. With the shape tool selected, check the tool options and on the left side you will see a dropdown that says Shape . Change that to Pixels and a new checkbox option ( anti-alias ) will appear.


2 Answers

Try this, it's a fix for removing it in all browsers.

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

Sources:

http://nullsleep.tumblr.com/post/16417178705/how-to-disable-image-smoothing-in-modern-web-browsers

http://updates.html5rocks.com/2015/01/pixelated

GitaarLAB

like image 192
Vargr Avatar answered Nov 11 '22 06:11

Vargr


CSS that works in Firefox Only:

img { image-rendering: -moz-crisp-edges; }  

It worked for me (firefox 16.0) enter image description here

like image 35
GajendraSinghParihar Avatar answered Nov 11 '22 07:11

GajendraSinghParihar