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: josch
GPG key ID: F2CBA5C78FBD83E1

View file

@ -589,6 +589,15 @@ def test_suite():
# to the pixel data of the input image
imgdata = zlib.decompress(
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
if colorspace == PdfName.DeviceGray:
colorspace = 'L'