mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-26 09:56:17 +03:00
Added exception explaining that _repr_png_ saves to PNG
This commit is contained in:
parent
b48cfa747c
commit
fdce845364
|
@ -537,6 +537,12 @@ class TestFilePng:
|
|||
assert repr_png.format == "PNG"
|
||||
assert_image_equal(im, repr_png)
|
||||
|
||||
def test_repr_png_error(self):
|
||||
im = hopper("F")
|
||||
|
||||
with pytest.raises(ValueError):
|
||||
im._repr_png_()
|
||||
|
||||
def test_chunk_order(self, tmp_path):
|
||||
with Image.open("Tests/images/icc_profile.png") as im:
|
||||
test_file = str(tmp_path / "temp.png")
|
||||
|
|
|
@ -670,7 +670,10 @@ class Image:
|
|||
:returns: png version of the image as bytes
|
||||
"""
|
||||
b = io.BytesIO()
|
||||
self.save(b, "PNG")
|
||||
try:
|
||||
self.save(b, "PNG")
|
||||
except Exception as e:
|
||||
raise ValueError("Could not save to PNG for display") from e
|
||||
return b.getvalue()
|
||||
|
||||
@property
|
||||
|
|
Loading…
Reference in New Issue
Block a user