''' Provides a sandbox for image transformations ''' from PIL import Image # get Pillow Image capabilities import locate, mutate, dimensions # get our modules for image transformations def play( original ) : ow, oh = original.size # get dimensions of the original nw, nh = dimensions.same( original ) # set dimensions of the new image # The new image is gonna be the same size as og. # get a new appropriately sized image and fill it in new_image = Image.new( 'RGB', ( nw, nh ) ) for nx in range( 0, nw ) : # consider all possible x values for new image for ny in range( 0, nh ) : # consider all possible y values for new image nspot = ( nx, ny ) # set the spot to be filled in new image # ospot = locate.same( nspot, nw, nh ) # determine duplicate corresponding spot in original # ospot = locate.mirror( nspot, nw, nh ) # determine mirror corresponding spot in original ospot = locate.flip( nspot, nw, nh ) # determine flipping corresponding spot in original opixel = original.getpixel( ospot ) # get the pixel at the ospot # npixel = mutate.same( opixel ) # determine duplicate pixel for the new image # npixel = mutate.blue( opixel ) # determine blue pixel for the new image # npixel = mutate.grey( opixel ) # determine greyscale pixel for the new image npixel = mutate.fade( opixel ) # determine faqded pixel for the new image new_image.putpixel( nspot, npixel ) # set the nspot in the new image # Please raise your hand and look towards back if you need a TA! return new_image # return the filled in new image if ( __name__ == '__main__' ) : import url # 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 = play( original ) new_image.show()