Add webp support
This commit is contained in:
parent
29f404bce3
commit
2b58eece50
@ -196,3 +196,15 @@ class HEICParser(exiftool.ExiftoolParser):
|
|||||||
|
|
||||||
def remove_all(self) -> bool:
|
def remove_all(self) -> bool:
|
||||||
return self._lightweight_cleanup()
|
return self._lightweight_cleanup()
|
||||||
|
|
||||||
|
class WEBPParser(GdkPixbufAbstractParser):
|
||||||
|
mimetypes = {'image/webp'}
|
||||||
|
meta_allowlist = {'SourceFile', 'ExifToolVersion', 'FileName',
|
||||||
|
'Directory', 'FileSize', 'FileModifyDate',
|
||||||
|
'FileAccessDate', "FileInodeChangeDate",
|
||||||
|
'FilePermissions', 'FileType', 'FileTypeExtension',
|
||||||
|
'MIMEType', 'ImageWidth', 'ImageSize', 'BitsPerSample',
|
||||||
|
'ColorComponents', 'EncodingProcess', 'JFIFVersion',
|
||||||
|
'ResolutionUnit', 'XResolution', 'YCbCrSubSampling',
|
||||||
|
'YResolution', 'Megapixels', 'ImageHeight', 'Orientation',
|
||||||
|
'HorizontalScale', 'VerticalScale', 'VP8Version'}
|
||||||
|
BIN
tests/data/dirty.webp
Normal file
BIN
tests/data/dirty.webp
Normal file
Binary file not shown.
After Width: | Height: | Size: 38 KiB |
@ -236,6 +236,11 @@ class TestGetMeta(unittest.TestCase):
|
|||||||
self.assertIn(b'i am a : various comment', stdout)
|
self.assertIn(b'i am a : various comment', stdout)
|
||||||
self.assertIn(b'artist: jvoisin', stdout)
|
self.assertIn(b'artist: jvoisin', stdout)
|
||||||
|
|
||||||
|
def test_webp(self):
|
||||||
|
proc = subprocess.Popen(mat2_binary + ['--show', './tests/data/dirty.webp'],
|
||||||
|
stdout=subprocess.PIPE)
|
||||||
|
stdout, _ = proc.communicate()
|
||||||
|
self.assertIn(b'Warning: [minor] Improper EXIF header', stdout)
|
||||||
|
|
||||||
class TestControlCharInjection(unittest.TestCase):
|
class TestControlCharInjection(unittest.TestCase):
|
||||||
def test_jpg(self):
|
def test_jpg(self):
|
||||||
|
@ -113,6 +113,11 @@ class TestGetMeta(unittest.TestCase):
|
|||||||
meta = p.get_meta()
|
meta = p.get_meta()
|
||||||
self.assertEqual(meta['Comment'], 'Created with GIMP')
|
self.assertEqual(meta['Comment'], 'Created with GIMP')
|
||||||
|
|
||||||
|
def test_webp(self):
|
||||||
|
p = images.WEBPParser('./tests/data/dirty.webp')
|
||||||
|
meta = p.get_meta()
|
||||||
|
self.assertEqual(meta['Warning'], '[minor] Improper EXIF header')
|
||||||
|
|
||||||
def test_ppm(self):
|
def test_ppm(self):
|
||||||
p = images.PPMParser('./tests/data/dirty.ppm')
|
p = images.PPMParser('./tests/data/dirty.ppm')
|
||||||
meta = p.get_meta()
|
meta = p.get_meta()
|
||||||
@ -333,6 +338,11 @@ class TestCleaning(unittest.TestCase):
|
|||||||
'parser': images.JPGParser,
|
'parser': images.JPGParser,
|
||||||
'meta': {'Comment': 'Created with GIMP'},
|
'meta': {'Comment': 'Created with GIMP'},
|
||||||
'expected_meta': {},
|
'expected_meta': {},
|
||||||
|
}, {
|
||||||
|
'name': 'webp',
|
||||||
|
'parser': images.WEBPParser,
|
||||||
|
'meta': {'Warning': '[minor] Improper EXIF header'},
|
||||||
|
'expected_meta': {},
|
||||||
}, {
|
}, {
|
||||||
'name': 'wav',
|
'name': 'wav',
|
||||||
'parser': audio.WAVParser,
|
'parser': audio.WAVParser,
|
||||||
|
@ -23,6 +23,11 @@ class TestLightWeightCleaning(unittest.TestCase):
|
|||||||
'parser': images.JPGParser,
|
'parser': images.JPGParser,
|
||||||
'meta': {'Comment': 'Created with GIMP'},
|
'meta': {'Comment': 'Created with GIMP'},
|
||||||
'expected_meta': {},
|
'expected_meta': {},
|
||||||
|
}, {
|
||||||
|
'name': 'webp',
|
||||||
|
'parser': images.WEBPParser,
|
||||||
|
'meta': {'Warning': '[minor] Improper EXIF header'},
|
||||||
|
'expected_meta': {},
|
||||||
}, {
|
}, {
|
||||||
'name': 'torrent',
|
'name': 'torrent',
|
||||||
'parser': torrent.TorrentParser,
|
'parser': torrent.TorrentParser,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user