Skip to content
Snippets Groups Projects
Commit 433609f8 authored by Julien (jvoisin) Voisin's avatar Julien (jvoisin) Voisin
Browse files

Implement .gif support

parent e8c1bb0e
No related branches found
No related tags found
No related merge requests found
......@@ -42,6 +42,21 @@ class PNGParser(exiftool.ExiftoolParser):
return True
class GIFParser(exiftool.ExiftoolParser):
mimetypes = {'image/gif'}
meta_whitelist = {'AnimationIterations', 'BackgroundColor', 'BitsPerPixel',
'ColorResolutionDepth', 'Directory', 'Duration',
'ExifToolVersion', 'FileAccessDate',
'FileInodeChangeDate', 'FileModifyDate', 'FileName',
'FilePermissions', 'FileSize', 'FileType',
'FileTypeExtension', 'FrameCount', 'GIFVersion',
'HasColorMap', 'ImageHeight', 'ImageSize', 'ImageWidth',
'MIMEType', 'Megapixels', 'SourceFile',}
def remove_all(self) -> bool:
return self._lightweight_cleanup()
class GdkPixbufAbstractParser(exiftool.ExiftoolParser):
""" GdkPixbuf can handle a lot of surfaces, so we're rending images on it,
this has the side-effect of completely removing metadata.
......
tests/data/dirty.gif

1.1 KiB

......@@ -171,6 +171,12 @@ class TestGetMeta(unittest.TestCase):
meta = p.get_meta()
self.assertEqual(meta['EncodingSettings'], 'Lavf52.103.0')
def test_gif(self):
p, mimetype = parser_factory.get_parser('./tests/data/dirty.gif')
self.assertEqual(mimetype, 'image/gif')
meta = p.get_meta()
self.assertEqual(meta['Comment'], 'this is a test comment')
class TestRemovingThumbnails(unittest.TestCase):
def test_odt(self):
shutil.copy('./tests/data/revision.odt', './tests/data/clean.odt')
......@@ -572,3 +578,21 @@ class TestCleaning(unittest.TestCase):
os.remove('./tests/data/clean.wmv')
os.remove('./tests/data/clean.cleaned.wmv')
os.remove('./tests/data/clean.cleaned.cleaned.wmv')
def test_gif(self):
shutil.copy('./tests/data/dirty.gif', './tests/data/clean.gif')
p = images.GIFParser('./tests/data/clean.gif')
meta = p.get_meta()
self.assertEqual(meta['Comment'], 'this is a test comment')
ret = p.remove_all()
self.assertTrue(ret)
p = images.GIFParser('./tests/data/clean.cleaned.gif')
self.assertNotIn('EncodingSettings', p.get_meta())
self.assertTrue(p.remove_all())
os.remove('./tests/data/clean.gif')
os.remove('./tests/data/clean.cleaned.gif')
os.remove('./tests/data/clean.cleaned.cleaned.gif')
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