使用 ImageMagick 将 PDF 转换为 PNG

发布于 2024-09-01 20:49:10 字数 274 浏览 2 评论 0原文

使用 ImageMagick,我应该使用什么命令将 PDF 转换为 PNG?我需要最高的质量、最小的文件大小。这就是我到目前为止所得到的(顺便说一句,速度很慢):

convert -density 300 -depth 8 -quality 85 a.pdf a.png

看看 Gmail 在用户“查看”PDF 时所做的事情,质量非常好,文件大小非常小。 DPI 只有 96(我必须将密度设置为 300 才能获得像样的效果)。有人知道GMail是怎么做到的吗?谢谢。

using ImageMagick, what command should i use to convert a PDF to PNG? I need highest quality, smallest file size. this is what I have so far (very slow by the way):

convert -density 300 -depth 8 -quality 85 a.pdf a.png

Looking at what Gmail does when a user "view" a PDF, the quality is awesome and the file size very minimal. The DPI is just 96 (I have to set a density of 300 to get anything decent). Anyone know how GMail does it? Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

七七 2024-09-08 20:49:10

在输出结果之前缩小图像尺寸就我而言,看起来更清晰的东西:

convert -density 300 a.pdf -resize 25% a.png

Reducing the image size before output results in something that looks sharper, in my case:

convert -density 300 a.pdf -resize 25% a.png
坦然微笑 2024-09-08 20:49:10

当你将密度设置为96时,看起来不是很好吗?

当我尝试时,我发现保存为 jpg 会带来更好的质量,但文件大小更大

when you set the density to 96, doesn't it look good?

when i tried it i saw that saving as jpg resulted with better quality, but larger file size

智商已欠费 2024-09-08 20:49:10

为了获得高质量,应该在 Imagemagick 中进行“超级采样”。以高密度进行转换,然后根据需要缩小大小(名义上足以补偿高密度)。

convert -density 288 input.pdf -resize 25% output.png

288=72*4 (72 dpi is default density, so 4x)
25%=1/4

所以 1/4 补偿了 4x。

To get high quality, one should do "supersampling" in Imagemagick. Convert at a high density, but then resize down as needed (nominal enough to compensate for the high density).

convert -density 288 input.pdf -resize 25% output.png

288=72*4 (72 dpi is default density, so 4x)
25%=1/4

So the 1/4 compensates for the 4x.

ㄟ。诗瑗 2024-09-08 20:49:10
convert -density 192 input.pdf -quality 100 -alpha remove output.png

对于 pdf 文本文档来说就足够了。
-密度192双96dpi,更高只会使图像和文件大小更大
-quality 100 不知怎的,这使得文件大小稍微小一些
-alpha remove 删除png透明背景

convert -density 192 input.pdf -quality 100 -alpha remove output.png

for pdf text document is good enough.
-density 192 double 96dpi, higher just make bigger image and file size
-quality 100 somehow this give slightly smaller file size
-alpha remove to remove png transparent background

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文