Click here to Skip to main content
15,797,984 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:

This is venkat..

I have an issue when rotate images which are exist in remote system..

I have written the following code for image rotation in handler page..

The below code is not working ..Please help me on this issue as early as possible..

public void ProcessRequest(HttpContext context)
    string Path = context.Request.Form["Path"];
    int width = int.Parse(Convert.ToString(context.Request.Form["Width"]));
    int height = int.Parse(Convert.ToString(context.Request.Form["Height"]));

    //Create Request to get Image stream
    HttpWebRequest request = (HttpWebRequest)WebRequest.Create(Path);
    HttpWebResponse response = (HttpWebResponse)request.GetResponse();
    Stream receiveStream = response.GetResponseStream();
    Image theImage = System.Drawing.Image.FromStream(receiveStream);

    context.Response.ContentType = "image/jpeg";
    theImage.Save(context.Response.OutputStream, ImageFormat.Jpeg);

    context.Response.ContentType = "text/plain";
    context.Response.Charset = "";
Updated 14-Nov-12 9:32am
[no name] 14-Nov-12 14:33pm    
Whats the error message?
K.Venkateswarlu 14-Nov-12 14:35pm    
i am not getting error message..
the image not rotating..
jkirkerx 15-Nov-12 1:55am    
So your trying to take a snapshot of a webpage and rotate it?

I may be wrong on this, but I think your missing the webpage to image conversion part. Then rotate it.

1 solution

I was wrong. At the core, you're doing everything wrong. You need to use Server.MapPath to get the path to the file, and use that path to save it, unless your HTTPHandler is being used correctly ( to find and process a file, the URL being the src part of an img tag ).
Share this answer
K.Venkateswarlu 14-Nov-12 16:19pm    
Actually the image in remote system not in local system so when i call this handler page by post method using j-query the code is executing fine...but the image is not rotating...
Christian Graus 14-Nov-12 16:20pm    
Read it again.....
K.Venkateswarlu 14-Nov-12 16:22pm    
you have written theImage = theImage.Rotate... like this
but the Rotateflip method won't return anything..
Christian Graus 14-Nov-12 16:23pm    
You are right. Then this code is not running. I bet the browser is caching the image
K.Venkateswarlu 14-Nov-12 16:26pm    
then how can i solve the issue..

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900