Skip to content

Commit cd3441f

Browse files
authored
Merge pull request #172 from isatsam/master
Add support for DDS
2 parents d13ef9b + 97b250e commit cd3441f

File tree

5 files changed

+25
-0
lines changed

5 files changed

+25
-0
lines changed

README.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ Image
8080
- **heic** - ``image/heic``
8181
- **avif** - ``image/avif``
8282
- **qoi** - ``image/qoi``
83+
- **dds** - ``image/dds``
8384

8485
Video
8586
^^^^^

filetype/types/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
image.Dcm(),
3333
image.Avif(),
3434
image.Qoi(),
35+
image.Dds(),
3536
)
3637

3738
# Supported video types

filetype/types/image.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -434,3 +434,20 @@ def match(self, buf):
434434
buf[1] == 0x6F and
435435
buf[2] == 0x69 and
436436
buf[3] == 0x66)
437+
438+
439+
class Dds(Type):
440+
"""
441+
Implements the DDS image type matcher.
442+
"""
443+
MIME = 'image/dds'
444+
EXTENSION = 'dds'
445+
446+
def __init__(self):
447+
super(Dds, self).__init__(
448+
mime=Dds.MIME,
449+
extension=Dds.EXTENSION
450+
)
451+
452+
def match(self, buf):
453+
return buf.startswith(b'\x44\x44\x53\x20')

tests/fixtures/sample.dds

2.8 KB
Binary file not shown.

tests/test_types.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,12 @@ def test_guess_avif(self):
5656
self.assertEqual(kind.mime, 'image/avif')
5757
self.assertEqual(kind.extension, 'avif')
5858

59+
def test_guess_dds(self):
60+
kind = filetype.guess(FIXTURES + '/sample.dds')
61+
self.assertTrue(kind is not None)
62+
self.assertEqual(kind.mime, 'image/dds')
63+
self.assertEqual(kind.extension, 'dds')
64+
5965
def test_guess_m4a(self):
6066
kind = filetype.guess(FIXTURES + '/sample.m4a')
6167
self.assertTrue(kind is not None)

0 commit comments

Comments
 (0)