diff options
| author | jvoisin | 2018-04-01 00:43:36 +0200 |
|---|---|---|
| committer | jvoisin | 2018-04-01 00:43:36 +0200 |
| commit | 2d7c703c52cae50034fc9618c72552365f7cc741 (patch) | |
| tree | c6fcd139ea0ea5d6970f8a5bb53b1bf719f222e4 /src/jpg.py | |
| parent | c186fc42929b2660e5c507adeb8a8fb406593b11 (diff) | |
Add support for .tiff files
Diffstat (limited to 'src/jpg.py')
| -rw-r--r-- | src/jpg.py | 30 |
1 files changed, 0 insertions, 30 deletions
diff --git a/src/jpg.py b/src/jpg.py deleted file mode 100644 index 34fc04c..0000000 --- a/src/jpg.py +++ /dev/null | |||
| @@ -1,30 +0,0 @@ | |||
| 1 | import subprocess | ||
| 2 | import json | ||
| 3 | |||
| 4 | import gi | ||
| 5 | gi.require_version('GdkPixbuf', '2.0') | ||
| 6 | from gi.repository import GdkPixbuf | ||
| 7 | |||
| 8 | from . import abstract | ||
| 9 | |||
| 10 | class JPGParser(abstract.AbstractParser): | ||
| 11 | mimetypes = {'image/jpg', } | ||
| 12 | meta_whitelist = {'SourceFile', 'ExifToolVersion', 'FileName', | ||
| 13 | 'Directory', 'FileSize', 'FileModifyDate', 'FileAccessDate', | ||
| 14 | "FileInodeChangeDate", 'FilePermissions', 'FileType', | ||
| 15 | 'FileTypeExtension', 'MIMEType', 'ImageWidth', | ||
| 16 | 'ImageSize', 'BitsPerSample', 'ColorComponents', 'EncodingProcess', | ||
| 17 | 'JFIFVersion', 'ResolutionUnit', 'XResolution', 'YCbCrSubSampling', | ||
| 18 | 'YResolution', 'Megapixels', 'ImageHeight'} | ||
| 19 | |||
| 20 | def get_meta(self): | ||
| 21 | out = subprocess.check_output(['exiftool', '-json', self.filename]) | ||
| 22 | meta = json.loads(out.decode('utf-8'))[0] | ||
| 23 | for key in self.meta_whitelist: | ||
| 24 | meta.pop(key, None) | ||
| 25 | return meta | ||
| 26 | |||
| 27 | def remove_all(self): | ||
| 28 | pixbuf = GdkPixbuf.Pixbuf.new_from_file(self.filename) | ||
| 29 | pixbuf.savev(self.output_filename, "jpeg", ["quality"], ["100"]) | ||
| 30 | return True | ||
