Commit 8d229e078f7e9f8af36ef983bb777c446aa5309b

Authored by Jay Berkenbilt
1 parent 8a9cfd26

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.
Showing 1 changed file with 5 additions and 4 deletions
qpdf/qpdf.cc
@@ -3767,7 +3767,6 @@ ImageOptimizer::makePipeline(std::string const& description, Pipeline* next) @@ -3767,7 +3767,6 @@ ImageOptimizer::makePipeline(std::string const& description, Pipeline* next)
3767 QPDFObjectHandle components_obj = dict.getKey("/BitsPerComponent"); 3767 QPDFObjectHandle components_obj = dict.getKey("/BitsPerComponent");
3768 if (! (w_obj.isInteger() && 3768 if (! (w_obj.isInteger() &&
3769 h_obj.isInteger() && 3769 h_obj.isInteger() &&
3770 - colorspace_obj.isName() &&  
3771 components_obj.isInteger())) 3770 components_obj.isInteger()))
3772 { 3771 {
3773 if (o.verbose && (! description.empty())) 3772 if (o.verbose && (! description.empty()))
@@ -3780,7 +3779,9 @@ ImageOptimizer::makePipeline(std::string const& description, Pipeline* next) @@ -3780,7 +3779,9 @@ ImageOptimizer::makePipeline(std::string const& description, Pipeline* next)
3780 } 3779 }
3781 JDIMENSION w = w_obj.getIntValue(); 3780 JDIMENSION w = w_obj.getIntValue();
3782 JDIMENSION h = h_obj.getIntValue(); 3781 JDIMENSION h = h_obj.getIntValue();
3783 - std::string colorspace = colorspace_obj.getName(); 3782 + std::string colorspace = (colorspace_obj.isName() ?
  3783 + colorspace_obj.getName() :
  3784 + "");
3784 int components = 0; 3785 int components = 0;
3785 J_COLOR_SPACE cs = JCS_UNKNOWN; 3786 J_COLOR_SPACE cs = JCS_UNKNOWN;
3786 if (colorspace == "/DeviceRGB") 3787 if (colorspace == "/DeviceRGB")
@@ -3803,8 +3804,8 @@ ImageOptimizer::makePipeline(std::string const& description, Pipeline* next) @@ -3803,8 +3804,8 @@ ImageOptimizer::makePipeline(std::string const& description, Pipeline* next)
3803 if (o.verbose && (! description.empty())) 3804 if (o.verbose && (! description.empty()))
3804 { 3805 {
3805 std::cout << whoami << ": " << description 3806 std::cout << whoami << ": " << description
3806 - << ": not optimizing because of unsupported"  
3807 - << " image parameters" << std::endl; 3807 + << ": not optimizing because qpdf can't optimize"
  3808 + << " images with this colorspace" << std::endl;
3808 } 3809 }
3809 return result; 3810 return result;
3810 } 3811 }