From eaf9de23c9255d8d652b4b42f0925f8db59f652d Mon Sep 17 00:00:00 2001 From: Johannes 'josch' Schauer Date: Tue, 17 Jul 2018 23:59:55 +0200 Subject: [PATCH] Filter must not be array for PNG output, so never make it an array --- src/img2pdf.py | 4 ++-- src/tests/__init__.py | 14 +++++++------- src/tests/output/CMYK.jpg.pdf | Bin 5560 -> 5558 bytes src/tests/output/CMYK.tif.pdf | Bin 1724 -> 1722 bytes src/tests/output/gray.png.pdf | Bin 1331 -> 1329 bytes src/tests/output/mono.png.pdf | Bin 960 -> 958 bytes src/tests/output/normal.jpg.pdf | Bin 3091 -> 3089 bytes src/tests/output/normal.png.pdf | Bin 1672 -> 1670 bytes 8 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/img2pdf.py b/src/img2pdf.py index d65335e..210b2d7 100755 --- a/src/img2pdf.py +++ b/src/img2pdf.py @@ -401,9 +401,9 @@ class pdfdoc(object): # either embed the whole jpeg or deflate the bitmap representation if imgformat is ImageFormat.JPEG: - ofilter = [PdfName.DCTDecode] + ofilter = PdfName.DCTDecode elif imgformat is ImageFormat.JPEG2000: - ofilter = [PdfName.JPXDecode] + ofilter = PdfName.JPXDecode self.writer.version = "1.5" # jpeg2000 needs pdf 1.5 elif imgformat is ImageFormat.CCITTGroup4: ofilter = PdfName.CCITTFaxDecode diff --git a/src/tests/__init__.py b/src/tests/__init__.py index 00426be..3c89b0f 100644 --- a/src/tests/__init__.py +++ b/src/tests/__init__.py @@ -554,9 +554,9 @@ def test_suite(): # test if the filter is valid: self.assertIn( - imgprops.Filter, [[PdfName.DCTDecode], [PdfName.JPXDecode], - [PdfName.FlateDecode], - [PdfName.CCITTFaxDecode]]) + imgprops.Filter, [PdfName.DCTDecode, PdfName.JPXDecode, + PdfName.FlateDecode, + PdfName.CCITTFaxDecode]) # test if the colorspace is valid self.assertIn( imgprops.ColorSpace, [PdfName.DeviceGray, @@ -568,12 +568,12 @@ def test_suite(): self.assertEqual(imgprops.Height, str(orig_img.size[1])) # if the input file is a jpeg then it should've been copied # verbatim into the PDF - if imgprops.Filter in [[PdfName.DCTDecode], - [PdfName.JPXDecode]]: + if imgprops.Filter in [PdfName.DCTDecode, + PdfName.JPXDecode]: self.assertEqual( cur_page.Resources.XObject.Im0.stream, convert_load(orig_imgdata)) - elif imgprops.Filter == [PdfName.CCITTFaxDecode]: + elif imgprops.Filter == PdfName.CCITTFaxDecode: tiff_header = tiff_header_for_ccitt( int(imgprops.Width), int(imgprops.Height), int(imgprops.Length), 4) @@ -589,7 +589,7 @@ def test_suite(): except AttributeError: pass - elif imgprops.Filter == [PdfName.FlateDecode]: + elif imgprops.Filter == PdfName.FlateDecode: # otherwise, the data is flate encoded and has to be equal # to the pixel data of the input image imgdata = zlib.decompress( diff --git a/src/tests/output/CMYK.jpg.pdf b/src/tests/output/CMYK.jpg.pdf index bfe67f395dc157c6cbaa6d39e9172565f47fb5cb..9efbe1603965b7ff5192148e23bcd2057394f05e 100644 GIT binary patch delta 32 ocmdm?y-j<=K}Ifp7v~U{)a3k>)XirZ9}9CBbE&Gj`nz!f0K&owc>n+a delta 34 qcmdm{y+eD$K}McveHZ5tm(=9^l+@VGrx_m$bC`0es=E5SaRC6^YYQ^~ diff --git a/src/tests/output/CMYK.tif.pdf b/src/tests/output/CMYK.tif.pdf index b00586bbe0d03ba5b0f74f5c94443f23371597c2..242bac73bc40390795679a7c8a714257cf32ecef 100644 GIT binary patch delta 34 pcmdnPyNh?jQbrzqx17Y1RF~A`{FKzqn;98dIn23KRbBnvxB$)U3N`=$ delta 36 rcmdnRyN7qfQbxXLeYc#%l2n(}*v%Um8Cf|jxl~nM{oS|#=fn!| diff --git a/src/tests/output/gray.png.pdf b/src/tests/output/gray.png.pdf index 573776049c45aa3f90872e4a15b86c19f20ecbce..3f2d4c3d9bbd1b7ed623b2653377d4f64ea8c626 100644 GIT binary patch delta 34 pcmdnYwUKMXXGR`TSTmZ~T3Euz! delta 36 rcmdnUwV7+fXGXqgeYc#%l2n(}*v<$XGXqgeYc#%l2n(}*vajB}h`nz!f0Q^1-Hvj+t diff --git a/src/tests/output/normal.jpg.pdf b/src/tests/output/normal.jpg.pdf index 87d2645450346af6043d0957d1c3b8888c94ded5..7acbe20198302682d7c91f7ce90033b673bac21c 100644 GIT binary patch delta 42 xcmbO%F;QZ}5=Iey7v~U{)a3k>R0VyH)XemZ5-x?!yBGtxI83-yRbBnvxBwqY3>yFd delta 44 zcmbOzF%@me>W}w>>~@F