我正在尝试使用命令行程序转换将PDF转换为图像(JPEG或PNG)。这是我正在转换的pdf文件之一。

我想让程序去掉多余的空白,并返回足够高质量的图像,以便上标可以轻松读取。

这是我目前最好的尝试。正如你所看到的,修剪工作很好,我只是需要锐化的分辨率相当多。这是我正在使用的命令:

convert -trim 24.pdf -resize 500% -quality 100 -sharpen 0x1.0 24-11.jpg

我试着做了以下有意识的决定:

调整它的大小(对分辨率没有影响) 尽可能提高质量 使用-锐化(我已经尝试了一系列值)

任何建议,请在最终的PNG/JPEG图像的分辨率更高,将非常感谢!


当前回答

在ImageMagick中,你可以做“超级采样”。您可以指定一个较大的密度,然后根据最终输出大小调整大小。以你的图片为例:

convert -density 600 test.pdf -background white -flatten -resize 25% test.png


下载图像以完整的分辨率进行比较。

如果您希望进行进一步处理,我不建议将其保存为JPG。

如果你想要输出与输入相同的大小,那么将大小调整为密度与72之比的倒数。例如,-density 288和-resize 25%。288=4*72, 25%=1/4

密度越大,得到的质量越好,但需要更长的加工时间。

其他回答

在投票之前请注意,这个解决方案是针对使用图形界面的Gimp的,而不是使用命令行的ImageMagick的,但它作为一个替代方案对我来说效果非常好,这就是为什么我发现有必要在这里分享它。

按照这些简单的步骤从PDF文档中提取任何格式的图像

Download GIMP Image Manipulation Program Open the Program after installation Open the PDF document that you want to extract Images Select only the pages of the PDF document that you would want to extract images from. N/B: If you need only the cover images, select only the first page. Click open after selecting the pages that you want to extract images from Click on File menu when GIMP when the pages open Select Export as in the File menu Select your preferred file type by extension (say png) below the dialog box that pops up. Click on Export to export your image to your desired location. You can then check your file explorer for the exported image.

这是所有。

我希望这对你们有帮助

使用这个命令行:

convert -geometry 3600x3600 -density 300x300 -quality 100 TEAM\ 4.pdf team4.png

这将正确地转换您所要求的文件。

另一个建议是您可以使用GIMP。

只需在GIMP->中加载PDF文件,另存为.xcf,然后你就可以对图像做任何你想做的事情了。

在mac电脑上使用预览其实很容易做到。你所要做的就是在预览中打开文件,并另存(或导出)png或jpeg格式,但要确保你在窗口底部使用至少300 dpi来获得高质量的图像。

对于Windows(在W11上测试):

magick.exe -verbose -density 150 "input.pdf" -quality 100 -sharpen 0x1.0 output.jpg

你需要安装:

ImageMagick https://imagemagick.org/index.php。

ghostscript https://www.ghostscript.com/releases/gsdnld.html

额外的信息:

注意使用-flatten参数,因为它只能生成首页作为图像 使用-scene 1参数从索引1开始,其中包含图像名称 上面提到的转换命令已经被弃用,取而代之的是魔法