summaryrefslogtreecommitdiff
path: root/libmat/images.py
diff options
context:
space:
mode:
Diffstat (limited to 'libmat/images.py')
-rw-r--r--libmat/images.py52
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
3References:
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
9import parser
10
11
12class 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
37class 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