mregan,
Please save the following file into an aspx and run it on your server.
You need to find a Gif file, rename it to test.gif to test this script.
<%@ Page language="c#" %>
<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="System.Drawing" %>
<%@ Import Namespace="System.Drawing.Imaging" %>
<script runat=server>
override protected void OnInit(EventArgs args)
{
string file=Server.MapPath("test.gif");
byte[] data;
using (FileStream fs = new FileStream(file, FileMode.Open, FileAccess.Read))
{
data = new byte[fs.Length];
fs.Read(data, 0, data.Length);
}
Bitmap bm;
int _width = 100, _height = 100;
float fx, fy, f;
int widthTh, heightTh;
float widthOrig, heightOrig;
using (Bitmap bitmapNew = new Bitmap(new System.IO.MemoryStream(data)))
{
widthOrig = bitmapNew.Width;
heightOrig = bitmapNew.Height;
fx = widthOrig / _width;
fy = heightOrig / _height; // subsample factors
// must fit in thumbnail size
f = Math.Max(fx, fy);
if (f < 1)
{
//clone
bm=new Bitmap(bitmapNew);
}
else
{
widthTh = (int)(widthOrig / f);
heightTh = (int)(heightOrig / f);
bm=(Bitmap)bitmapNew.GetThumbnailImage(widthTh, heightTh, new System.Drawing.Image.GetThumbnailImageAbort(ThumbnailCallback), IntPtr.Zero);
}
}
Context.Response.ContentType = "image/Jpeg";
bm.Save (Context.Response.OutputStream, ImageFormat.Jpeg);
}
public bool ThumbnailCallback()
{
return false;
}
</script>
asp.net Chat http://cutesoft.net/ASP.NET+Chat/default.aspx
Web Messenger: http://cutesoft.net/Web-Messenger/default.aspx
asp.net wysiwyg editor: http://cutesoft.net/ASP.NET+WYSIWYG+Editor/default.aspx
asp wysiwyg html editor: http://cutesoft.net/ASP
asp.net Image Gallery: http://cutesoft.net/ASP.NET+Image+Gallery/default.aspx
Live Support: http://cutesoft.net/live-support/default.aspx