In [7]:
import xmlrpclib, sys
import matplotlib.pyplot as plt
import numpy as np
import scipy.misc
################################# Connect to Server #################################
host, port = "127.0.0.1", 8001
server = xmlrpclib.ServerProxy("http://{0:s}:{1:.0f}".format(host, port) )
################################# Use Server's Functions #################################
image_name = "./waterfall.jpg"
image = plt.imread(image_name)
scipy.misc.imsave('client_original.jpg', np.array(image))
to_send = image.tolist() # lossless conversion to list
flipped = server.flip_image(to_send) # use server to flip the image
scipy.misc.imsave('client_flipped.jpg', np.array(flipped))
cropped = server.crop_image(to_send) # use server to crop the image
scipy.misc.imsave('client_cropped.jpg', np.array(cropped))
inverted = server.color_complement(to_send) # use server to invert the image's colors
scipy.misc.imsave('client_inverted.jpg', np.array(inverted))
In [2]:
################################# Test Help Functions #################################
print "The provided server functions are:"
for method in server.system.listMethods():
print method
print "\nAnd the help documentation specifically for 'crop_image' is:"
print server.system.methodHelp("crop_image")