I have successfully created a on the fly image refactoring application using Imagemagick. The performance is great and I am able to resize/crop/watermark/reformat etc all via a restful request. I use memcache to cache the binary blob of the refactored image and this gives me a massive performance boost.
EDIT: I used the Java Imagemagick libs initially and kept running into issues, the PHP libs are far better imho ( this was about a year ago, its possible that the Java libs have improved )