mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-07-28 08:59:57 +03:00
Simplified code
This commit is contained in:
parent
8093cf3704
commit
7ebfb871d0
|
@ -6,11 +6,7 @@ import pytest
|
||||||
|
|
||||||
from PIL import Image, QoiImagePlugin
|
from PIL import Image, QoiImagePlugin
|
||||||
|
|
||||||
from .helper import (
|
from .helper import assert_image_equal_tofile, hopper
|
||||||
assert_image_equal,
|
|
||||||
assert_image_equal_tofile,
|
|
||||||
hopper,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def test_sanity() -> None:
|
def test_sanity() -> None:
|
||||||
|
@ -42,15 +38,13 @@ def test_save(tmp_path: Path) -> None:
|
||||||
im = hopper("RGB")
|
im = hopper("RGB")
|
||||||
im.save(f, qoi_colorspace="sRGB")
|
im.save(f, qoi_colorspace="sRGB")
|
||||||
|
|
||||||
with Image.open(f) as reloaded:
|
assert_image_equal_tofile(im, f)
|
||||||
assert_image_equal(im, reloaded)
|
|
||||||
|
|
||||||
for image in ["Tests/images/default_font.png", "Tests/images/pil123rgba.png"]:
|
for image in ["Tests/images/default_font.png", "Tests/images/pil123rgba.png"]:
|
||||||
with Image.open(image) as im:
|
with Image.open(image) as im:
|
||||||
im.save(f)
|
im.save(f)
|
||||||
|
|
||||||
with Image.open(f) as reloaded:
|
assert_image_equal_tofile(im, f)
|
||||||
assert_image_equal(im, reloaded)
|
|
||||||
|
|
||||||
im = hopper("P")
|
im = hopper("P")
|
||||||
with pytest.raises(ValueError):
|
with pytest.raises(ValueError):
|
||||||
|
|
|
@ -133,7 +133,7 @@ def _save(im: Image.Image, fp: IO[bytes], filename: str | bytes) -> None:
|
||||||
fp.write(o8(channels))
|
fp.write(o8(channels))
|
||||||
fp.write(o8(colorspace))
|
fp.write(o8(colorspace))
|
||||||
|
|
||||||
ImageFile._save(im, fp, [ImageFile._Tile("qoi", (0, 0) + im.size, 0, im.mode)])
|
ImageFile._save(im, fp, [ImageFile._Tile("qoi", (0, 0) + im.size)])
|
||||||
|
|
||||||
|
|
||||||
class QoiEncoder(ImageFile.PyEncoder):
|
class QoiEncoder(ImageFile.PyEncoder):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user