def convert(self, from_, to, what):
if(from_.lower()==to.lower()):<EOL><INDENT>return what<EOL><DEDENT>direct_conversion = '<STR_LIT>'%(from_.lower(),to.lower())<EOL>if( hasattr(self, direct_conversion ) ):<EOL><INDENT>fn = getattr(self, direct_conversion)<EOL>return fn(what)<EOL><DEDENT>from_to_xyz = getattr(self, '<STR_LIT>'%(from_.lower()) )<EOL>xyz_to_to = getattr(self, '<STR_LIT>'%(to.lower()) )<EOL>return xyz_to_to( from_to_xyz(what) )<EOL>
Convert image or color "what" from "from_" colorpace to "to"
colorspace.  E.g.: ``convert("rgb", "hsv", X)``, where X is a
numpy dstack or a color tuple.