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
never seen a client-side component to do this - besides, do you really want to
require your clients to install some activeX control? No, javascript can't do this - it would have to be something more chunky. j
RTFM - straight talk for web developers. Unmoderated, uncensored, occasionally unreadable
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
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("/albums/"+UserDirectory+"/"+_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>NewSize.Width+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+"\\"+FilenameWithExtension); if(fInfo.Exists) fInfo.Delete(); FileStream str1=fInfo.Create();
//string file=Server.MapPath("/albums/temp/"+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+="\nCompression Failed
for file"+FileName; } finally { } } problem is I want tp do the same On client side . I don't want that user should run a c++/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
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
very vocal proportion of the general audience. j
RTFM - straight talk for web developers. Unmoderated, uncensored, occasionally unreadable
I don't see how AJAX would allow you to access and compress a local client-side file in the browser.
As far as I can tell, the only options for compressing client-side are Java Applets and ActiveX controls. 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.
Member
10 Points
31 Posts
image compression before sending to the browser
Jun 27, 2003 10:50 AM|verinder|LINK
Member
50 Points
3581 Posts
Re: image compression before sending to the browser
Jul 01, 2003 11:55 PM|Atrax|LINK
Jason Brown - MVP, IIS
None
0 Points
9 Posts
Re: image compression before sending to the browser
Jul 02, 2003 08:04 AM|phillipsc|LINK
Member
10 Points
31 Posts
Re: image compression before sending to the browser
Aug 10, 2003 01:29 AM|verinder|LINK
Member
50 Points
3581 Posts
Re: image compression before sending to the browser
Aug 10, 2003 10:32 PM|Atrax|LINK
Jason Brown - MVP, IIS
Member
10 Points
31 Posts
Re: image compression before sending to the browser
Feb 09, 2007 11:23 AM|verinder|LINK
None
0 Points
4 Posts
Re: image compression before sending to the browser
Jun 28, 2007 01:09 PM|DezTech|LINK
I don't see how AJAX would allow you to access and compress a local client-side file in the browser.
As far as I can tell, the only options for compressing client-side are Java Applets and ActiveX controls. 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.
-Aaron
client side image compression