使用 ImageMagick 将 PDF 转换为 PNG
使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
在输出结果之前缩小图像尺寸就我而言,看起来更清晰的东西:
Reducing the image size before output results in something that looks sharper, in my case:
当你将密度设置为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
为了获得高质量,应该在 Imagemagick 中进行“超级采样”。以高密度进行转换,然后根据需要缩小大小(名义上足以补偿高密度)。
所以 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).
So the 1/4 compensates for the 4x.
对于 pdf 文本文档来说就足够了。
-密度192
双96dpi,更高只会使图像和文件大小更大-quality 100
不知怎的,这使得文件大小稍微小一些-alpha remove
删除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