mirror of
https://github.com/python-pillow/Pillow.git
synced 2026-02-03 22:15:52 +03:00
Merge 7e208ccf9d into 62aa42f9da
This commit is contained in:
commit
1f14836d71
|
|
@ -85,7 +85,7 @@ class TestFileJpeg:
|
|||
def test_zero(self, size: tuple[int, int], tmp_path: Path) -> None:
|
||||
f = tmp_path / "temp.jpg"
|
||||
im = Image.new("RGB", size)
|
||||
with pytest.raises(ValueError):
|
||||
with pytest.raises(ValueError, match="cannot write empty image"):
|
||||
im.save(f)
|
||||
|
||||
def test_app(self) -> None:
|
||||
|
|
|
|||
|
|
@ -1244,7 +1244,7 @@ class TestFileLibTiff(LibTiffTestCase):
|
|||
def test_save_zero(self, compression: str | None, tmp_path: Path) -> None:
|
||||
im = Image.new("RGB", (0, 0))
|
||||
out = tmp_path / "temp.tif"
|
||||
with pytest.raises(SystemError):
|
||||
with pytest.raises(ValueError, match="cannot write empty image"):
|
||||
im.save(out, compression=compression)
|
||||
|
||||
def test_save_many_compressed(self, tmp_path: Path) -> None:
|
||||
|
|
|
|||
|
|
@ -661,10 +661,6 @@ def get_sampling(im: Image.Image) -> int:
|
|||
|
||||
|
||||
def _save(im: Image.Image, fp: IO[bytes], filename: str | bytes) -> None:
|
||||
if im.width == 0 or im.height == 0:
|
||||
msg = "cannot write empty image as JPEG"
|
||||
raise ValueError(msg)
|
||||
|
||||
try:
|
||||
rawmode = RAWMODE[im.mode]
|
||||
except KeyError as e:
|
||||
|
|
|
|||
|
|
@ -239,6 +239,10 @@ _setimage(ImagingEncoderObject *encoder, PyObject *args) {
|
|||
if (!im) {
|
||||
return NULL;
|
||||
}
|
||||
if (im->xsize == 0 || im->ysize == 0) {
|
||||
PyErr_SetString(PyExc_ValueError, "cannot write empty image");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
encoder->im = im;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user