如何从 PDF 文件中提取图像? [英] How can I extract images from a PDF file?

查看:51
本文介绍了如何从 PDF 文件中提取图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要从服务器上的 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) 文件中的图像保存为便携式像素图 (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 文件,并为每个图像写入一个 PPM、PBM 或 JPEG 文件 image-root-nnn.xxx,其中 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆