【问题标题】:PHP imagemagick exec convert PDF page 0 to PNG is too smallPHP imagemagick exec将PDF页面0转换为PNG太小
【发布时间】:2011-07-06 19:42:21
【问题描述】:

我正在使用它来将 PDF 转换为 PNG:

exec('/usr/bin/convert -density 96 -quality 85 a.pdf[0] a.png');

我也试着让它变得像这样简单:

exec('/usr/bin/convert -colorspace RGB "a.pdf[0]" "a.png"');

但我提供的源 PDF 文件只有一张图像,没有文字,而且该图像的大小为 700x400 像素,但生成的 PNG 仍然小到 100x30。

如何转换才能得到原始大小的图像?我是不是做错了什么?

谢谢。

【问题讨论】:

  • 尝试降低密度因子。这是一个相对数字 - 较小的密度 = 较大的输出图像。
  • 实际上,如果我像这样设置密度: -density 350% ,我会得到全尺寸的精确像素图像。那怎么样?

标签: php imagemagick


【解决方案1】:

尝试使用此参数转换“-density 300x300 -units pixelperinch”。怎么样?

【讨论】:

  • 这样我可以从 500x500 像素的源中获得 429x429 像素的图像...使用 350% 的密度,我得到 500x500。我并不是说我对 imagemagick 的命令参数如此熟悉,但我只是在告诉结果。谢谢。
【解决方案2】:

我最终使用了该命令以及“-density 350%”参数。这给了我每次准确的图片尺寸,并且到目前为止一直有效。

exec('/usr/bin/convert -density 350% -quality 85 a.pdf[0] a.png');

感谢您的宝贵时间。

【讨论】:

    猜你喜欢
    • 2020-08-21
    • 1970-01-01
    • 2022-01-22
    • 2014-06-19
    • 2020-05-31
    • 2011-02-21
    • 2018-03-16
    • 1970-01-01
    • 2011-04-19
    相关资源
    最近更新 更多