Filter must not be array for PNG output, so never make it an array

This commit is contained in:
Johannes 'josch' Schauer 2018-07-17 23:59:55 +02:00
parent 2a33ff275d
commit eaf9de23c9
Signed by untrusted user: josch
GPG key ID: F2CBA5C78FBD83E1
8 changed files with 9 additions and 9 deletions

View file

@ -401,9 +401,9 @@ class pdfdoc(object):
# either embed the whole jpeg or deflate the bitmap representation # either embed the whole jpeg or deflate the bitmap representation
if imgformat is ImageFormat.JPEG: if imgformat is ImageFormat.JPEG:
ofilter = [PdfName.DCTDecode] ofilter = PdfName.DCTDecode
elif imgformat is ImageFormat.JPEG2000: elif imgformat is ImageFormat.JPEG2000:
ofilter = [PdfName.JPXDecode] ofilter = PdfName.JPXDecode
self.writer.version = "1.5" # jpeg2000 needs pdf 1.5 self.writer.version = "1.5" # jpeg2000 needs pdf 1.5
elif imgformat is ImageFormat.CCITTGroup4: elif imgformat is ImageFormat.CCITTGroup4:
ofilter = PdfName.CCITTFaxDecode ofilter = PdfName.CCITTFaxDecode

View file

@ -554,9 +554,9 @@ def test_suite():
# test if the filter is valid: # test if the filter is valid:
self.assertIn( self.assertIn(
imgprops.Filter, [[PdfName.DCTDecode], [PdfName.JPXDecode], imgprops.Filter, [PdfName.DCTDecode, PdfName.JPXDecode,
[PdfName.FlateDecode], PdfName.FlateDecode,
[PdfName.CCITTFaxDecode]]) PdfName.CCITTFaxDecode])
# test if the colorspace is valid # test if the colorspace is valid
self.assertIn( self.assertIn(
imgprops.ColorSpace, [PdfName.DeviceGray, imgprops.ColorSpace, [PdfName.DeviceGray,
@ -568,12 +568,12 @@ def test_suite():
self.assertEqual(imgprops.Height, str(orig_img.size[1])) self.assertEqual(imgprops.Height, str(orig_img.size[1]))
# if the input file is a jpeg then it should've been copied # if the input file is a jpeg then it should've been copied
# verbatim into the PDF # verbatim into the PDF
if imgprops.Filter in [[PdfName.DCTDecode], if imgprops.Filter in [PdfName.DCTDecode,
[PdfName.JPXDecode]]: PdfName.JPXDecode]:
self.assertEqual( self.assertEqual(
cur_page.Resources.XObject.Im0.stream, cur_page.Resources.XObject.Im0.stream,
convert_load(orig_imgdata)) convert_load(orig_imgdata))
elif imgprops.Filter == [PdfName.CCITTFaxDecode]: elif imgprops.Filter == PdfName.CCITTFaxDecode:
tiff_header = tiff_header_for_ccitt( tiff_header = tiff_header_for_ccitt(
int(imgprops.Width), int(imgprops.Height), int(imgprops.Width), int(imgprops.Height),
int(imgprops.Length), 4) int(imgprops.Length), 4)
@ -589,7 +589,7 @@ def test_suite():
except AttributeError: except AttributeError:
pass pass
elif imgprops.Filter == [PdfName.FlateDecode]: elif imgprops.Filter == PdfName.FlateDecode:
# otherwise, the data is flate encoded and has to be equal # otherwise, the data is flate encoded and has to be equal
# to the pixel data of the input image # to the pixel data of the input image
imgdata = zlib.decompress( imgdata = zlib.decompress(

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.