File tree Expand file tree Collapse file tree 5 files changed +41
-2
lines changed Expand file tree Collapse file tree 5 files changed +41
-2
lines changed Original file line number Diff line number Diff line change 6666- **xcf ** - ``image/x-xcf ``
6767- **jpg ** - ``image/jpeg ``
6868- **jpx ** - ``image/jpx ``
69+ - **jxl ** - ``image/jxl ``
6970- **png ** - ``image/png ``
7071- **apng ** - ``image/apng ``
7172- **gif ** - ``image/gif ``
161162- **otf ** - ``application/font-sfnt ``
162163
163164Application
164- ^^^^^^^^^^^
165+ ^^^^^^^^^^^
165166
166167- **wasm ** - ``application/wasm ``
167168
Original file line number Diff line number Diff line change 1717 image .Xcf (),
1818 image .Jpeg (),
1919 image .Jpx (),
20+ image .Jxl (),
2021 image .Apng (),
2122 image .Png (),
2223 image .Gif (),
Original file line number Diff line number Diff line change @@ -48,6 +48,38 @@ def match(self, buf):
4848 )
4949
5050
51+ class Jxl (Type ):
52+ """
53+ Implements the JPEG XL image type matcher.
54+ """
55+
56+ MIME = "image/jxl"
57+ EXTENSION = "jxl"
58+
59+ def __init__ (self ):
60+ super (Jxl , self ).__init__ (mime = Jxl .MIME , extension = Jxl .EXTENSION )
61+
62+ def match (self , buf ):
63+ return (
64+ (len (buf ) > 1 and
65+ buf [0 ] == 0xFF and
66+ buf [1 ] == 0x0A ) or
67+ (len (buf ) > 11 and
68+ buf [0 ] == 0x00 and
69+ buf [1 ] == 0x00 and
70+ buf [2 ] == 0x00 and
71+ buf [3 ] == 0x00 and
72+ buf [4 ] == 0x0C and
73+ buf [5 ] == 0x4A and
74+ buf [6 ] == 0x58 and
75+ buf [7 ] == 0x4C and
76+ buf [8 ] == 0x20 and
77+ buf [9 ] == 0x0D and
78+ buf [10 ] == 0x87 and
79+ buf [11 ] == 0x0A )
80+ )
81+
82+
5183class Apng (Type ):
5284 """
5385 Implements the APNG image type matcher.
Original file line number Diff line number Diff line change @@ -32,6 +32,12 @@ def test_guess_jpx(self):
3232 self .assertEqual (kind .mime , 'image/jpx' )
3333 self .assertEqual (kind .extension , 'jpx' )
3434
35+ def test_guess_jxl (self ):
36+ kind = filetype .guess (FIXTURES + '/sample.jxl' )
37+ self .assertTrue (kind is not None )
38+ self .assertEqual (kind .mime , 'image/jxl' )
39+ self .assertEqual (kind .extension , 'jxl' )
40+
3541 def test_guess_gif (self ):
3642 kind = filetype .guess (FIXTURES + '/sample.gif' )
3743 self .assertTrue (kind is not None )
@@ -56,7 +62,6 @@ def test_guess_m4a(self):
5662 self .assertEqual (kind .mime , 'audio/mp4' )
5763 self .assertEqual (kind .extension , 'm4a' )
5864
59-
6065 def test_guess_mp4 (self ):
6166 kind = filetype .guess (FIXTURES + '/sample.mp4' )
6267 self .assertTrue (kind is not None )
You can’t perform that action at this time.
0 commit comments