Skip to content
Snippets Groups Projects
Commit 2b58eece authored by Vincent Deffontaines's avatar Vincent Deffontaines Committed by jvoisin
Browse files

Add webp support

parent 29f404bc
No related branches found
No related tags found
No related merge requests found
Pipeline #271410 failed
......@@ -196,3 +196,15 @@ class HEICParser(exiftool.ExiftoolParser):
def remove_all(self) -> bool:
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'}
tests/data/dirty.webp

37.6 KiB

......@@ -236,6 +236,11 @@ class TestGetMeta(unittest.TestCase):
self.assertIn(b'i am a : various comment', 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):
def test_jpg(self):
......
......@@ -113,6 +113,11 @@ class TestGetMeta(unittest.TestCase):
meta = p.get_meta()
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):
p = images.PPMParser('./tests/data/dirty.ppm')
meta = p.get_meta()
......@@ -333,6 +338,11 @@ class TestCleaning(unittest.TestCase):
'parser': images.JPGParser,
'meta': {'Comment': 'Created with GIMP'},
'expected_meta': {},
}, {
'name': 'webp',
'parser': images.WEBPParser,
'meta': {'Warning': '[minor] Improper EXIF header'},
'expected_meta': {},
}, {
'name': 'wav',
'parser': audio.WAVParser,
......
......@@ -23,6 +23,11 @@ class TestLightWeightCleaning(unittest.TestCase):
'parser': images.JPGParser,
'meta': {'Comment': 'Created with GIMP'},
'expected_meta': {},
}, {
'name': 'webp',
'parser': images.WEBPParser,
'meta': {'Warning': '[minor] Improper EXIF header'},
'expected_meta': {},
}, {
'name': 'torrent',
'parser': torrent.TorrentParser,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment