''' Purpose: support image copy transformation ''' # This module basically defines functions that we want to use when we want to # create a copy of an image. # We want to define three functions: # 1. Dimensions (width/height) # 2. Color (pixels - r,g,b) # 3. Locations (spots in image (x,y)) def size( original ) : ''' Purpose: return the size of the new image when performing a copy ''' nw, nh = original.size # gives us the dimensions (width and height of the original image) return ( nw , nh ) def color( opixel ) : ''' Purpose: return the new pixel when performing a copy of opixel ''' npixel = opixel # We want the same colors as the original image's colors! return npixel def where( nspot, original = None ) : ''' Purpose: return the correspondent of nspot in the original when doing a copy ''' ospot = nspot return ospot if ( __name__ == '__main__' ) : import url from manip import manip # from manip.py import the manip function # get web image of interest link = "http://www.cs.virginia.edu/~cs1112/images/mandrill/full.png" original = url.get_image( link ) original.show() new_image = manip( original, size, color, where ) # Pass in the copy.py functions # functions to manipulate the image new_image.show()