#NEWLINE# def create_image( self , buffer ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# img = Image . open ( BytesIO ( buffer ) ) #NEWLINE# #UNINDENT# except Image . DecompressionBombWarning : #NEWLINE# #INDENT# return None #NEWLINE# #UNINDENT# self . icc_profile = img . info . get ( 'icc_profile' ) #NEWLINE# self . transparency = img . info . get ( 'transparency' ) #NEWLINE# self . exif = img . info . get ( 'exif' ) #NEWLINE# self . subsampling = JpegImagePlugin . get_sampling ( img ) #NEWLINE# if ( img . subsampling == ( - 1 ) ) : #NEWLINE# #INDENT# self . subsampling = None #NEWLINE# #UNINDENT# self . qtables = getattr ( img , 'quantization' , None ) #NEWLINE# if ( self . context . config . ALLOW_ANIMATED_GIFS and ( self . extension == '.gif' ) ) : #NEWLINE# #INDENT# frames = [ ] #NEWLINE# for frame in ImageSequence . Iterator ( img ) : #NEWLINE# #INDENT# frames . append ( frame . convert ( 'P' ) ) #NEWLINE# #UNINDENT# img . seek ( 0 ) #NEWLINE# self . frame_count = len ( frames ) #NEWLINE# return frames #NEWLINE# #UNINDENT# return img