MCPcopy Index your code
hub / github.com/python-pillow/Pillow / roundtrip

Method roundtrip

Tests/test_imagefile.py:35–50  ·  view source on GitHub ↗
(format: str)

Source from the content-addressed store, hash-verified

33class TestImageFile:
34 def test_parser(self, monkeypatch: pytest.MonkeyPatch) -> None:
35 def roundtrip(format: str) -> tuple[Image.Image, Image.Image]:
36 im = hopper("L").resize((1000, 1000), Image.Resampling.NEAREST)
37 if format in ("MSP", "XBM"):
38 im = im.convert("1")
39
40 test_file = BytesIO()
41
42 im.copy().save(test_file, format)
43
44 data = test_file.getvalue()
45
46 parser = ImageFile.Parser()
47 parser.feed(data)
48 im_out = parser.close()
49
50 return im, im_out
51
52 assert_image_equal(*roundtrip("BMP"))
53 im1, im2 = roundtrip("GIF")

Callers

nothing calls this directly

Calls 7

feedMethod · 0.95
closeMethod · 0.95
hopperFunction · 0.85
convertMethod · 0.80
resizeMethod · 0.45
saveMethod · 0.45
copyMethod · 0.45

Tested by

no test coverage detected