summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mat/exiftool.py44
-rw-r--r--mat/mat.py9
2 files changed, 44 insertions, 9 deletions
diff --git a/mat/exiftool.py b/mat/exiftool.py
index d9c938a..7cd279a 100644
--- a/mat/exiftool.py
+++ b/mat/exiftool.py
@@ -4,17 +4,53 @@
4 4
5import subprocess 5import subprocess
6import images 6import images
7import parser
8 7
9class Jpeg_Stripper(images.JpegStripper): 8
9class JpegStripper(images.JpegStripper):
10 ''' 10 '''
11 Care about jpeg files with help 11 Care about jpeg files with help
12 of exiftool 12 of exiftool
13 ''' 13 '''
14 ALLOWED = ['ExifTool Version Number', 'File Name', 'Directory',
15 'File Size', 'File Modification Date/Time', 'File Permissions',
16 'File Type', 'MIME Type', 'JFIF Version', 'Resolution Unit',
17 'X Resolution', 'Y Resolution', 'Image Width', 'Image Height',
18 'Encoding Process', 'Bits Per Sample', 'Color Components',
19 'Y Cb Cr Sub Sampling', 'Image Size']
20
14 def remove_all(self): 21 def remove_all(self):
15 ''' 22 '''
16 Remove all metadata with help of exiftool 23 Remove all metadata with help of exiftool
17 ''' 24 '''
18 subprocess.Popen(['exiftool', '-filename=', self.output, 25 if self.backup:
19 '-all= ', self.filename]) 26 process = subprocess.Popen(['exiftool', '-all=',
27 '-o %s' % self.output, self.filename])
28 #, stdout=open('/dev/null'))
29 process.wait()
30 else:
31 process = subprocess.Popen(['exiftool', '-overwrite_original',
32 '-all=', self.filename]) # , stdout=open('/dev/null'))
33 process.wait()
34
35 def is_clean(self):
36 '''
37 Check if the file is clean
38 '''
39 out = subprocess.Popen(['exiftool', self.filename],
40 stdout=subprocess.PIPE).communicate()[0]
41 out = out.split('\n')
42 for i in out[:-1]:
43 if i.split(':')[0].strip() not in self.ALLOWED:
44 return False
45 return True
20 46
47 def get_meta(self): # FIXME: UGLY
48 out = subprocess.Popen(['exiftool', self.filename],
49 stdout=subprocess.PIPE).communicate()[0]
50 out = out.split('\n')
51 meta = {}
52 for i in out[:-1]:
53 key = i.split(':')[0].strip()
54 if key not in self.ALLOWED:
55 meta[key] = i.split(':')[1].strip()
56 return meta
diff --git a/mat/mat.py b/mat/mat.py
index 0b75ba6..1700561 100644
--- a/mat/mat.py
+++ b/mat/mat.py
@@ -54,13 +54,12 @@ except ImportError:
54 print('Unable to import python-mutagen: limited audio format support') 54 print('Unable to import python-mutagen: limited audio format support')
55 55
56try: 56try:
57 #FIXME : WIP 57 subprocess.Popen('exiftool', stdout=open('/dev/null'))
58 subprocess.Popen('exiftool_', stdout=open('/dev/null'))
59 import exiftool 58 import exiftool
60 #STRIPPERS['image/jpeg'] = exiftool.JpegStripper 59 STRIPPERS['image/jpeg'] = exiftool.JpegStripper
61 #STRIPPERS['image/png'] = exiftool.PngStripper 60 STRIPPERS['image/png'] = images.PngStripper
62except: 61except:
63 #print('Unable to find exiftool: limited images support') 62 print('Unable to find exiftool: limited images support')
64 STRIPPERS['image/jpeg'] = images.JpegStripper 63 STRIPPERS['image/jpeg'] = images.JpegStripper
65 STRIPPERS['image/png'] = images.PngStripper 64 STRIPPERS['image/png'] = images.PngStripper
66 65