66
77from PIL import Image , JpegXlImagePlugin , features
88
9- from .helper import assert_image_similar_tofile , skip_unless_feature
9+ from .helper import (
10+ assert_image_equal_tofile ,
11+ assert_image_similar_tofile ,
12+ skip_unless_feature ,
13+ )
1014
1115try :
1216 from PIL import _jpegxl
@@ -34,12 +38,18 @@ def test_version(self) -> None:
3438 assert version is not None
3539 assert re .search (r"\d+\.\d+\.\d+$" , version )
3640
37- def test_read_rgb (self ) -> None :
38- """
39- Can we read an RGB mode JPEG XL file without error?
40- Does it have the bits we expect?
41- """
41+ def test_read_1 (self ) -> None :
42+ with Image .open ("Tests/images/jxl/hopper_bw_500.jxl" ) as im :
43+ assert im .mode == "1"
44+ assert im .size == (500 , 500 )
45+ assert im .format == "JPEG XL"
46+ im .getdata ()
47+
48+ # generated with:
49+ # cjxl hopper_bw_500.jxl hopper_bw_500.jxl
50+ assert_image_equal_tofile (im , "Tests/images/hopper_bw_500.png" )
4251
52+ def test_read_rgb (self ) -> None :
4353 with Image .open ("Tests/images/hopper.jxl" ) as im :
4454 assert im .mode == "RGB"
4555 assert im .size == (128 , 128 )
@@ -63,10 +73,6 @@ def test_read_rgba(self) -> None:
6373 assert_image_similar_tofile (im , "Tests/images/transparent.png" , 1 )
6474
6575 def test_read_i16 (self ) -> None :
66- """
67- Can we read 16-bit Grayscale JPEG XL image?
68- """
69-
7076 with Image .open ("Tests/images/jxl/16bit_subcutaneous.cropped.jxl" ) as im :
7177 assert im .mode == "I;16"
7278 assert im .size == (128 , 64 )
@@ -81,6 +87,5 @@ def test_JpegXlDecode_with_invalid_args(self) -> None:
8187 """
8288 Calling decoder functions with no arguments should result in an error.
8389 """
84-
8590 with pytest .raises (TypeError ):
8691 _jpegxl .JpegXlDecoder ()
0 commit comments