From 7465cedee790439aff799a68e5071ed96c772b61 Mon Sep 17 00:00:00 2001 From: jvoisin Date: Mon, 16 Dec 2019 14:55:35 -0800 Subject: [PATCH] Handle tiff images with a .tif extension --- libmat2/images.py | 2 ++ tests/test_corrupted_files.py | 9 +++++++++ 2 files changed, 11 insertions(+) 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): pixbuf = GdkPixbuf.Pixbuf.new_from_file(self.filename) if extension.lower() == '.jpg': extension = '.jpeg' # gdk is picky + elif extension.lower() == '.tif': + extension = '.tiff' # gdk is picky try: pixbuf.savev(self.output_filename, type=extension[1:], 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): audio.MP3Parser('./tests/data/clean.mp3') os.remove('./tests/data/clean.mp3') + def test_wrong_tif(self): + shutil.copy('./tests/data/dirty.tiff', './tests/data/clean.tif') + p = images.TiffParser('./tests/data/clean.tif') + p.remove_all() + p = images.TiffParser('./tests/data/clean.cleaned.tif') + self.assertEqual(p.get_meta(), {}) + os.remove('./tests/data/clean.tif') + os.remove('./tests/data/clean.cleaned.tif') + def test_jpg(self): shutil.copy('./tests/data/dirty.mp3', './tests/data/clean.jpg') with self.assertRaises(ValueError):