def max_size(image, _max_sz, method=3):
	""" im = max_size(im, (_max_szX, _max_szY), method = Image.BICUBIC)

	Resizes a PIL image to a _maximum size specified while maintaining
	the aspect ratio of the image.  Similar to Image.thumbnail(), but allows
	usage of different resizing methods and does NOT modify the image in
	place."""
	
	im_aspect = float(image.size[0])/float(image.size[1])
	out_aspect = float(_max_sz[0])/float(_max_sz[1])
	
	if im_aspect >= out_aspect:
		#set to _maxWidth x _maxWidth/im_aspect
		return image.resize((_max_sz[0], int((float(_max_sz[0])/im_aspect) + 0.5)), method)
	else:
		#set to _maxHeight*im_aspect x _maxHeight
		return image.resize((int((float(_max_sz[1])*im_aspect) + 0.5), _max_sz[1]), method)