def test_sanity(self): self.assertRaises(ValueError, lambda: hopper().tobitmap()) im1 = hopper().convert("1") bitmap = im1.tobitmap() self.assertIsInstance(bitmap, bytes) self.assert_image_equal(im1, fromstring(bitmap))
def test_safeblock(self): if "zip_encoder" not in codecs: self.skipTest("PNG (zlib) encoder not available") im1 = hopper() try: ImageFile.SAFEBLOCK = 1 im2 = fromstring(tostring(im1, "PNG")) finally: ImageFile.SAFEBLOCK = SAFEBLOCK self.assert_image_equal(im1, im2)
def draft(mode, size): im = fromstring(DATA) im.draft(mode, size) return im
def draft_roundtrip(self, in_mode, in_size, req_mode, req_size): im = Image.new(in_mode, in_size) data = tostring(im, 'JPEG') im = fromstring(data) im.draft(req_mode, req_size) return im
def draft(mode, size): im = fromstring(data) im.draft(mode, size) return im