summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgregor herrmann <gregoa@debian.org>2021-03-28 17:36:21 +0200
committergregor herrmann <gregoa@debian.org>2021-03-28 17:36:21 +0200
commitd5078c25d23795316e09b98f0ab07fecc83cbe47 (patch)
treef673bd3eb895fd48b6cf7784a6aca5981080e0e2
parent2cb135337a55c78a00a56fbf9573d7cdb2251f35 (diff)
Add patch to fix TIFF bilevel issues.
Thanks: Francesco Potortì for the bug report and Jeffrey Ratcliffe for preparing the patch by cherry-picking relevant parts from upstream Git. Closes: #985887
-rw-r--r--debian/patches/bilevel_tiff.patch47
-rw-r--r--debian/patches/series1
2 files changed, 48 insertions, 0 deletions
diff --git a/debian/patches/bilevel_tiff.patch b/debian/patches/bilevel_tiff.patch
new file mode 100644
index 0000000..2d6262a
--- /dev/null
+++ b/debian/patches/bilevel_tiff.patch
@@ -0,0 +1,47 @@
+Description: TIFF bilevel fixes
+Origin: upstream
+Bug-Debian: https://bugs.debian.org/985887
+Author: Phil Perry
+Reviewed-by: Jeffrey Ratcliffe <jffry@posteo.net>
+ gregor herrmann <gregoa@debian.org>
+Last-Update: 2021-03-28
+Applied-Upstream: https://github.com/PhilterPaper/Perl-PDF-Builder/commit/d03b59847ecfbf3c7c31b8c1901d3878dba08040
+
+--- a/lib/PDF/Builder/Resource/XObject/Image/TIFF_GT.pm
++++ b/lib/PDF/Builder/Resource/XObject/Image/TIFF_GT.pm
+@@ -164,6 +164,9 @@
+ $dict->{'BitsPerComponent'} = PDFNum($tif->{'bitsPerSample'});
+ $dict->{'Colors'} = PDFNum($tif->{'colorSpace'} eq 'DeviceGray'?1 :3);
+
++ if (!defined $tif->{'filter'} && $tif->{'bitsPerSample'} == 1) {
++ $self->{'Decode'} = PDFArray(PDFNum(1), PDFNum(0));
++ }
+ $stripcount = $tif->{'object'}->NumberOfStrips();
+ $buffer = '';
+ for my $i (0 .. $stripcount - 1) {
+@@ -586,9 +589,10 @@
+ $decode->{'K'} = (($tif->{'ccitt'} == 4 || (defined $tif->{'g3Options'} && $tif->{'g3Options'} & 0x1))? PDFNum(-1): PDFNum(0));
+ $decode->{'Columns'} = PDFNum($tif->{'imageWidth'});
+ $decode->{'Rows'} = PDFNum($tif->{'imageHeight'});
+- # not sure why whiteIsZero needs to be flipped around???
+- $decode->{'BlackIs1'} = PDFBool($tif->{'whiteIsZero'} == 0? 1: 0);
++ $decode->{'BlackIs1'} = PDFBool($tif->{'whiteIsZero'} == 1? 1: 0);
+ $decode->{'DamagedRowsBeforeError'} = PDFNum(100);
++ # all CCITT Fax need to flip black/white
++ $self->{'Decode'} = PDFArray(PDFNum(1), PDFNum(0));
+
+ # g3Options bit 0 = 0 for 1-Dimensional, = 1 for 2-Dimensional MR
+ # aka T4Options bit 1 = 0 (compressed data only)
+@@ -640,12 +644,6 @@
+ sub read_tiff {
+ my ($self, $pdf, $tif, %opts) = @_;
+
+- # not sure why blackIsZero needs to be flipped around???
+- if (defined $tif->{'blackIsZero'}) {
+- $tif->{'blackIsZero'} = $tif->{'blackIsZero'} == 1? 0: 1;
+- $tif->{'whiteIsZero'} = $tif->{'blackIsZero'} == 1? 0: 1;
+- }
+-
+ $self->width($tif->{'imageWidth'});
+ $self->height($tif->{'imageHeight'});
+
diff --git a/debian/patches/series b/debian/patches/series
new file mode 100644
index 0000000..7e93554
--- /dev/null
+++ b/debian/patches/series
@@ -0,0 +1 @@
+bilevel_tiff.patch