summaryrefslogtreecommitdiff
path: root/src/png.py
diff options
context:
space:
mode:
authorjvoisin2018-03-31 15:46:17 +0200
committerjvoisin2018-03-31 15:46:17 +0200
commitf391c9603c36a8ec80942c23ac6ba39fca5df72a (patch)
tree7fdc2053c01f103a675274ebd3e6abcffba4dfbe /src/png.py
parent088c3d013ce4515920dea5e0becb98b36afa9a31 (diff)
Change a bit the source code organisation
Diffstat (limited to 'src/png.py')
-rw-r--r--src/png.py27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/png.py b/src/png.py
new file mode 100644
index 0000000..377682e
--- /dev/null
+++ b/src/png.py
@@ -0,0 +1,27 @@
1import subprocess
2import json
3
4import cairo
5
6from . import abstract
7
8class PNGParser(abstract.AbstractParser):
9 mimetypes = {'image/png', }
10 meta_whitelist = {'SourceFile', 'ExifToolVersion', 'FileName',
11 'Directory', 'FileSize', 'FileModifyDate', 'FileAccessDate',
12 "FileInodeChangeDate", 'FilePermissions', 'FileType',
13 'FileTypeExtension', 'MIMEType', 'ImageWidth', 'BitDepth', 'ColorType',
14 'Compression', 'Filter', 'Interlace', 'BackgroundColor', 'ImageSize',
15 'Megapixels', 'ImageHeight'}
16
17 def get_meta(self):
18 out = subprocess.check_output(['exiftool', '-json', self.filename])
19 meta = json.loads(out.decode('utf-8'))[0]
20 for key in self.meta_whitelist:
21 meta.pop(key, None)
22 return meta
23
24 def remove_all(self):
25 surface = cairo.ImageSurface.create_from_png(self.filename)
26 surface.write_to_png(self.output_filename)
27 return True