From 237f4e0887eff2f22d5542dfed33fa94a8c7b0ff Mon Sep 17 00:00:00 2001 From: Ryan Date: Tue, 21 Feb 2017 16:11:53 +0800 Subject: [PATCH] Fix(poppler-utils): pdfimages extract too many same pictures with the same object number. --- utils/ImageOutputDev.cc | 8 ++++++++ utils/ImageOutputDev.h | 2 ++ 2 files changed, 10 insertions(+) diff --git a/utils/ImageOutputDev.cc b/utils/ImageOutputDev.cc index 5de51ad..26bf95b 100644 --- a/utils/ImageOutputDev.cc +++ b/utils/ImageOutputDev.cc @@ -442,6 +442,14 @@ void ImageOutputDev::writeImageFile(ImgWriter *writer, ImageFormat format, const void ImageOutputDev::writeImage(GfxState *state, Object *ref, Stream *str, int width, int height, GfxImageColorMap *colorMap, GBool inlineImg) { + if (ref->isRef()) { + const Ref imageRef = ref->getRef(); + if (refNums.find(imageRef.num) != refNums.end()) + return; + else + refNums.insert(imageRef.num); + } + ImageFormat format; if (dumpJPEG && str->getKind() == strDCT && diff --git a/utils/ImageOutputDev.h b/utils/ImageOutputDev.h index a694bbc..89c67ac 100644 --- a/utils/ImageOutputDev.h +++ b/utils/ImageOutputDev.h @@ -35,6 +35,7 @@ #endif #include +#include #include "goo/gtypes.h" #include "goo/ImgWriter.h" #include "OutputDev.h" @@ -173,6 +174,7 @@ private: int pageNum; // current page number int imgNum; // current image number GBool ok; // set up ok? + std::set refNums; }; #endif -- 2.10.2