2
1
mirror of https://github.com/qpdf/qpdf.git synced 2024-06-05 03:40:53 +00:00

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.
This commit is contained in:
Jay Berkenbilt 2019-01-29 18:16:02 -05:00
parent 8a9cfd2605
commit 8d229e078f

View File

@ -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;
}