When we want to read and create thumbnail from a database image field, read it and store it into a memory stream object and look into the following code. I am discussing only the key area of this functionality.

The ShowAlbumImage() is a function to return image field of the database as stream.
Then converting the stream obj into image, creating thumbnail using GetThumbnailimage function. Again it is saving to memory stream and can display using context.response.binarywrite()...

Do include required namespaces...

And the Orkut stuff is achieved of transforming an image into a thumbnail...