blob: 5406b8b60f3b43c27c8d837d18d2145582ae8701 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
''' 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)
|