【问题标题】:fabricjs toDataURL specify DPIfabricjs toDataURL 指定 DPI
【发布时间】:2015-04-12 15:02:02
【问题描述】:

我正在尝试使用 150DPI 生成 1800px 2400px 的图像,但我总是得到 72DPI。

var image = canvas.toDataURL({
  left:150,
  top: 100,
  width: 180,
  height: 240,
  multiplier: 10
}).replace("image/png", "image/octet-stream")

如何获得 150DPI 的 PNG?

【问题讨论】:

标签: png fabricjs dpi


【解决方案1】:

默认情况下,您的图像以 72DPI 创建。由于您将图像发送到服务器,因此您可以使用 ImageMagick 将图像转换为 150DPI。

在 PHP 中使用这个命令:

$img150 = "convert input72image.png -units PixelsPerCentimeter -density 60x60 output150image.png;
exec ($img150);

PNG 图像不会转换为 DPI,而是转换为“PixelsPerCentimeter”。 60 PixelsPerCentimeter 等于 152,4 DPI。

查看这些帖子: What is the best practice to export canvas with high quality images?canvas.toDataURL() for large canvas

希望对你有帮助。

【讨论】:

  • 我无权访问 exec 或任何类似的功能...您可以添加一个 php 图像魔术对象来演示吗?
猜你喜欢
  • 1970-01-01
  • 2017-05-29
  • 2012-12-25
  • 2020-09-11
  • 2012-12-13
  • 1970-01-01
  • 2015-12-30
  • 2018-10-28
  • 1970-01-01
相关资源
最近更新 更多