diff options
| author | jvoisin | 2018-05-06 21:58:31 +0200 |
|---|---|---|
| committer | jvoisin | 2018-05-06 21:58:31 +0200 |
| commit | b02d72887afd4498b03cdd767ca46676fb150622 (patch) | |
| tree | 9e10596ac428a4fce2b7da14ee8fb972ff826a68 /src/images.py | |
| parent | 459e9b82f76d9aa5c93c288d2ce7b8be34c601b4 (diff) | |
Test for faulty files, and document how MAT2 is behaving wrt. them
Diffstat (limited to 'src/images.py')
| -rw-r--r-- | src/images.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/images.py b/src/images.py index 7c1abaa..6cc3dfe 100644 --- a/src/images.py +++ b/src/images.py | |||
| @@ -20,6 +20,13 @@ class PNGParser(abstract.AbstractParser): | |||
| 20 | 'Compression', 'Filter', 'Interlace', 'BackgroundColor', 'ImageSize', | 20 | 'Compression', 'Filter', 'Interlace', 'BackgroundColor', 'ImageSize', |
| 21 | 'Megapixels', 'ImageHeight'} | 21 | 'Megapixels', 'ImageHeight'} |
| 22 | 22 | ||
| 23 | def __init__(self, filename): | ||
| 24 | super().__init__(filename) | ||
| 25 | try: # better fail here than later | ||
| 26 | cairo.ImageSurface.create_from_png(self.filename) | ||
| 27 | except MemoryError: | ||
| 28 | raise ValueError | ||
| 29 | |||
| 23 | def get_meta(self): | 30 | def get_meta(self): |
| 24 | out = subprocess.check_output(['/usr/bin/exiftool', '-json', self.filename]) | 31 | out = subprocess.check_output(['/usr/bin/exiftool', '-json', self.filename]) |
| 25 | meta = json.loads(out.decode('utf-8'))[0] | 32 | meta = json.loads(out.decode('utf-8'))[0] |
