From 8d229e078f7e9f8af36ef983bb777c446aa5309b Mon Sep 17 00:00:00 2001 From: Jay Berkenbilt Date: Tue, 29 Jan 2019 18:16:02 -0500 Subject: [PATCH] Improve info message in optimize images (fixes #280) When qpdf can't optimize an image because of an unsupported color space, state this specifically. Recognize that many valid colorspaces are not represented as name objects. --- qpdf/qpdf.cc | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/qpdf/qpdf.cc b/qpdf/qpdf.cc index 55157af2..c26189de 100644 --- a/qpdf/qpdf.cc +++ b/qpdf/qpdf.cc @@ -3767,7 +3767,6 @@ ImageOptimizer::makePipeline(std::string const& description, Pipeline* next) QPDFObjectHandle components_obj = dict.getKey("/BitsPerComponent"); if (! (w_obj.isInteger() && h_obj.isInteger() && - colorspace_obj.isName() && components_obj.isInteger())) { if (o.verbose && (! description.empty())) @@ -3780,7 +3779,9 @@ ImageOptimizer::makePipeline(std::string const& description, Pipeline* next) } JDIMENSION w = w_obj.getIntValue(); JDIMENSION h = h_obj.getIntValue(); - std::string colorspace = colorspace_obj.getName(); + std::string colorspace = (colorspace_obj.isName() ? + colorspace_obj.getName() : + ""); int components = 0; J_COLOR_SPACE cs = JCS_UNKNOWN; if (colorspace == "/DeviceRGB") @@ -3803,8 +3804,8 @@ ImageOptimizer::makePipeline(std::string const& description, Pipeline* next) if (o.verbose && (! description.empty())) { std::cout << whoami << ": " << description - << ": not optimizing because of unsupported" - << " image parameters" << std::endl; + << ": not optimizing because qpdf can't optimize" + << " images with this colorspace" << std::endl; } return result; }