From df9588c3a8040d193b60dcb86bd8b03eef94224b Mon Sep 17 00:00:00 2001 From: Adrian Johnson Date: Sat, 24 Aug 2013 21:25:51 +0930 Subject: [PATCH 7/7] pdfimages: Add -all option to write all image in thair native format --- utils/pdfimages.1 | 4 ++++ utils/pdfimages.cc | 23 +++++++++++++++++------ 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/utils/pdfimages.1 b/utils/pdfimages.1 index 5a87573..a841ad7 100644 --- a/utils/pdfimages.1 +++ b/utils/pdfimages.1 @@ -87,6 +87,10 @@ Encoding uses 0 for black and 1 for white Input data fills from most significant bit to least significant bit. .RE .TP +.B \-all +Write JPEG, JPEG2000, JBIG2, and CCITT images in their native format. All other images are written as PNG files. +This is equivalent to specifying the options \-png \-j \-jp2 \-jbig2 \-ccitt. +.TP .B \-list Instead of writing the images, list the images along with various information for each image. Do not specify an .IR image-root diff --git a/utils/pdfimages.cc b/utils/pdfimages.cc index 5d74738..ac7cac7 100644 --- a/utils/pdfimages.cc +++ b/utils/pdfimages.cc @@ -56,6 +56,7 @@ static GBool dumpJPEG = gFalse; static GBool dumpJP2 = gFalse; static GBool dumpJBIG2 = gFalse; static GBool dumpCCITT = gFalse; +static GBool allFormats = gFalse; static GBool pageNames = gFalse; static char ownerPassword[33] = "\001"; static char userPassword[33] = "\001"; @@ -84,6 +85,8 @@ static const ArgDesc argDesc[] = { "write JBIG2 images as JBIG2 files"}, {"-ccitt", argFlag, &dumpCCITT, 0, "write CCITT images as CCITT files"}, + {"-all", argFlag, &allFormats, 0, + "equivalent to -png -j -jp2 -jbig2 -ccitt"}, {"-list", argFlag, &listImages, 0, "print list of images instead of saving"}, {"-opw", argString, ownerPassword, sizeof(ownerPassword), @@ -189,12 +192,20 @@ int main(int argc, char *argv[]) { // write image files imgOut = new ImageOutputDev(imgRoot, pageNames, listImages); if (imgOut->isOk()) { - imgOut->enablePNG(enablePNG); - imgOut->enableTiff(enableTiff); - imgOut->enableJpeg(dumpJPEG); - imgOut->enableJpeg2000(dumpJP2); - imgOut->enableJBig2(dumpJBIG2); - imgOut->enableCCITT(dumpCCITT); + if (allFormats) { + imgOut->enablePNG(gTrue); + imgOut->enableJpeg(gTrue); + imgOut->enableJpeg2000(gTrue); + imgOut->enableJBig2(gTrue); + imgOut->enableCCITT(gTrue); + } else { + imgOut->enablePNG(enablePNG); + imgOut->enableTiff(enableTiff); + imgOut->enableJpeg(dumpJPEG); + imgOut->enableJpeg2000(dumpJP2); + imgOut->enableJBig2(dumpJBIG2); + imgOut->enableCCITT(dumpCCITT); + } doc->displayPages(imgOut, firstPage, lastPage, 72, 72, 0, gTrue, gFalse, gFalse); } -- 1.8.1.2