The script you linked to is hilariously stupid... I can't imagine what it would possibly be useful for.
You could use a Canvas element to rotate the image but it would be far easier to just do it on the server. It's pretty easy to write a php script to rotate the image, or you could use phpthumb. Then just update its src to be example.php?img=example.jpg°=45 whenever you want it to rotate.