Image JPG Handler
-
I would like to make a HttpHandler that looks for querystring and edits the image (let's say jpg) as specified. I can do all this and it works great. My issue is since every JPG is being sent to the handler what do I do if I want it to not do anything? I tried to Server.Transfer to the requested image when the querystring is 0 but that basically makes a loop. I figure I can have the handler read the file image then save it to the output stream with no edits but I don't want the server doing the extra work for nothing. Is there and easy way to do this? Is to a lot of extra work for the server to read and dispose rather than just hand the file over? Is there a better way to write the Web.config (currently I have modified on Sunday, October 5, 2008 12:19 PM
-
I would like to make a HttpHandler that looks for querystring and edits the image (let's say jpg) as specified. I can do all this and it works great. My issue is since every JPG is being sent to the handler what do I do if I want it to not do anything? I tried to Server.Transfer to the requested image when the querystring is 0 but that basically makes a loop. I figure I can have the handler read the file image then save it to the output stream with no edits but I don't want the server doing the extra work for nothing. Is there and easy way to do this? Is to a lot of extra work for the server to read and dispose rather than just hand the file over? Is there a better way to write the Web.config (currently I have modified on Sunday, October 5, 2008 12:19 PM
well, *something* has to handle the request - if not your custom handler then .NET itself, so as long as you pass it straight back if no editing is required I wouldn't worry too much... If [condition] Then ' amend image ...Save(context.Response.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg) Else ' send original image straight to browser context.Response.ContentType = "image/jpeg" context.Response.WriteFile([FilePath]) End If Otherwise, if you can separate your images into different folders such that all those that need amending are all in a particular folder then you can re-write the path="*.jpg" attribute in your web.config accordingly...