Here's some code I've been playing around with. It creates square thumbs,
but could easily be modified to create proportional...
private void CreateThumbnail(string pathToFullSizeImage, string
pathToThumbnailImage, int sizeToCreate) {
try {
int iWidth = 0;
int iHeight = 0;
string strFilename = pathToFullSizeImage;
int dotPlace = strFilename.LastIndexOf(".");
string fileType = strFilename.Substring((dotPlace + 1),
(strFilename.Length - (dotPlace + 1))).ToUpper();
if (sizeToCreate == 1) {
iWidth = 80;
iHeight = 80;
}
else {
iWidth = 130;
iHeight = 130;
}
System.IO.FileStream fs = new System.IO.FileStream(pathToFullSizeImage,
System.IO.FileMode.Open, System.IO.FileAccess.Read);
System.Drawing.Image objThumbnail =
System.Drawing.Image.FromStream(fs).GetThumbnailIm age(iWidth, iHeight, null,
IntPtr.Zero);
// DO NOT USE THE FOLLOWING LINE (in place of the previous line) because
Image.FromFile() keeps the file open. This is why we open the file via a
stream - a stream can be closed.
// System.Drawing.Image objThumbnail =
System.Drawing.Image.FromFile(strFilename).GetThum bnailImage(iWidth,
iHeight, null, IntPtr.Zero);
// Set the ContentType correctly
if (fileType == "JPG" || fileType == "JPEG") {
objThumbnail.Save(pathToThumbnailImage, ImageFormat.Jpeg);
}
else {
objThumbnail.Save(pathToThumbnailImage, ImageFormat.Gif);
}
objThumbnail.Dispose();
fs.Close();
}
catch (Exception ex) {
if (!(ex is OOPS.DalException)) {
OOPS.WriteErrorInfo(ex, "");
}
}
}
"Daniel" <so*****@yahoo.com> wrote in message
news:opsa62m7naxo301l@dev-02...
hi,
I have a whole lot of pictures needed to transform to the thumbnails to
display on the web, it there any easy to do?
Thanks.