summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjvoisin2019-12-16 14:55:35 -0800
committerjvoisin2019-12-16 14:55:35 -0800
commit7465cedee790439aff799a68e5071ed96c772b61 (patch)
tree24e1fe7aa7d47af272c886eb819df9ead51f35b3
parentf5aef1b391e8c112543a6cebe50e8397b1daf3ca (diff)
Handle tiff images with a .tif extension
-rw-r--r--libmat2/images.py2
-rw-r--r--tests/test_corrupted_files.py9
2 files changed, 11 insertions, 0 deletions
diff --git a/libmat2/images.py b/libmat2/images.py
index 6066b07..2098569 100644
--- a/libmat2/images.py
+++ b/libmat2/images.py
@@ -112,6 +112,8 @@ class GdkPixbufAbstractParser(exiftool.ExiftoolParser):
112 pixbuf = GdkPixbuf.Pixbuf.new_from_file(self.filename) 112 pixbuf = GdkPixbuf.Pixbuf.new_from_file(self.filename)
113 if extension.lower() == '.jpg': 113 if extension.lower() == '.jpg':
114 extension = '.jpeg' # gdk is picky 114 extension = '.jpeg' # gdk is picky
115 elif extension.lower() == '.tif':
116 extension = '.tiff' # gdk is picky
115 try: 117 try:
116 pixbuf.savev(self.output_filename, type=extension[1:], 118 pixbuf.savev(self.output_filename, type=extension[1:],
117 option_keys=[], option_values=[]) 119 option_keys=[], option_values=[])
diff --git a/tests/test_corrupted_files.py b/tests/test_corrupted_files.py
index 6dc80a4..d4b40a5 100644
--- a/tests/test_corrupted_files.py
+++ b/tests/test_corrupted_files.py
@@ -187,6 +187,15 @@ class TestCorruptedFiles(unittest.TestCase):
187 audio.MP3Parser('./tests/data/clean.mp3') 187 audio.MP3Parser('./tests/data/clean.mp3')
188 os.remove('./tests/data/clean.mp3') 188 os.remove('./tests/data/clean.mp3')
189 189
190 def test_wrong_tif(self):
191 shutil.copy('./tests/data/dirty.tiff', './tests/data/clean.tif')
192 p = images.TiffParser('./tests/data/clean.tif')
193 p.remove_all()
194 p = images.TiffParser('./tests/data/clean.cleaned.tif')
195 self.assertEqual(p.get_meta(), {})
196 os.remove('./tests/data/clean.tif')
197 os.remove('./tests/data/clean.cleaned.tif')
198
190 def test_jpg(self): 199 def test_jpg(self):
191 shutil.copy('./tests/data/dirty.mp3', './tests/data/clean.jpg') 200 shutil.copy('./tests/data/dirty.mp3', './tests/data/clean.jpg')
192 with self.assertRaises(ValueError): 201 with self.assertRaises(ValueError):