You cannot do this quickly in a non-compiled language, and I don't mean bytecode.
Unless you do it with popen and imagemagick. Actually, there's probably a Python wrapper around that.