diff options
| author | jvoisin | 2015-12-02 17:07:19 +0100 |
|---|---|---|
| committer | jvoisin | 2015-12-02 17:22:45 +0100 |
| commit | 80ece3001895ea13d50915a5215fd47e313bab4c (patch) | |
| tree | c5ede43867c5d7fe2af4178b34b0e6dc219f6aac /libmat/images.py | |
| parent | 3cf80e8b5d6faf410e9ad3aad77f23cf6418a587 (diff) | |
Remove hachoir from MAT.
This (huge) commit removes completely hachoir from MAT.
Audio files are now processed with mutagen, and images
with exiftool, since the main python imaging library (PIL)
isn't super-great to deal with metadata (and damaged/non-standard
files).
Package maintainer should change the dependencies to reflect this.
Diffstat (limited to 'libmat/images.py')
| -rw-r--r-- | libmat/images.py | 52 |
1 files changed, 0 insertions, 52 deletions
diff --git a/libmat/images.py b/libmat/images.py deleted file mode 100644 index 813b0fd..0000000 --- a/libmat/images.py +++ /dev/null | |||
| @@ -1,52 +0,0 @@ | |||
| 1 | """ Takes care about pictures formats | ||
| 2 | |||
| 3 | References: | ||
| 4 | - JFIF: http://www.ecma-international.org/publications/techreports/E-TR-098.htm | ||
| 5 | - PNG: http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/PNG.html | ||
| 6 | - PNG: http://www.w3.org/TR/PNG-Chunks.html | ||
| 7 | """ | ||
| 8 | |||
| 9 | import parser | ||
| 10 | |||
| 11 | |||
| 12 | class JpegStripper(parser.GenericParser): | ||
| 13 | """ Represents a jpeg file. | ||
| 14 | Custom Huffman and Quantization tables | ||
| 15 | are stripped: they may leak | ||
| 16 | some info, and the quality loss is minor. | ||
| 17 | """ | ||
| 18 | def _should_remove(self, field): | ||
| 19 | """ Return True if the field is compromising | ||
| 20 | """ | ||
| 21 | field_list = frozenset([ | ||
| 22 | 'start_image', # start of the image | ||
| 23 | 'app0', # JFIF data | ||
| 24 | 'start_frame', # specify width, height, number of components | ||
| 25 | 'start_scan', # specify which slice of data the top-to-bottom scan contains | ||
| 26 | 'data', # actual data | ||
| 27 | 'end_image']) # end of the image | ||
| 28 | if field.name in field_list: | ||
| 29 | return False | ||
| 30 | elif field.name.startswith('quantization['): # custom Quant. tables | ||
| 31 | return False | ||
| 32 | elif field.name.startswith('huffman['): # custom Huffman tables | ||
| 33 | return False | ||
| 34 | return True | ||
| 35 | |||
| 36 | |||
| 37 | class PngStripper(parser.GenericParser): | ||
| 38 | """ Represents a png file | ||
| 39 | """ | ||
| 40 | def _should_remove(self, field): | ||
| 41 | """ Return True if the field is compromising | ||
| 42 | """ | ||
| 43 | field_list = frozenset([ | ||
| 44 | 'id', | ||
| 45 | 'header', # PNG header | ||
| 46 | 'physical', # the intended pixel size or aspect ratio | ||
| 47 | 'end']) # end of the image | ||
| 48 | if field.name in field_list: | ||
| 49 | return False | ||
| 50 | elif field.name.startswith('data['): # data | ||
| 51 | return False | ||
| 52 | return True | ||
