''' Purpose: support image mirroring transformation ''' def size( original ) : ''' Purpose: return the size of the new image when performing a mirroring ''' nw, nh = original.size return (nw, nh) def color( opixel ) : ''' Purpose: return the new pixel when performing a mirroring transformation ''' npixel = opixel return npixel def where( nspot, original = None ) : ''' Purpose: return the correspondent of nspot in the original when doing a mirroring ''' nw, nh = original.size # get the width and height of the image # We want to plot our coordinates differently! nx, ny = nspot # This is the x and y in the new image # This spot is nx from the left-hand side and ny down from the top oy = ny # We are going the same distance down from the top! ox = ( nw - 1 ) - nx # In the original we are going x across from the left so now we want to go opixel = ( ox,oy ) return opixel if ( __name__ == '__main__' ) : import url from manip import manip # 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 ) new_image.show()