using System; using System.Data; using System.Configuration; using System.Collections; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; using System.IO; public partial class build_inventory_make_thumbnail : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { string file = "\\images\\inventory\\"; file += Request.QueryString.Get("file"); System.Drawing.Image image = System.Drawing.Image.FromFile(Server.MapPath(file)); System.Drawing.Image thumbnailImage = image.GetThumbnailImage(200, 126, new System.Drawing.Image.GetThumbnailImageAbort(ThumbnailCallback), IntPtr.Zero); MemoryStream imageStream = new 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"; imageStream.Close(); image.Dispose(); thumbnailImage.Dispose(); Response.BinaryWrite(imageContent); } public bool ThumbnailCallback() { return true; } }