如何在不损失质量的情况下扩展图像?

时间:2019-09-17 17:03:01

标签: javascript angular image resize

我有一个png图像或斑点。 此图片有特定尺寸,可以说800px * 600px 当我使用像这样的一些画布方法调整它的大小时: Resize image, need a good library 它会失去质量。

我想将图像调整为4000像素左右,并且不模糊内容。 有办法吗?我的图片中只有文字。

我正在使用Angular CLI:1.7.3节点:8.9.0 Angular:4.4.6打字稿:2.3.4

1 个答案:

答案 0 :(得分:0)

可能发生的是,在调整画布大小时会应用一些自动别名。使用此other question for reference,似乎您可能需要为最近邻指定插值模式:

canvas {
  image-rendering: optimizeSpeed;             // Older versions of FF
  image-rendering: -moz-crisp-edges;          // FF 6.0+
  image-rendering: -webkit-optimize-contrast; // Webkit (non standard naming)
  image-rendering: -o-crisp-edges;            // OS X & Windows Opera (12.02+)
  image-rendering: crisp-edges;               // Possible future browsers.
  -ms-interpolation-mode: nearest-neighbor;   // IE (non standard naming)
}

(从引用的问题中提取的代码段)

相关问题