如何从PDF文件提取图像? [英] How can I extract images from a PDF file?
问题描述
我需要从服务器上的PDF文件中提取所有图像.我不想要PDF页面,只想要原始大小和分辨率的图像.
I need to extract all the images from a PDF file on my server. I don't want the PDF pages, only the images at their original size and resolution.
我该如何使用Perl,PHP或任何其他基于UNIX的应用程序(我将通过PHP的exec函数调用它)来实现此目的?
How could I do this with Perl, PHP or any other UNIX based app (which I would invoke with the exec function from PHP)?
推荐答案
pdfimages 就是这样.它是poppler-utils和xpdf-utils软件包的一部分.
pdfimages does just that. It's is part of the poppler-utils and xpdf-utils packages.
从联机帮助页:
Pdfimages将可移植文档格式(PDF)文件中的图像另存为可移植Pixmap(PPM),可移植位图(PBM)或JPEG文件.
Pdfimages saves images from a Portable Document Format (PDF) file as Portable Pixmap (PPM), Portable Bitmap (PBM), or JPEG files.
Pdfimages读取PDF文件,扫描一页或多页PDF文件并为每个图像image-root-nnn.xxx写入一个PPM,PBM或JPEG文件,其中nnn是图像编号,xxx是图像类型(.ppm,.pbm,.jpg).
Pdfimages reads the PDF file, scans one or more pages, PDF-file, and writes one PPM, PBM, or JPEG file for each image, image-root-nnn.xxx, where nnn is the image number and xxx is the image type (.ppm, .pbm, .jpg).
注意:pdfimages从PDF文件中提取原始图像数据,而无需执行任何其他转换. PDF内容流所做的任何旋转,剪切,颜色反转等操作都将被忽略.
NB: pdfimages extracts the raw image data from the PDF file, without performing any additional transforms. Any rotation, clipping, color inversion, etc. done by the PDF content stream is ignored.
这篇关于如何从PDF文件提取图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!