Image Processing

M

Martin Schmid

Hi... I have this simple Page_Load that works as expected, however, the
output in the browser is such that when one tries to right-click to save the
image, it is grabbing the aspx instead of an actual image...

I.e., sending the URL
http://localhost/spc/Result.aspx?file=/spc/images/03110002_tn.jpg&size=0.25
results in the image in the browser window, but when you right-click Save
Picture as.. you don't get a jpeg, you get an aspx text file.

<%@ Page language="c#" Codebehind="Result.aspx.cs" AutoEventWireup="false"
Inherits="spc.Result" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>Result</title>
<meta content="Microsoft Visual Studio 7.0" name="GENERATOR">
<meta content="C#" name="CODE_LANGUAGE">
<meta content="JavaScript" name="vs_defaultClientScript">
<meta content="http://schemas.microsoft.com/intellisense/ie5"
name="vs_targetSchema">
</HEAD>
<body>
</body>
</HTML>


Any ideas?



private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
string path=
Request.QueryString.GetValues("file").GetValue(0).ToString();
double size =
Convert.ToDouble(Request.QueryString.GetValues("size").GetValue(0).ToString(
));

string fName = path.Substring(0,path.Length-7) + ".jpg";

System.Drawing.Image fullSizeImg;
System.Drawing.Bitmap bmp;
System.Drawing.Graphics g;
fullSizeImg=System.Drawing.Image.FromFile(Server.MapPath(fName));
Response.ContentType="image/jpeg";
bmp=new System.Drawing.Bitmap(1,1);
g=System.Drawing.Graphics.FromImage(fullSizeImg);
bmp=(System.Drawing.Bitmap)fullSizeImg;
int height = (int)(fullSizeImg.Height*size);

int width = (int)(fullSizeImg.Width*size);

bmp=(System.Drawing.Bitmap)(ResizeImage(bmp,width,height));
bmp.Save(Response.OutputStream,System.Drawing.Imaging.ImageFormat.Jpeg);
g.Dispose();
bmp.Dispose();
}
 
G

Guest

I think you have too much in you page.

get rid of everything after the directives page..

In a very similar webform the only lines in my "webpage" ar
<%@ Page Language="vb" AutoEventWireup="false" Codebehind="ReturnFile.aspx.vb" Inherits="albertphoto.ReturnFile"%

HT

Ro
 
M

Martin Schmid

Tried that... when saving the Picture As... it is still saving a text file
containing the calling webform...

I.e., Webform1.aspx calls Results.aspx... when trying to save the image on
Results.aspx, I am getting the client side Webform1.aspx file, as a text
document.


--
Thanks,
Martin Schmid, EIT, CCSA, MCDBA, MCSE
Rob Lynch said:
I think you have too much in you page..

get rid of everything after the directives page...

In a very similar webform the only lines in my "webpage" are
<%@ Page Language="vb" AutoEventWireup="false"
Codebehind="ReturnFile.aspx.vb" Inherits="albertphoto.ReturnFile"%>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,756
Messages
2,569,540
Members
45,025
Latest member
KetoRushACVFitness

Latest Threads

Top