#NEWLINE# def __init__( self , spec , image_size = None ) : #NEWLINE# #INDENT# super ( Transform , self ) . __init__ ( spec ) #NEWLINE# self . flag = getattr ( Image , self [ 0 ] . upper ( ) ) #NEWLINE# try : #NEWLINE# #INDENT# axis = ( ( None , 0 , 1 ) + TRANSFORM_AXIS [ self . flag ] ) #NEWLINE# #UNINDENT# except KeyError : #NEWLINE# #INDENT# raise ValueError ( ( 'unknown transform %r' % self [ 0 ] ) ) #NEWLINE# #UNINDENT# if ( len ( self ) != len ( axis ) ) : #NEWLINE# #INDENT# raise ValueError ( ( 'expected %d transform values; got %d' % ( len ( axis ) , len ( self ) ) ) ) #NEWLINE# #UNINDENT# for i in xrange ( 1 , len ( self ) ) : #NEWLINE# #INDENT# v = self [ i ] #NEWLINE# if isinstance ( v , basestring ) : #NEWLINE# #INDENT# if ( v [ ( - 1 ) : ] in ( '%' , 'p' ) ) : #NEWLINE# #INDENT# if ( spec [ i ] is None ) : #NEWLINE# #INDENT# raise ValueError ( ( 'unknown dimension for %s value %d' % ( self [ 0 ] , i ) ) ) #NEWLINE# #UNINDENT# if ( image_size is None ) : #NEWLINE# #INDENT# raise ValueError ( 'no image size with relative transform' ) #NEWLINE# #UNINDENT# self [ i ] = ( ( image_size [ axis [ i ] ] * float ( v [ : ( - 1 ) ] ) ) / 100 ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# self [ i ] = float ( v ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# if ( ( not self [ 1 ] ) or ( not self [ 2 ] ) ) : #NEWLINE# #INDENT# if ( not image_size ) : #NEWLINE# #INDENT# ValueError ( 'no image size or transform size' ) #NEWLINE# #UNINDENT# #UNINDENT# self [ 1 ] = int ( ( self [ 1 ] or image_size [ 0 ] ) ) #NEWLINE# self [ 2 ] = int ( ( self [ 2 ] or image_size [ 1 ] ) )