aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog4
-rw-r--r--libqpdf/QPDFPageObjectHelper.cc16
-rw-r--r--qpdf/qpdf.testcov1
-rw-r--r--qpdf/qtest/qpdf.test12
-rw-r--r--qpdf/qtest/qpdf/inline-image-colorspace-lookup-out.pdfbin0 -> 1348 bytes
-rw-r--r--qpdf/qtest/qpdf/inline-image-colorspace-lookup.pdfbin0 -> 1176 bytes
6 files changed, 32 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 68aff3fe..38749752 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
2020-01-26 Jay Berkenbilt <ejb@ql.org>
+ * Bug fix: when externalizing inline images, a colorspace value
+ that was a lookup key in the page's /Resource -> /ColorSpace
+ dictionary was not properly handled. Fixes #392.
+
* Add "encrypt" key to the json output. This contains largely the
same information as given by --show-encryption but in a
consistent, parseable format.
diff --git a/libqpdf/QPDFPageObjectHelper.cc b/libqpdf/QPDFPageObjectHelper.cc
index d588c322..01f1d662 100644
--- a/libqpdf/QPDFPageObjectHelper.cc
+++ b/libqpdf/QPDFPageObjectHelper.cc
@@ -141,6 +141,22 @@ InlineImageTracker::convertIIDict(QPDFObjectHandle odict)
}
else
{
+ // This is a key in the page's /Resources ->
+ // /ColorSpace dictionary. We need to look it up
+ // and use its value as the color space for the
+ // image.
+ QPDFObjectHandle colorspace =
+ resources.getKey("/ColorSpace");
+ if (colorspace.isDictionary() && colorspace.hasKey(name))
+ {
+ QTC::TC("qpdf", "QPDFPageObjectHelper colorspace lookup");
+ value = colorspace.getKey(name);
+ }
+ else
+ {
+ resources.warnIfPossible(
+ "unable to resolve colorspace " + name);
+ }
name.clear();
}
if (! name.empty())
diff --git a/qpdf/qpdf.testcov b/qpdf/qpdf.testcov
index 82ac9684..db3de950 100644
--- a/qpdf/qpdf.testcov
+++ b/qpdf/qpdf.testcov
@@ -447,3 +447,4 @@ QPDF_encryption same password 1
QPDFWriter stream in ostream 0
QPDFObjectHandle duplicate dict key 0
QPDFWriter no encryption sig contents 0
+QPDFPageObjectHelper colorspace lookup 0
diff --git a/qpdf/qtest/qpdf.test b/qpdf/qtest/qpdf.test
index bfc20178..f9bab01f 100644
--- a/qpdf/qtest/qpdf.test
+++ b/qpdf/qtest/qpdf.test
@@ -809,7 +809,7 @@ $td->runtest("check pass1 file",
show_ntests();
# ----------
$td->notify("--- Inline Images ---");
-$n_tests += 8;
+$n_tests += 10;
# The file large-inline-image.pdf is a hand-crafted file with several
# inline images of various sizes including one that is two megabytes,
@@ -853,6 +853,16 @@ $td->runtest("externalize damaged image",
$td->runtest("check output",
{$td->FILE => "a.pdf"},
{$td->FILE => "damaged-inline-image-out.pdf"});
+$td->runtest("named colorspace",
+ {$td->COMMAND =>
+ "qpdf --static-id --externalize-inline-images" .
+ " --ii-min-bytes=0 inline-image-colorspace-lookup.pdf a.pdf"},
+ {$td->STRING => "", $td->EXIT_STATUS => 0},
+ $td->NORMALIZE_NEWLINES);
+$td->runtest("check output",
+ {$td->FILE => "a.pdf"},
+ {$td->FILE => "inline-image-colorspace-lookup-out.pdf"});
+
my @eii_tests = (
['inline-images', 80],
diff --git a/qpdf/qtest/qpdf/inline-image-colorspace-lookup-out.pdf b/qpdf/qtest/qpdf/inline-image-colorspace-lookup-out.pdf
new file mode 100644
index 00000000..5fa0ed6c
--- /dev/null
+++ b/qpdf/qtest/qpdf/inline-image-colorspace-lookup-out.pdf
Binary files differ
diff --git a/qpdf/qtest/qpdf/inline-image-colorspace-lookup.pdf b/qpdf/qtest/qpdf/inline-image-colorspace-lookup.pdf
new file mode 100644
index 00000000..30584737
--- /dev/null
+++ b/qpdf/qtest/qpdf/inline-image-colorspace-lookup.pdf
Binary files differ