as for rendering the image, see http://stackoverflow.com/questions/1353850/serve-image-with-php-script-vs-direct-loading-image (readfile function)