Skip to content

Commit 590dac5

Browse files
authored
Merge pull request h2non#153 from CatKasha/qoi
add QOI support
2 parents 017eb95 + 450f096 commit 590dac5

File tree

3 files changed

+23
-0
lines changed

3 files changed

+23
-0
lines changed

README.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ Image
7878
- **ico** - ``image/x-icon``
7979
- **heic** - ``image/heic``
8080
- **avif** - ``image/avif``
81+
- **qoi** - ``image/qoi``
8182

8283
Video
8384
^^^^^

filetype/types/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
image.Heic(),
3131
image.Dcm(),
3232
image.Avif(),
33+
image.Qoi(),
3334
)
3435

3536
# Supported video types

filetype/types/image.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -381,3 +381,24 @@ def match(self, buf):
381381
if major_brand in ['mif1', 'msf1'] and 'avif' in compatible_brands:
382382
return True
383383
return False
384+
385+
386+
class Qoi(Type):
387+
"""
388+
Implements the QOI image type matcher.
389+
"""
390+
MIME = 'image/qoi'
391+
EXTENSION = 'qoi'
392+
393+
def __init__(self):
394+
super(Qoi, self).__init__(
395+
mime=Qoi.MIME,
396+
extension=Qoi.EXTENSION
397+
)
398+
399+
def match(self, buf):
400+
return (len(buf) > 3 and
401+
buf[0] == 0x71 and
402+
buf[1] == 0x6F and
403+
buf[2] == 0x69 and
404+
buf[3] == 0x66)

0 commit comments

Comments
 (0)