1
0
Fork 0
forked from josch/img2pdf

src/tests/__init__.py: handle PNG input images properly

This commit is contained in:
Johannes 'josch' Schauer 2018-07-18 00:05:15 +02:00
parent b99fae1380
commit d931f02709
Signed by untrusted user: josch
GPG key ID: F2CBA5C78FBD83E1

View file

@ -589,6 +589,15 @@ def test_suite():
# to the pixel data of the input image # to the pixel data of the input image
imgdata = zlib.decompress( imgdata = zlib.decompress(
convert_store(cur_page.Resources.XObject.Im0.stream)) convert_store(cur_page.Resources.XObject.Im0.stream))
if imgprops.DecodeParms:
if orig_img.format == 'PNG':
pngidat, palette = img2pdf.parse_png(orig_imgdata)
else:
pngbuffer = BytesIO()
orig_img.save(pngbuffer, format="png")
pngidat, palette = img2pdf.parse_png(pngbuffer.getvalue())
self.assertEqual(zlib.decompress(pngidat), imgdata)
else:
colorspace = imgprops.ColorSpace colorspace = imgprops.ColorSpace
if colorspace == PdfName.DeviceGray: if colorspace == PdfName.DeviceGray:
colorspace = 'L' colorspace = 'L'