1
0
mirror of synced 2024-12-22 04:39:58 +01:00

Add support for BMP

To be completely honest, BMP have no metadata,
but we still add it, just in case™
This commit is contained in:
jvoisin 2018-04-16 22:27:29 +02:00
parent 4b92bef219
commit e34bc19f71
3 changed files with 29 additions and 0 deletions

View File

@ -75,3 +75,17 @@ class TiffParser(GdkPixbufAbstractParser):
'FileTypeExtension', 'ImageHeight', 'ImageSize', 'ImageWidth',
'MIMEType', 'Megapixels', 'SourceFile'}
class BMPParser(GdkPixbufAbstractParser):
mimetypes = {'image/bmp', 'image/x-ms-bmp'}
meta_whitelist = {'SourceFile', 'ExifToolVersion', 'FileName', 'Directory',
'FileSize', 'FileModifyDate', 'FileAccessDate',
'FileInodeChangeDate', 'FilePermissions', 'FileType',
'FileTypeExtension', 'MIMEType', 'BMPVersion', 'ImageWidth',
'ImageHeight', 'Planes', 'BitDepth', 'Compression', 'ImageLength',
'PixelsPerMeterX', 'PixelsPerMeterY', 'NumColors',
'NumImportantColors', 'RedMask', 'GreenMask', 'BlueMask',
'AlphaMask', 'ColorSpace', 'RedEndpoint', 'GreenEndpoint',
'BlueEndpoint', 'GammaRed', 'GammaGreen', 'GammaBlue', 'ImageSize',
'Megapixels'}

BIN
tests/data/dirty.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.6 KiB

View File

@ -307,3 +307,18 @@ class TestCleaning(unittest.TestCase):
self.assertEqual(p.get_meta(), {})
os.remove('./tests/data/clean.tiff')
def test_bmp(self):
shutil.copy('./tests/data/dirty.bmp', './tests/data/clean.bmp')
p = images.BMPParser('./tests/data/clean.bmp')
meta = p.get_meta()
self.assertEqual(meta, {}) # bmp has no meta :)
ret = p.remove_all()
self.assertTrue(ret)
p = images.BMPParser('./tests/data/clean.bmp.cleaned')
self.assertEqual(p.get_meta(), {})
os.remove('./tests/data/clean.bmp')