tags 985887 patch thanks
I've cherry-picked enough of this patch to fix this from master at https://github.com/PhilterPaper/Perl-PDF-Builder/commit/d03b59847ecfbf3c7c31b8c1901d3878dba08040#diff-44803d0b8089ee5eb36d750b5be96b6038d4f32687973371d4c67310afc81ae1 i.e. the author should be Phil Perry, who is also the upstream maintainer.
diff --git a/lib/PDF/Builder/Resource/XObject/Image/TIFF_GT.pm b/lib/PDF/Builder/Resource/XObject/Image/TIFF_GT.pm
index 00fb893..7ac0cf9 100644
--- a/lib/PDF/Builder/Resource/XObject/Image/TIFF_GT.pm
+++ b/lib/PDF/Builder/Resource/XObject/Image/TIFF_GT.pm
@@ -164,6 +164,9 @@ sub handle_generic {
$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 @@ sub handle_ccitt {
$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 handle_ccitt {
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'});
OpenPGP_signature
Description: OpenPGP digital signature

