From ac9ba1d0f69e99f32bc20629a3cc41b88d484773 Mon Sep 17 00:00:00 2001 From: Johannes 'josch' Schauer Date: Wed, 18 Jul 2018 00:03:31 +0200 Subject: [PATCH] handle monochrome png properly --- src/img2pdf.py | 8 ++++++-- src/tests/output/mono.png.pdf | Bin 958 -> 958 bytes 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/img2pdf.py b/src/img2pdf.py index 210b2d7..29522ba 100755 --- a/src/img2pdf.py +++ b/src/img2pdf.py @@ -422,7 +422,9 @@ class pdfdoc(object): if imgformat is ImageFormat.CCITTGroup4: image[PdfName.BitsPerComponent] = 1 else: - if color == Colorspace.P: + if color == Colorspace['1']: + image[PdfName.BitsPerComponent] = 1 + elif color == Colorspace.P: if len(palette) <= 2**1: image[PdfName.BitsPerComponent] = 1 elif len(palette) <= 2**4: @@ -451,7 +453,9 @@ class pdfdoc(object): else: decodeparms[PdfName.Colors] = 3 decodeparms[PdfName.Columns] = imgwidthpx - if color == Colorspace.P: + if color == Colorspace['1']: + decodeparms[PdfName.BitsPerComponent] = 1 + elif color == Colorspace.P: if len(palette) <= 2**1: decodeparms[PdfName.BitsPerComponent] = 1 elif len(palette) <= 2**4: diff --git a/src/tests/output/mono.png.pdf b/src/tests/output/mono.png.pdf index af98641973dd36ea93f08d2c1a4b5c840cf821f2..c773715d7c5cf883d5e6bc77f815103e238df04e 100644 GIT binary patch delta 20 ccmdnTzK?xFGb5wnHq)$ delta 20 ccmdnTzK?xFGb5wLQs_y7O^