mirror of
https://github.com/qpdf/qpdf.git
synced 2025-02-02 11:58:25 +00:00
Bug fix: handle ColorSpace lookup for inline images (fixes #392)
If the value of /CS in the inline image dictionary was is key in the page's /Resource -> /ColorSpace dictionary, properly resolve it by referencing the proper colorspace, and not just the name, in the external image dictionary.
This commit is contained in:
parent
12777a04ca
commit
bbc2f8ffae
@ -1,5 +1,9 @@
|
|||||||
2020-01-26 Jay Berkenbilt <ejb@ql.org>
|
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
|
* Add "encrypt" key to the json output. This contains largely the
|
||||||
same information as given by --show-encryption but in a
|
same information as given by --show-encryption but in a
|
||||||
consistent, parseable format.
|
consistent, parseable format.
|
||||||
|
@ -141,6 +141,22 @@ InlineImageTracker::convertIIDict(QPDFObjectHandle odict)
|
|||||||
}
|
}
|
||||||
else
|
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();
|
name.clear();
|
||||||
}
|
}
|
||||||
if (! name.empty())
|
if (! name.empty())
|
||||||
|
@ -447,3 +447,4 @@ QPDF_encryption same password 1
|
|||||||
QPDFWriter stream in ostream 0
|
QPDFWriter stream in ostream 0
|
||||||
QPDFObjectHandle duplicate dict key 0
|
QPDFObjectHandle duplicate dict key 0
|
||||||
QPDFWriter no encryption sig contents 0
|
QPDFWriter no encryption sig contents 0
|
||||||
|
QPDFPageObjectHelper colorspace lookup 0
|
||||||
|
@ -809,7 +809,7 @@ $td->runtest("check pass1 file",
|
|||||||
show_ntests();
|
show_ntests();
|
||||||
# ----------
|
# ----------
|
||||||
$td->notify("--- Inline Images ---");
|
$td->notify("--- Inline Images ---");
|
||||||
$n_tests += 8;
|
$n_tests += 10;
|
||||||
|
|
||||||
# The file large-inline-image.pdf is a hand-crafted file with several
|
# The file large-inline-image.pdf is a hand-crafted file with several
|
||||||
# inline images of various sizes including one that is two megabytes,
|
# 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->runtest("check output",
|
||||||
{$td->FILE => "a.pdf"},
|
{$td->FILE => "a.pdf"},
|
||||||
{$td->FILE => "damaged-inline-image-out.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 = (
|
my @eii_tests = (
|
||||||
['inline-images', 80],
|
['inline-images', 80],
|
||||||
|
BIN
qpdf/qtest/qpdf/inline-image-colorspace-lookup-out.pdf
Normal file
BIN
qpdf/qtest/qpdf/inline-image-colorspace-lookup-out.pdf
Normal file
Binary file not shown.
BIN
qpdf/qtest/qpdf/inline-image-colorspace-lookup.pdf
Normal file
BIN
qpdf/qtest/qpdf/inline-image-colorspace-lookup.pdf
Normal file
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user