Image interpolation mode in Chrome/Safari?

☆樱花仙子☆ 提交于 2019-12-03 16:27:08

问题


I need to have an image render with nearest-neighbor resizing and not the bicubic way that is currently used. I currently use the following:

ms-interpolation-mode: nearest-neighbor;
image-rendering: -moz-crisp-edges;

This works in IE and Firefox, but not in Chrome and Safari. Are there any webkit alternatives or any other way to achieve this effect?


回答1:


Edit: It's now possible with image-rendering: -webkit-optimize-contrast;.

https://developer.mozilla.org/en-US/docs/CSS/image-rendering#Examples

This doesn't work in current versions of Chrome, here are some useful links:

  • http://vaughnroyko.com/state-of-nearest-neighbor-interpolation-in-canvas/
  • Image scaling by CSS: is there a webkit alternative for -moz-crisp-edges?

I didn't think there was a way.

And some quick Googling all but confirms it; the top Google result for webkit image interpolation is:

http://code.google.com/p/chromium/issues/detail?id=1502

Reported in September 2008, and still not resolved.

Also: https://bugs.webkit.org/show_bug.cgi?id=40881


If I needed this, I'd probably write a PHP script to dynamically scale images up using nearest neighbour.

This will work in every browser, but then you have all that extra processing and transfer overhead.




回答2:


I've just tried this:

img {image-rendering: pixelated;}

And it works great on Chrome 39.0.2145.4 dev-m



来源:https://stackoverflow.com/questions/5403955/image-interpolation-mode-in-chrome-safari

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!