mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-07-12 01:02:39 +03:00
Use member names to initialize module
This commit is contained in:
parent
05aee33c5e
commit
6c3f0b5ad2
|
@ -41,31 +41,31 @@ class TestFileJpegXl:
|
|||
Does it have the bits we expect?
|
||||
"""
|
||||
|
||||
with Image.open("Tests/images/hopper.jxl") as image:
|
||||
assert image.mode == "RGB"
|
||||
assert image.size == (128, 128)
|
||||
assert image.format == "JPEG XL"
|
||||
image.load()
|
||||
image.getdata()
|
||||
with Image.open("Tests/images/hopper.jxl") as im:
|
||||
assert im.mode == "RGB"
|
||||
assert im.size == (128, 128)
|
||||
assert im.format == "JPEG XL"
|
||||
im.load()
|
||||
im.getdata()
|
||||
|
||||
# generated with:
|
||||
# djxl hopper.jxl hopper_jxl_bits.ppm
|
||||
assert_image_similar_tofile(image, "Tests/images/hopper_jxl_bits.ppm", 1)
|
||||
assert_image_similar_tofile(im, "Tests/images/hopper_jxl_bits.ppm", 1)
|
||||
|
||||
def test_read_i16(self) -> None:
|
||||
"""
|
||||
Can we read 16-bit Grayscale Jpeg XL image?
|
||||
"""
|
||||
|
||||
with Image.open("Tests/images/jxl/16bit_subcutaneous.cropped.jxl") as image:
|
||||
assert image.mode == "I;16"
|
||||
assert image.size == (128, 64)
|
||||
assert image.format == "JPEG XL"
|
||||
image.load()
|
||||
image.getdata()
|
||||
with Image.open("Tests/images/jxl/16bit_subcutaneous.cropped.jxl") as im:
|
||||
assert im.mode == "I;16"
|
||||
assert im.size == (128, 64)
|
||||
assert im.format == "JPEG XL"
|
||||
im.load()
|
||||
im.getdata()
|
||||
|
||||
assert_image_similar_tofile(
|
||||
image, "Tests/images/jxl/16bit_subcutaneous.cropped.png", 1
|
||||
im, "Tests/images/jxl/16bit_subcutaneous.cropped.png", 1
|
||||
)
|
||||
|
||||
def test_JpegXlDecode_with_invalid_args(self) -> None:
|
||||
|
|
|
@ -27,18 +27,17 @@ except ImportError:
|
|||
|
||||
|
||||
def test_read_exif_metadata() -> None:
|
||||
with Image.open("Tests/images/flower.jxl") as image:
|
||||
assert image.format == "JPEG XL"
|
||||
exif_data = image.info.get("exif", None)
|
||||
assert exif_data
|
||||
with Image.open("Tests/images/flower.jxl") as im:
|
||||
assert im.format == "JPEG XL"
|
||||
exif_data = im.info["exif"]
|
||||
|
||||
exif = image.getexif()
|
||||
exif = im.getexif()
|
||||
|
||||
# Camera make
|
||||
assert exif[271] == "Canon"
|
||||
|
||||
with Image.open("Tests/images/flower.jpg") as jpeg_image:
|
||||
expected_exif = jpeg_image.info["exif"]
|
||||
with Image.open("Tests/images/flower.jpg") as im_jpeg:
|
||||
expected_exif = im_jpeg.info["exif"]
|
||||
|
||||
# jpeg xl always returns exif without 'Exif\0\0' prefix
|
||||
assert exif_data == expected_exif[6:]
|
||||
|
@ -54,14 +53,12 @@ def test_read_exif_metadata_without_prefix() -> None:
|
|||
|
||||
|
||||
def test_read_icc_profile() -> None:
|
||||
with Image.open("Tests/images/flower2.jxl") as image:
|
||||
assert image.format == "JPEG XL"
|
||||
assert image.info.get("icc_profile", None)
|
||||
with Image.open("Tests/images/flower2.jxl") as im:
|
||||
assert im.format == "JPEG XL"
|
||||
icc = im.info["icc_profile"]
|
||||
|
||||
icc = image.info["icc_profile"]
|
||||
|
||||
with Image.open("Tests/images/flower2.jxl") as jpeg_image:
|
||||
expected_icc = jpeg_image.info["icc_profile"]
|
||||
with Image.open("Tests/images/flower2.jxl") as im_jpeg:
|
||||
expected_icc = im_jpeg.info["icc_profile"]
|
||||
|
||||
assert icc == expected_icc
|
||||
|
||||
|
@ -114,10 +111,10 @@ def test_4_byte_exif(monkeypatch: pytest.MonkeyPatch) -> None:
|
|||
|
||||
monkeypatch.setattr(JpegXlImagePlugin, "_jpegxl", _mock_jpegxl)
|
||||
|
||||
with Image.open("Tests/images/hopper.jxl") as image:
|
||||
assert "exif" not in image.info
|
||||
with Image.open("Tests/images/hopper.jxl") as im:
|
||||
assert "exif" not in im.info
|
||||
|
||||
|
||||
def test_read_exif_metadata_empty() -> None:
|
||||
with Image.open("Tests/images/hopper.jxl") as image:
|
||||
assert image.getexif() == {}
|
||||
with Image.open("Tests/images/hopper.jxl") as im:
|
||||
assert im.getexif() == {}
|
||||
|
|
|
@ -635,7 +635,6 @@ setup_module(PyObject *m) {
|
|||
|
||||
// TODO(oloke) ready object types?
|
||||
PyObject *d = PyModule_GetDict(m);
|
||||
|
||||
PyObject *v = PyUnicode_FromString(JpegXlDecoderVersion_str());
|
||||
PyDict_SetItemString(d, "libjxl_version", v ? v : Py_None);
|
||||
Py_XDECREF(v);
|
||||
|
@ -649,10 +648,9 @@ PyInit__jpegxl(void) {
|
|||
|
||||
static PyModuleDef module_def = {
|
||||
PyModuleDef_HEAD_INIT,
|
||||
"_jpegxl", /* m_name */
|
||||
NULL, /* m_doc */
|
||||
-1, /* m_size */
|
||||
jpegxlMethods, /* m_methods */
|
||||
.m_name = "_jpegxl",
|
||||
.m_size = -1,
|
||||
.m_methods = jpegxlMethods,
|
||||
};
|
||||
|
||||
m = PyModule_Create(&module_def);
|
||||
|
|
Loading…
Reference in New Issue
Block a user