Fabricjs HTML5 Canvas: Why are images so poorly re

2020-05-27 05:26发布

问题:

When I add a 775 x 775 image to a fabricjs canvas and resize it down to around 90 x 90, the image greatly loses its quality.

But if I add that same image as an <img/> and scale it down, it retains its quality.

Why does the canvas image become so low quality? How can I make the canvas image retain it's original quality like the <img/> does?

回答1:

It should probably go for a comment, but unfortunately I am new here and I can't add comments. However, to me it looks like antialiasing issue. Canvas is just bunch of pixels - it's up to you whether you do some antialiasing or not. Browsers however do some antialiasing on picture scaling (see here Disable antialising when scaling images).

This question might be a duplicate of:

Html5 canvas drawImage: how to apply antialiasing

HTML5 Canvas and Anti-aliasing

Hope it helps.