From fb550678117a6963539b864a18b904021e619dc5 Mon Sep 17 00:00:00 2001 From: jvoisin Date: Tue, 21 Jul 2015 21:37:32 +0200 Subject: Remove the pillow stuff, because it was a bad idea. Pillow sucks at parsing malformed pictures :/ --- libmat/exiftool.py | 4 +--- libmat/images.py | 16 ++-------------- libmat/pillow.py | 27 --------------------------- 3 files changed, 3 insertions(+), 44 deletions(-) delete mode 100644 libmat/pillow.py (limited to 'libmat') diff --git a/libmat/exiftool.py b/libmat/exiftool.py index 366ab12..3efd4f2 100644 --- a/libmat/exiftool.py +++ b/libmat/exiftool.py @@ -4,10 +4,9 @@ import subprocess import parser -import pillow -class ExiftoolStripper(parser.GenericParser, pillow.PillowStripper): +class ExiftoolStripper(parser.GenericParser): ''' A generic stripper class using exiftool as backend ''' @@ -27,7 +26,6 @@ class ExiftoolStripper(parser.GenericParser, pillow.PillowStripper): def remove_all(self): ''' Remove all metadata with help of exiftool ''' - self.open_and_save() try: if self.backup: self.create_backup_copy() diff --git a/libmat/images.py b/libmat/images.py index 2daea88..67c710f 100644 --- a/libmat/images.py +++ b/libmat/images.py @@ -7,21 +7,9 @@ References: ''' import parser -import pillow -class ImageStripper(parser.GenericParser, pillow.PillowStripper): - ''' Common stripper for images. - Its purpose is to open then save - images with PIL, the goal being to remove - unknown metadata. - ''' - def remove_all(self): - self.open_and_save() - super(ImageStripper, self).remove_all() - - -class JpegStripper(ImageStripper): +class JpegStripper(parser.GenericParser): ''' Represents a jpeg file. Custom Huffman and Quantization tables are stripped: they may leak @@ -46,7 +34,7 @@ class JpegStripper(ImageStripper): return True -class PngStripper(ImageStripper): +class PngStripper(parser.GenericParser): ''' Represents a png file ''' def _should_remove(self, field): diff --git a/libmat/pillow.py b/libmat/pillow.py deleted file mode 100644 index 5406b8b..0000000 --- a/libmat/pillow.py +++ /dev/null @@ -1,27 +0,0 @@ -''' Care about images with help of PIL. -This class doesn't remove metadata in the "conventional way"; -it opens, then saves the image. This should remove unknown metadata. -''' - -# FIXME Implement this with a decorator instead - -import parser - - -class PillowStripper(object): - ''' This class implements a single method, "open_and_save". - It's a class instead of a function so it can be inherited. - ''' - def open_and_save(self): - ''' Open and save the image with PIL. - This should remove a lot of unknown metadata. - ''' - try: - from PIL import Image - except ImportError: - logging.error('Unable to import PIL, image support degraded. Be careful.') - - try: - Image.open(self.filename).save(self.filename, exif='') - except IOError: - logging.error('Can not save %s.' % self.filename) -- cgit v1.3