Can I turn off smooth scaling of Safari images?

I would like to scale some pixel images in a browser. Since this is a pixel art, it looks awful if the image is smoothed.

In Firefox, I can turn off anti-aliasing using "image-rendering: -moz-crisp-edge".

IE has "-ms-interpolation-mode: closest neighbor" ... anyway it's the default zoom mode.

But I cannot find a way to disable anti-aliasing in Safari for scaled images. Has anyone found a way to do this?

+4
source share
2 answers

Safari / WebKit doesn't seem to have anything equivalent.

See below: https://developer.mozilla.org/en/CSS/image-rendering

+4
source

I understand that this is an old question, but I had the same doubts and appeared when I was looking for an answer, had the same doubt, and I will lay out a solution for anyone in the same situation.

Something like a trick in Safari accesses a canvas whose context has this flag: ctx.webkitImageSmoothingEnabled = false;

For all variations of this flag, see https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/imageSmoothingEnabled

0
source

Source: https://habr.com/ru/post/1306729/


All Articles