def test_jp2(resources): pdf = Pdf.open(resources / 'pike-jp2.pdf') xobj = next(iter(pdf.pages[0].images.values())) pim = PdfImage(xobj) assert isinstance(pim, PdfJpxImage) assert '/JPXDecode' in pim.filters assert pim.colorspace == '/DeviceRGB' assert not pim.is_inline assert not pim.indexed assert pim.mode == 'RGB' assert pim.bits_per_component == 8 assert pim.__eq__(42) is NotImplemented assert pim == PdfImage(xobj) outstream = BytesIO() pim.extract_to(stream=outstream) del pim del xobj.ColorSpace # If there is no explicit ColorSpace metadata we should get it from the # compressed data stream pim = PdfImage(xobj) assert pim.colorspace == '/DeviceRGB' assert pim.bits_per_component == 8
def test_jp2(first_image_in): xobj, pdf = first_image_in('pike-jp2.pdf') pim = PdfImage(xobj) assert isinstance(pim, PdfJpxImage) assert '/JPXDecode' in pim.filters assert pim.colorspace == '/DeviceRGB' assert not pim.is_inline assert not pim.indexed assert pim.mode == 'RGB' assert pim.bits_per_component == 8 assert pim.__eq__(42) is NotImplemented assert pim == PdfImage(xobj) outstream = BytesIO() pim.extract_to(stream=outstream) del pim del xobj.ColorSpace # If there is no explicit ColorSpace metadata we should get it from the # compressed data stream pim = PdfImage(xobj) assert pim.colorspace == '/DeviceRGB' assert pim.bits_per_component == 8