summaryrefslogtreecommitdiffstats
path: root/qpdf/qpdf.cc
diff options
context:
space:
mode:
authorJay Berkenbilt <ejb@ql.org>2019-01-31 22:07:33 +0100
committerJay Berkenbilt <ejb@ql.org>2019-02-01 03:29:28 +0100
commit0a470d2daf8ec8a1ba0abfea053af4b4d0955ff6 (patch)
treee2ce315e1904cc593ab5f6b411043b5559d7df18 /qpdf/qpdf.cc
parenteb49e07c0afc1b30b53d3ae2849c824c9407f00d (diff)
downloadqpdf-0a470d2daf8ec8a1ba0abfea053af4b4d0955ff6.tar.zst
Don't optimize non-8-bit images
Also add test cases for additional coverage on image optimization.
Diffstat (limited to 'qpdf/qpdf.cc')
-rw-r--r--qpdf/qpdf.cc13
1 files changed, 13 insertions, 0 deletions
diff --git a/qpdf/qpdf.cc b/qpdf/qpdf.cc
index 12672e21..6db07432 100644
--- a/qpdf/qpdf.cc
+++ b/qpdf/qpdf.cc
@@ -3816,6 +3816,18 @@ ImageOptimizer::makePipeline(std::string const& description, Pipeline* next)
}
return result;
}
+ QPDFObjectHandle components_obj = dict.getKey("/BitsPerComponent");
+ if (! (components_obj.isInteger() && (components_obj.getIntValue() == 8)))
+ {
+ QTC::TC("qpdf", "qpdf image optimize bits per component");
+ if (o.verbose && (! description.empty()))
+ {
+ std::cout << whoami << ": " << description
+ << ": not optimizing because image has other than"
+ << " 8 bits per component" << std::endl;
+ }
+ return result;
+ }
// Files have been seen in the wild whose width and height are
// floating point, which is goofy, but we can deal with it.
JDIMENSION w = static_cast<JDIMENSION>(
@@ -3844,6 +3856,7 @@ ImageOptimizer::makePipeline(std::string const& description, Pipeline* next)
}
else
{
+ QTC::TC("qpdf", "qpdf image optimize colorspace");
if (o.verbose && (! description.empty()))
{
std::cout << whoami << ": " << description