summaryrefslogtreecommitdiff
path: root/lib/images.py
blob: 3eb354490bf2da776dda6a01c207f93467998af0 (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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
'''
    Takes care about pictures formats
'''

import parser


class JpegStripper(parser.GenericParser):
    '''
        represents a jpeg file
        remaining :
        http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/CanonRaw.html
    '''
    def _should_remove(self, field):
        '''
            return True if the field is compromizing
        '''
        name = field.name
        if name.startswith('comment'):
            return True
        elif name in ('photoshop', 'exif', 'adobe', 'app12'):
            return True
        elif name in ('icc'):  # should we remove the icc profile ?
            return True
        else:
            return False


class PngStripper(parser.GenericParser):
    '''
        represents a png file
        see : http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/PNG.html
    '''
    def _should_remove(self, field):
        '''
            return True if the field is compromizing
        '''
        name = field.name
        if name.startswith('text['):  # textual meta
            return True
        elif name.startswith('utf8_text['):  # uncompressed adobe crap
            return True
        elif name.startswith('compt_text['):  # compressed adobe crap
            return True
        elif name == "time":  # timestamp
            return True
        else:
            return False