This simple function outputs an image generated using GD library to PHP string (standard image functions from GD library can output images only to the browser or a file). The image then can be stored in $_SESSION variable or MySQL database.
The PHP Exif Library (PEL) provides an easy-to-use library written in pure PHP which will allow you to read and write the Exif headers commenly found in JPEG and TIFF photos taken with digital cameras. PEL runs on any platform that supports PHP5.