#NEWLINE# def _get_image_properties( self , filename , image_data ) : #NEWLINE# #INDENT# height = 0 #NEWLINE# width = 0 #NEWLINE# x_dpi = 96 #NEWLINE# y_dpi = 96 #NEWLINE# if ( not image_data ) : #NEWLINE# #INDENT# fh = open ( filename , 'rb' ) #NEWLINE# data = fh . read ( ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# data = image_data . getvalue ( ) #NEWLINE# #UNINDENT# image_name = os . path . basename ( filename ) #NEWLINE# marker1 = unpack ( '3s' , data [ 1 : 4 ] ) [ 0 ] #NEWLINE# marker2 = unpack ( '>H' , data [ : 2 ] ) [ 0 ] #NEWLINE# marker3 = unpack ( '2s' , data [ : 2 ] ) [ 0 ] #NEWLINE# if ( sys . version_info < ( 2 , 6 , 0 ) ) : #NEWLINE# #INDENT# png_marker = 'PNG' #NEWLINE# bmp_marker = 'BM' #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# png_marker = eval ( "b'PNG'" ) #NEWLINE# bmp_marker = eval ( "b'BM'" ) #NEWLINE# #UNINDENT# if ( marker1 == png_marker ) : #NEWLINE# #INDENT# self . image_types [ 'png' ] = 1 #NEWLINE# ( image_type , width , height , x_dpi , y_dpi ) = self . _process_png ( data ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( marker2 == 65496 ) : #NEWLINE# #INDENT# self . image_types [ 'jpeg' ] = 1 #NEWLINE# ( image_type , width , height , x_dpi , y_dpi ) = self . _process_jpg ( data ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( marker3 == bmp_marker ) : #NEWLINE# #INDENT# self . image_types [ 'bmp' ] = 1 #NEWLINE# ( image_type , width , height ) = self . _process_bmp ( data ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# raise Exception ( ( '%s: Unknown or unsupported image file format.' % filename ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# if ( ( not height ) or ( not width ) ) : #NEWLINE# #INDENT# raise Exception ( ( '%s: no size data found in image file.' % filename ) ) #NEWLINE# #UNINDENT# self . images . append ( [ filename , image_type , image_data ] ) #NEWLINE# if ( not image_data ) : #NEWLINE# #INDENT# fh . close ( ) #NEWLINE# #UNINDENT# return ( image_type , width , height , image_name , x_dpi , y_dpi )