Мне интересно, есть ли какие-либо недостатки в использовании файла для создания эскиза для существующего изображения вместо его сохранения на диск.Есть ли проблемы с памятью, связанные с этим ?!
Мой код:
// thumbnails.aspx
protected void Page_Load(object sender, EventArgs e)
{
string file = Request.QueryString["i"];
if (file == null)
return;
if (!IsFileExists(file))
return;
Thumb(file);
}
public void Thumb(string file)
{
System.Drawing.Image image = System.Drawing.Image.FromFile(Server.MapPath(file));
System.Drawing.Image thumbnailImage = image.GetThumbnailImage(70, 70, new System.Drawing.Image.GetThumbnailImageAbort(ThumbnailCallback), IntPtr.Zero);
System.IO.MemoryStream imageStream = new System.IO.MemoryStream();
thumbnailImage.Save(imageStream, System.Drawing.Imaging.ImageFormat.Jpeg);
byte[] imageContent = new Byte[imageStream.Length];
imageStream.Position = 0;
imageStream.Read(imageContent, 0, (int)imageStream.Length);
Response.ContentType = "image/jpeg";
Response.BinaryWrite(imageContent);
}