image compression before sending to the browserhttp://forums.asp.net/t/261550.aspx/1?image+compression+before+sending+to+the+browserThu, 28 Jun 2007 17:09:43 -0400261550261550http://forums.asp.net/p/261550/261550.aspx/1?image+compression+before+sending+to+the+browserimage compression before sending to the browser Hi, I am uploading some images to server using asp.net. rightnow i upload the image and then compress the image in server using asp.net. Is there any way to do the same at client side before uploading the file to server. I would love to see any asp.net control (free) which is available on net which exactly does that by spitting out javascript code on the browser so that i don't have to worry about creating one for me. regard's verinder 2003-06-27T14:50:00-04:00265481http://forums.asp.net/p/261550/265481.aspx/1?Re+image+compression+before+sending+to+the+browserRe: image compression before sending to the browser never seen a client-side component to do this - besides, do you really want to <i> require</i> your clients to install some activeX control? No, javascript can't do this - it would have to be something more chunky. j 2003-07-02T03:55:58-04:00265612http://forums.asp.net/p/261550/265612.aspx/1?Re+image+compression+before+sending+to+the+browserRe: image compression before sending to the browser I would have to agree. I dont know of anything that would accomplish this browser/client side in javascript (just doesnt have access to that API) You could write a WebForm for IE (replacement for ActiveX) but you will run into some issues with .Net Security Policy on the client machines. By default (i think) these types of WebForms for IE dont have file system access. BTW, what type of image compression are you dealing with? From and to? Good Luck Charles Phillips 2003-07-02T12:04:58-04:00304973http://forums.asp.net/p/261550/304973.aspx/1?Re+image+compression+before+sending+to+the+browserRe: image compression before sending to the browser I want to do from JPEG to JPEG GIF TO Gif . I use following function on server side to do compression. HEre is the code. private void CompressImage(string DestPath,string FileName,long QualityFactor) { try { FileInfo FileDetails=new FileInfo(FileName); string str=FileName;//Server.MapPath(&quot;/albums/&quot;&#43;UserDirectory&#43;&quot;/&quot;&#43;_fileName); //' create New image and bitmap objects. Load the image file and put into a resized bitmap. System.Drawing.Image g = System.Drawing.Image.FromFile(str) ; System.Drawing.Imaging.ImageFormat thisFormat=g.RawFormat;//rawformat ; double tempMultiplier;// as Double int Width=(int)g.Width; int Height=(int)g.Height; int NewWidth=600; int NewHeight=(int)((double)(Height/(double)Width)*600); Size NewSize =new Size((int)NewWidth, (int)(NewHeight)) ; if( NewSize.Height&gt;NewSize.Width&#43;30) { NewWidth=300; NewHeight=(int)((double)(Height/(double)Width)*300); NewSize =new Size((int)NewWidth, (int)(NewHeight)) ; } Size thumbSize =NewSize;//(NewthumbSize(g.Width,g.Height)); Bitmap imgOutput = new Bitmap(g, thumbSize.Width, thumbSize.Height); g.Dispose(); string FilenameWithExtension; FilenameWithExtension=FileDetails.Name; //' send the resized image to the viewer FileInfo fInfo=new FileInfo(DestPath&#43;&quot;\\&quot;&#43;FilenameWithExtension); if(fInfo.Exists) fInfo.Delete(); FileStream str1=fInfo.Create(); //string file=Server.MapPath(&quot;/albums/temp/&quot;&#43;FilenameWithExtension); // now compress the image ImageCodecInfo[] icf = ImageCodecInfo.GetImageEncoders(); // get available EncoderParameters encps = new EncoderParameters(1); EncoderParameter encp = new EncoderParameter (Encoder.Quality, (long) QualityFactor); //Set quality to 50 encps.Param[0] = encp; imgOutput.Save(str1, icf[1],encps) ;//' output to the user str1.Close(); imgOutput.Dispose();//dispose() ; } catch(Exception e) { this.ErrorText.Text&#43;=&quot;\nCompression Failed for file&quot;&#43;FileName; } finally { } } problem is I want tp do the same On client side . I don't want that user should run a c&#43;&#43;/c# utility to compress the image and then upload it to server. IS there any way out without using ActiveX/etc/etc.. I don't think sooo.. anyway thanks.. if nobody has answer to my question 2003-08-10T05:29:03-04:00305407http://forums.asp.net/p/261550/305407.aspx/1?Re+image+compression+before+sending+to+the+browserRe: image compression before sending to the browser no, there's no way you're going to be able to do this client-side the way you seem to want to (that is, without an ActiveX Control or Java Applet). There are limitations to what you can do client side for very good reasons - you're not allowed to use a lot of memory, you're not allowed to access the filesystem, or the registry, you're not allowed to access pages loaded from other servers, and you can't call an 'external' API - you can get round SOME of these restrictions (not all) with ActiveX or other trusted code, but without that, you've got not much chance of doing this client-side. And even then you're restricted to IE/Windows as a client platform, which would annoy a small but <i>very</i> vocal proportion of the general audience. j 2003-08-11T02:32:05-04:001571850http://forums.asp.net/p/261550/1571850.aspx/1?Re+image+compression+before+sending+to+the+browserRe: image compression before sending to the browser Well now this can be done by using Ajax i guess 2007-02-09T15:23:15-05:001777899http://forums.asp.net/p/261550/1777899.aspx/1?Re+image+compression+before+sending+to+the+browserRe: image compression before sending to the browser <p>I don't see how AJAX would allow you to access and compress a local client-side file in the browser.</p> <p>As far as I can tell, the only options for compressing client-side are Java Applets and ActiveX controls.&nbsp; I need to be able to do the same thing and I think I'll go the Applet route since I believe it will be more browser independant.</p> <p>-Aaron</p> 2007-06-28T17:09:43-04:00