最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Is it possible to pixelate an image without canvas? - Stack Overflow

programmeradmin0浏览0评论

Given an <img> element, is it possible to pixelate the image using only CSS and/or not use canvas? I've seen things like the crisp edges feature (but that's just for images that are scaled) and a lot of canvas options, but I'm hoping for a better way.

Given an <img> element, is it possible to pixelate the image using only CSS and/or not use canvas? I've seen things like the crisp edges feature (but that's just for images that are scaled) and a lot of canvas options, but I'm hoping for a better way.

Share Improve this question asked Feb 3, 2016 at 16:46 CassidyCassidy 3,4085 gold badges41 silver badges80 bronze badges 3
  • 2 This doesn't seem like a request for a resource. It's asking about CSS techniques. – isherwood Commented Feb 3, 2016 at 16:47
  • 4 The question is perfectly valid. image-rendering: pixelated; developer.mozilla.org/en/docs/Web/CSS/image-rendering – Pogrindis Commented Feb 3, 2016 at 16:49
  • 1 It may be possible using CSS filters: developer.mozilla.org/en-US/docs/Web/CSS/filter Unfortunately there's no built-in pixelate filter but you can specify a custom filter with the url function which can pull a filter from an svg element. Inside your svg you can use a bunch of different filter effects (see the fe* elements at developer.mozilla.org/en-US/docs/Web/SVG/Element). Some combination of those filter effects might produce a pixelation effect. – tschumann Commented Feb 12, 2019 at 5:03
Add a comment  | 

1 Answer 1

Reset to default 16

You can achieve a pixelated affect by using the image-rendering: pixelated; CSS rule and scaling up an image - see this article.

发布评论

评论列表(0)

  1. 暂无评论