尽管设置了密度和调整大小选项,ImageMagick 仍将 PDF 转换为小图像
我正在使用 ImageMagick 将以下 PDF 转换为 PNG 文件: 来自 IMSLP 的 PDF (永久链接)
在 PDF 查看器中它看起来不错(尽管它需要相当多的缩放) :
但使用
convert "file.pdf" "/tmp/file.png"
生成的图像进行转换时分辨率极低:
添加密度时并调整信息大小,我得到了更大的图像,但仍然不是 PDF 中存储的原始分辨率(当然不是 300 DPI)
convert -density "300" -resize "3000x3000>" "file.pdf" "/tmp/file.png"
使用 Poppler-Utils 时pdfimages
,我得到了适当的图像:
我的问题是:有没有办法告诉 ImageMagick 以“正确”分辨率提取图像(如存储在 PDF 中 文档)?换句话说,忽略正确查看 PDF 所需的缩放,从而提取正确的图像分辨率?
我在 Alpine Linux docker 镜像中使用 ImageMagick 7.1.0.16 和 Ghostscript 9.55.0。
I'm using ImageMagick to convert the following PDF to an PNG file: PDF from IMSLP (Permalink)
In a PDF viewer it looks nice (even though it needs quite a bit of zooming):
but when converting with
convert "file.pdf" "/tmp/file.png"
the produced image gets an extremely low resolution:
when adding density and resize information, I get somewhat bigger images, but still not the original resolution that is stored within the PDF (certainly not 300 DPI)
convert -density "300" -resize "3000x3000>" "file.pdf" "/tmp/file.png"
When using Poppler-Utils' pdfimages
, I'm getting the appropriate image:
My question is: Is there any way to tell ImageMagick to extract the images in the "correct" resolution (as is stored in the PDF document)? In other words, ignore the zoom that is necessary to view the PDF properly, thus extracting the correct image resolution?
I'm using ImageMagick 7.1.0.16 with Ghostscript 9.55.0 inside an Alpine Linux docker image.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这是非常不寻常的结构,它经历了许多更改,但我们可以猜测某些页面可能已转换为 300 dpi 或 600 dpi,因为它们都以大致相同的尺寸呈现。
请注意,图形 dpi 是主观的,它不是 PDF 中使用的值,而是与图形工作 dpi 相关的 72 点单位的默认像素。图像的分辨率可能为 75 dpi,但以每 72 点 300 像素的形式存储。
第一个分析表示图像为
,但所有图像都已被下采样到各种尺寸,大约为 600 dpi。 1.2" x 1.5" 因此可能有一个合理的源尺寸来匹配所有这些减少
9.6 英寸 x 12 英寸,经过一些裁剪。
因此,要获得最接近的原始质量提取页面@ 600 dpi(无损png最好保留那些有损jpeg缺陷),
然后将它们重新转换为75 dpi应该会给你最接近的低质量输入。
Very unusual structure you have there its been through many changes but we can guess some pages may have been converted to 300 dpi or 600 dpi since they all render at roughly the same size.
Note that graphics dpi is subjective it is not that value that's used inside a PDF it is the the pixels per default of 72 point units that relate to a graphics working dpi. the image may have been 75 dpi but stored at 300 pixels per 72 points.
1st Analysis says images are
but all have been down-sampled to various sizes approx. 1.2" x 1.5" so a sensible source size to match all those reductions is possibly
9.6" x 12" with some cropping.
Thus to get the nearest original quality extract pages @ 600 dpi (lossless png would be best to keep those lossy jpeg flaws)
Then reconvert them to 75 dpi should give you the closest to the poor quality inputs.
您需要将密度增加得更大,并在读取 Imagemagick 中的输入后调整大小。
这将是 5800 × 7200 像素:
这将为 2417 × 3000 像素:
You need to increase your density much larger and put your resize after reading the input in Imagemagick.
This will be 5800 × 7200 pixels:
This will be 2417 × 3000 pixels: