Resize image servlet using imagemagick or thumbnailator.
Resize an image using imagemagick (http://www.imagemagick.org/) or thumbnailator (http://code.google.com/p/thumbnailator/) from within a servlet. The servlet will resize an already existing original image to one of the predefined desired sizes (or whatever size you want, depending on configuration).
/SERVLET/?img=MY_ORIGINAL_IMAGE-120x94.png
The servlet will check if the image already exist in the requested size. If the file exists, it is forwarded to the user. Else the servlet checks if the original image exist (named MY_ORIGINAL_IMAGE.png) and that the requested thumbnail size is valid (you can configure valid size or say that all sizes are valid) . If the request is valid, a new thumbnail is resized and put in your configured thumbnail base dir + a generated folder path that is calculated from the original file name, so that files are spread within the file system (but all sizes for a specific file, are within the same folder). Then the new image is returned to the user.
The calling thread is the thread that creates the actual thumbnail and it is concurrent in the meaning only one thread can create the same thumbnail.
Bundled with Tomcat, set it up using and inctructions of how to start: https://github.com/jsimone/webapp-runner
Also an expire filter is setup in the web.xml to set some cache headers (so make sure to empty your browser cache if you change images but keep the same name).
Tuckeys url rewrite filter is used to setup a friendly url.
If you want to run this in production, you need to think of a couple of things: