def chunk_zTXt(self, pos, len): # compressed text s = ImageFile._safe_read(self.fp, len) k, v = string.split(s, "\0", 1) comp_method = ord(v[0]) if comp_method != 0: raise SyntaxError("Unknown compression method %s in zTXt chunk" % comp_method) import zlib self.im_info[k] = self.im_text[k] = zlib.decompress(v[1:]) return s
def chunk_iCCP(self, pos, len): # ICC profile s = ImageFile._safe_read(self.fp, len) # according to PNG spec, the iCCP chunk contains: # Profile name 1-79 bytes (character string) # Null separator 1 byte (null character) # Compression method 1 byte (0) # Compressed profile n bytes (zlib with deflate compression) i = string.find(s, chr(0)) if Image.DEBUG: print "iCCP profile name", s[:i] print "Compression method", ord(s[i]) comp_method = ord(s[i]) if comp_method != 0: raise SyntaxError("Unknown compression method %s in iCCP chunk" % comp_method) try: icc_profile = zlib.decompress(s[i+2:]) except zlib.error: icc_profile = None # FIXME self.im_info["icc_profile"] = icc_profile return s
def chunk_iCCP(self, pos, len): # ICC profile s = ImageFile._safe_read(self.fp, len) # according to PNG spec, the iCCP chunk contains: # Profile name 1-79 bytes (character string) # Null separator 1 byte (null character) # Compression method 1 byte (0) # Compressed profile n bytes (zlib with deflate compression) i = string.find(s, chr(0)) if Image.DEBUG: print "iCCP profile name", s[:i] print "Compression method", ord(s[i]) comp_method = ord(s[i]) if comp_method != 0: raise SyntaxError("Unknown compression method %s in iCCP chunk" % comp_method) try: icc_profile = zlib.decompress(s[i + 2:]) except zlib.error: icc_profile = None # FIXME self.im_info["icc_profile"] = icc_profile return s