简体   繁体   English

jQuery或Javascript客户端图像在上传之前调整大小

[英]jQuery or Javascript client side image resize before upload

Is there a way to resize images client side before upload (when the user clicks the upload button) so that all fields with data-type="image" will execute resizing to the specified dimensions and then commit the upload? 有没有办法在上载之前调整图像客户端的大小(当用户单击上传按钮时),以便所有具有data-type="image"字段将执行调整大小到指定的维度,然后提交上传?

I'm working on a mobile compatible app where users have often to upload images using their mobile camera. 我正在开发一个移动兼容的应用程序,用户经常使用他们的移动相机上传图像。 It's necessary to reduce the image on client-side to perform quicker uploads of the photos to the server to reduce upload time. 有必要减少客户端的图像,以便更快地将照片上传到服务器,以减少上传时间。

Thanks. 谢谢。

There is a way to do this with plan JS by using canvas capabilities of HTML5. 有一种方法可以通过使用HTML5的canvas功能来实现计划JS。

Refere to this answer: JavaScript reduce the size and quality of image with based64 encoded code 参考这个答案: JavaScript使用基于64位编码的代码减少了图像的大小和质量

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM