No luck using Python Image Library with Jython, I am sorry. The Python code idea looks interesting though in all stylistic points I do not find code agreeable (like using small el for variable name and capitalized function names, which should be dedicated to Classes in Python). There is also euclidean distance function in math library (hypot) so Distance is kind of pointless, just call math.hypot(x2-x1, y2-y1) Also global statements are completely without purpose as opt is not changed in those functions.