diff options
Diffstat (limited to 'MAT/images.py')
| -rw-r--r-- | MAT/images.py | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/MAT/images.py b/MAT/images.py new file mode 100644 index 0000000..236d566 --- /dev/null +++ b/MAT/images.py | |||
| @@ -0,0 +1,41 @@ | |||
| 1 | ''' | ||
| 2 | Takes care about pictures formats | ||
| 3 | ''' | ||
| 4 | |||
| 5 | import parser | ||
| 6 | |||
| 7 | |||
| 8 | class JpegStripper(parser.GenericParser): | ||
| 9 | ''' | ||
| 10 | represents a jpeg file | ||
| 11 | ''' | ||
| 12 | def _should_remove(self, field): | ||
| 13 | ''' | ||
| 14 | return True if the field is compromizing | ||
| 15 | ''' | ||
| 16 | field_list = frozenset(['start_image', 'app0', 'start_frame', | ||
| 17 | 'start_scan', 'data', 'end_image']) | ||
| 18 | if field.name in field_list: | ||
| 19 | return False | ||
| 20 | elif field.name.startswith('quantization['): | ||
| 21 | return False | ||
| 22 | elif field.name.startswith('huffman['): | ||
| 23 | return False | ||
| 24 | return True | ||
| 25 | |||
| 26 | |||
| 27 | class PngStripper(parser.GenericParser): | ||
| 28 | ''' | ||
| 29 | represents a png file | ||
| 30 | see : http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/PNG.html | ||
| 31 | ''' | ||
| 32 | def _should_remove(self, field): | ||
| 33 | ''' | ||
| 34 | return True if the field is compromizing | ||
| 35 | ''' | ||
| 36 | field_list = frozenset(['id', 'header', 'physical', 'end']) | ||
| 37 | if field.name in field_list: | ||
| 38 | return False | ||
| 39 | if field.name.startswith('data['): | ||
| 40 | return False | ||
| 41 | return True | ||
