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:
parent
4b92bef219
commit
e34bc19f71
@ -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
BIN
tests/data/dirty.bmp
Normal file
Binary file not shown.
After Width: | Height: | Size: 5.6 KiB |
@ -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')
|
||||
|
Loading…
Reference in New Issue
Block a user