New answers tagged download
ImageMagick can do that assuming you're running on a *nix/BSD server where it's readily available. I don't think it's available on Windows. You can interface ImageMagick with any code you have to do what you mentioned.
Top 50 recent answers are included