'Retrieve an image file off of disk, resize it to a maximum size, then save to a stream as a jpeg
objImage = System.Drawing.Image.FromFile(sFullFileName)
If Not objImage Is Nothing Then
ImageTools.Resize.ToMaxDimensions(objImage, m_nViewHeight, m_nViewWidth).Save(objStream, System.Drawing.Imaging.ImageFormat.Jpeg)
End If
'Take an image object, resize as a thumbnail of maximum dimensions, then save to a stream as an jpeg
ImageTools.Thumbnail.ToMaxDimensions(objImage, m_nThumbNailSize, m_nThumbNailSize).Save(objStream, System.Drawing.Imaging.ImageFormat.Jpeg)
The reason for "Resize" vs. "Thumbnail" is that when you use the Thumbnail method that is used by the internal code, it creates a lower quality image. When I wrote those tools, I found that some images resized poorly to larger image sizes which kind of makes sense. There's little reason for a really high quality image if it's going to be a thumbnail simply by nature.
I wrote these tools for this photo browser application I made. All my digital photos (at high res) get dumped into a directory structure, and the applications reads those and builds thumbnails on the fly and shows the images at a specified size for "full view" suitable for viewing online.
Peter
------------------------------------------------------
Work smarter, not harder.
|