hi
refer below threads I use code for saving thumpnail image in other pace
http://www.aspforums.net/Threads/451626/save-thumpnail-image-in-other-place/
I want thumpnail image save in .JPG format so I change below code:
public string GetThumbNail(string url)
{
string path = Server.MapPath(url);
System.Drawing.Image image = System.Drawing.Image.FromFile(path);
using (System.Drawing.Image thumbnail = image.GetThumbnailImage(100, 100, new System.Drawing.Image.GetThumbnailImageAbort(ThumbnailCallback), IntPtr.Zero))
{
using (MemoryStream memoryStream = new MemoryStream())
{
thumbnail.Save(memoryStream, ImageFormat.Jpeg);
Byte[] bytes = new Byte[memoryStream.Length];
memoryStream.Position = 0;
memoryStream.Read(bytes, 0, (int)bytes.Length);
string base64String = Convert.ToBase64String(bytes, 0, bytes.Length);
return "data:image/jpeg;base64," + base64String;
}
}
}
I replace below line:
thumbnail.Save(memoryStream, ImageFormat.Png);
return "data:image/Png;base64," + base64String;
with:
thumbnail.Save(memoryStream, ImageFormat.Jpeg);
return "data:image/jpeg;base64," + base64String;
Now when I click on CopyImage button to save thumpnail image below error happen:
A generic error occurred in GDI+.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Runtime.InteropServices.ExternalException: A generic error occurred in GDI+.
Source Error:
Line 48: }
Line 49: //Save Image in C Folder
Line 50: image.Save("C:\\Thumbnail\\13.jpg");
Line 51: }
Line 52:
|
Best Regards
Neda