summaryrefslogtreecommitdiff
path: root/src/jpg.py
diff options
context:
space:
mode:
authorjvoisin2018-03-31 15:46:17 +0200
committerjvoisin2018-03-31 15:46:17 +0200
commitf391c9603c36a8ec80942c23ac6ba39fca5df72a (patch)
tree7fdc2053c01f103a675274ebd3e6abcffba4dfbe /src/jpg.py
parent088c3d013ce4515920dea5e0becb98b36afa9a31 (diff)
Change a bit the source code organisation
Diffstat (limited to 'src/jpg.py')
-rw-r--r--src/jpg.py30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/jpg.py b/src/jpg.py
new file mode 100644
index 0000000..34fc04c
--- /dev/null
+++ b/src/jpg.py
@@ -0,0 +1,30 @@
1import subprocess
2import json
3
4import gi
5gi.require_version('GdkPixbuf', '2.0')
6from gi.repository import GdkPixbuf
7
8from . import abstract
9
10class 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