I want to write a simple web service (I'm not particular about the language implementation) that runs on a FreeBSD web server at nearlyfreespeech.net, takes a URL that points to a JPEG image with some additional parameters like the following:
http://www.myserver.com/script.cgi?url=http://www.destination.com/image.jpg&width=320
and performs the following operations:
- How do I parse the URL's parameters? (destination URL plus some additional parameters for processing)
- How can I fetch the contents of the image at the URL provided in the parameter?
- Based on the additional parameters, perform some processing on the contents (out of scope of this question)
- How can I return the processed image to be properly recognized as an image to be displayed in a browser (as opposed to returning text)?
I presume this wouldn't be difficult to do with a scripting language like Perl, but I don't know where to begin for steps 1, 2, and 4.