diff options
| -rw-r--r-- | mat/exiftool.py | 20 | ||||
| -rw-r--r-- | mat/mat.py | 14 |
2 files changed, 31 insertions, 3 deletions
diff --git a/mat/exiftool.py b/mat/exiftool.py new file mode 100644 index 0000000..970ef3e --- /dev/null +++ b/mat/exiftool.py | |||
| @@ -0,0 +1,20 @@ | |||
| 1 | ''' | ||
| 2 | Care about images with help of the amazing (perl) library Exiftool. | ||
| 3 | ''' | ||
| 4 | |||
| 5 | import subprocess | ||
| 6 | import images | ||
| 7 | import parser | ||
| 8 | |||
| 9 | class JpegStripper(parser.GenericParser): | ||
| 10 | ''' | ||
| 11 | Care about jpeg files with help | ||
| 12 | of exiftool | ||
| 13 | ''' | ||
| 14 | def remove_all(self): | ||
| 15 | ''' | ||
| 16 | Remove all metadata with help of exiftool | ||
| 17 | ''' | ||
| 18 | subprocess.Popen('exiftool -filename=%s -all= %s' % | ||
| 19 | (self.output, self.filename)) | ||
| 20 | |||
| @@ -32,8 +32,6 @@ STRIPPERS = { | |||
| 32 | 'application/x-bzip2': archive.Bzip2Stripper, | 32 | 'application/x-bzip2': archive.Bzip2Stripper, |
| 33 | 'application/zip': archive.ZipStripper, | 33 | 'application/zip': archive.ZipStripper, |
| 34 | 'audio/mpeg': audio.MpegAudioStripper, | 34 | 'audio/mpeg': audio.MpegAudioStripper, |
| 35 | 'image/jpeg': images.JpegStripper, | ||
| 36 | 'image/png': images.PngStripper, | ||
| 37 | 'application/x-bittorrent': misc.TorrentStripper, | 35 | 'application/x-bittorrent': misc.TorrentStripper, |
| 38 | 'application/opendocument': office.OpenDocumentStripper, | 36 | 'application/opendocument': office.OpenDocumentStripper, |
| 39 | 'application/officeopenxml': office.OpenXmlStripper, | 37 | 'application/officeopenxml': office.OpenXmlStripper, |
| @@ -53,7 +51,17 @@ try: | |||
| 53 | STRIPPERS['audio/x-flac'] = audio.FlacStripper | 51 | STRIPPERS['audio/x-flac'] = audio.FlacStripper |
| 54 | STRIPPERS['audio/vorbis'] = audio.OggStripper | 52 | STRIPPERS['audio/vorbis'] = audio.OggStripper |
| 55 | except ImportError: | 53 | except ImportError: |
| 56 | print('unable to import python-mutagen : limited audio format support') | 54 | print('Unable to import python-mutagen: limited audio format support') |
| 55 | |||
| 56 | try: | ||
| 57 | subprocess.Popen('exiftool_', stdout=open('/dev/null')) | ||
| 58 | import exiftool | ||
| 59 | #STRIPPERS['image/jpeg'] = exiftool.JpegStripper | ||
| 60 | #STRIPPERS['image/png'] = exiftool.PngStripper | ||
| 61 | except: | ||
| 62 | #print('Unable to find exiftool: limited images support') | ||
| 63 | STRIPPERS['image/jpeg'] = images.JpegStripper | ||
| 64 | STRIPPERS['image/png'] = images.PngStripper | ||
| 57 | 65 | ||
| 58 | 66 | ||
| 59 | class XMLParser(xml.sax.handler.ContentHandler): | 67 | class XMLParser(xml.sax.handler.ContentHandler): |
