On the compression picture of client js

123 4

When users upload pictures through the browser, they'll be able to upload them, and now use the js browser to compress the picture, and then upload. Is this scheme feasible. What's the solution for sina webo when uploading pictures. - please, please! - thank you.

8 Answers

61 5
<script language="JavaScript" type="text/javascript"> 
function DrawImage(ImgD,FitWidth,FitHeight) 
{ 
var image=new Image(); 
image.src=ImgD.src; 
 if(image.width>0 && image.height>0) 
 { 
 if(image.width>FitWidth) 
 { 
 ImgD.width=FitWidth; 
 ImgD.height=(image.height*FitWidth)/image.width; 
 if(ImgD.height>FitHeight)
 {
 ImgD.height=FitHeight; 
 ImgD.width=(image.width*FitHeight)/image.height; 
 }
 } 
 else if(image.height>FitHeight) 
 { 
 ImgD.height=FitHeight; 
 ImgD.width=(image.width*FitHeight)/image.height; 
 if(image.width>FitWidth)
 {
 ImgD.width=FitWidth; 
 ImgD.height=(image.height*FitWidth)/image.width; 
 }
 }
 else
 { 
 ImgD.width=image.width; 
 ImgD.height=image.height; 
 } 
 } 
} 
</script>

When you've been doing a page recently, I don't know what your requirements are.

79 3
<script language="JavaScript" type="text/javascript"> 
function DrawImage(ImgD,FitWidth,FitHeight) 
{ 
var image=new Image(); 
image.src=ImgD.src; 
 if(image.width>0 && image.height>0) 
 { 
 if(image.width>FitWidth) 
 { 
 ImgD.width=FitWidth; 
 ImgD.height=(image.height*FitWidth)/image.width; 
 if(ImgD.height>FitHeight)
 {
 ImgD.height=FitHeight; 
 ImgD.width=(image.width*FitHeight)/image.height; 
 }
 } 
 else if(image.height>FitHeight) 
 { 
 ImgD.height=FitHeight; 
 ImgD.width=(image.width*FitHeight)/image.height; 
 if(image.width>FitWidth)
 {
 ImgD.width=FitWidth; 
 ImgD.height=(image.height*FitWidth)/image.width; 
 }
 }
 else
 { 
 ImgD.width=image.width; 
 ImgD.height=image.height; 
 } 
 } 
} 
</script>

When you've been doing a page recently, I don't know what your requirements are.

104 4

https://github.com/think2011/LocalResizeIMG

I was based on the code, finished the client image, compression, rotation.

You know, it's the main problem you'll see.

The picture of the mobile phone will save the picture in the picture frame, so it'll be rotated in the client image.

Compressed images can only be uploaded through

68 0

https://github.com/think2011/LocalResizeIMG

I was based on the code, finished the client image, compression, rotation.

You know, it's the main problem you'll see.

The picture of the mobile phone will save the picture in the picture frame, so it'll be rotated in the client image.

Compressed images can only be uploaded through

88 5

There are detailed scenarios for the js front end image compression
http://www.imwinlion.com/archives/158
An excerpt is as follows, and it should be what you want.

The difficulty of this scenario is image compression, why is the picture compression? first, because the current user is basically, a figure 1 is. Second, the user 's network status isn't great, although user 3g is very common, 4 g size, wifi hot spot, but the upload of a large number of. Again, users may not be willing to wait so long. Where's the solution? the answer is the front end compression, where the author commonly used, is LRZ download address as follows

91 3

There are detailed scenarios for the js front end image compression
http://www.imwinlion.com/archives/158
An excerpt is as follows, and it should be what you want.

The difficulty of this scenario is image compression, why is the picture compression? first, because the current user is basically, a figure 1 is. Second, the user 's network status isn't great, although user 3g is very common, 4 g size, wifi hot spot, but the upload of a large number of. Again, users may not be willing to wait so long. Where's the solution? the answer is the front end compression, where the author commonly used, is LRZ download address as follows

...