Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
''' Takes care about pictures formats
References:
- JFIF: http://www.ecma-international.org/publications/techreports/E-TR-098.htm
- PNG: http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/PNG.html
- PNG: http://www.w3.org/TR/PNG-Chunks.html
'''
import parser
import pillow
class ImageStripper(parser.GenericParser, pillow.PillowStripper):
''' Common stripper for images.
Its purpose is to open then save
images with PIL, the goal being to remove
unknown metadata.
'''
def remove_all(self):
self.open_and_save()
super(ImageStripper, self).remove_all()
class JpegStripper(ImageStripper):
''' Represents a jpeg file.
Custom Huffman and Quantization tables
are stripped: they may leak
some info, and the quality loss is minor.
'''