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 66
66
- **xcf ** - ``image/x-xcf ``
67
67
- **jpg ** - ``image/jpeg ``
68
68
- **jpx ** - ``image/jpx ``
69
+ - **jxl ** - ``image/jxl ``
69
70
- **png ** - ``image/png ``
70
71
- **apng ** - ``image/apng ``
71
72
- **gif ** - ``image/gif ``
161
162
- **otf ** - ``application/font-sfnt ``
162
163
163
164
Application
164
- ^^^^^^^^^^^
165
+ ^^^^^^^^^^^
165
166
166
167
- **wasm ** - ``application/wasm ``
167
168
Original file line number Diff line number Diff line change 17
17
image .Xcf (),
18
18
image .Jpeg (),
19
19
image .Jpx (),
20
+ image .Jxl (),
20
21
image .Apng (),
21
22
image .Png (),
22
23
image .Gif (),
Original file line number Diff line number Diff line change @@ -48,6 +48,38 @@ def match(self, buf):
48
48
)
49
49
50
50
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
+
51
83
class Apng (Type ):
52
84
"""
53
85
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):
32
32
self .assertEqual (kind .mime , 'image/jpx' )
33
33
self .assertEqual (kind .extension , 'jpx' )
34
34
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
+
35
41
def test_guess_gif (self ):
36
42
kind = filetype .guess (FIXTURES + '/sample.gif' )
37
43
self .assertTrue (kind is not None )
@@ -56,7 +62,6 @@ def test_guess_m4a(self):
56
62
self .assertEqual (kind .mime , 'audio/mp4' )
57
63
self .assertEqual (kind .extension , 'm4a' )
58
64
59
-
60
65
def test_guess_mp4 (self ):
61
66
kind = filetype .guess (FIXTURES + '/sample.mp4' )
62
67
self .assertTrue (kind is not None )
You can’t perform that action at this time.
0 commit comments