Skip to content

Commit

Permalink
Merge pull request #153 from CatKasha/qoi
Browse files Browse the repository at this point in the history
add QOI support
  • Loading branch information
h2non committed Nov 17, 2023
2 parents 017eb95 + 450f096 commit 590dac5
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ Image
- **ico** - ``image/x-icon``
- **heic** - ``image/heic``
- **avif** - ``image/avif``
- **qoi** - ``image/qoi``

Video
^^^^^
Expand Down
1 change: 1 addition & 0 deletions filetype/types/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
image.Heic(),
image.Dcm(),
image.Avif(),
image.Qoi(),
)

# Supported video types
Expand Down
21 changes: 21 additions & 0 deletions filetype/types/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -381,3 +381,24 @@ def match(self, buf):
if major_brand in ['mif1', 'msf1'] and 'avif' in compatible_brands:
return True
return False


class Qoi(Type):
"""
Implements the QOI image type matcher.
"""
MIME = 'image/qoi'
EXTENSION = 'qoi'

def __init__(self):
super(Qoi, self).__init__(
mime=Qoi.MIME,
extension=Qoi.EXTENSION
)

def match(self, buf):
return (len(buf) > 3 and
buf[0] == 0x71 and
buf[1] == 0x6F and
buf[2] == 0x69 and
buf[3] == 0x66)

0 comments on commit 590dac5

Please sign in to comment.