最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Compress image at client side (angularjs) and upload to server(nodejs) - Stack Overflow

programmeradmin0浏览0评论

I am using ng-file-upload directive to upload files to nodejs in my application. Now, I am trying to press the image before uploading. To do that I have tried using press method of Java Image Compress(JIC) library. It is successfully pressing an image. Now, the problem is, I have to send a file object to my server(nodejs) but press method returns an image with src attribute. Is there any way to get file object with url? or any other alternative way of achieving press at angularjs and upload to nodejs? Any help appreciated.

I am using ng-file-upload directive to upload files to nodejs in my application. Now, I am trying to press the image before uploading. To do that I have tried using press method of Java Image Compress(JIC) library. It is successfully pressing an image. Now, the problem is, I have to send a file object to my server(nodejs) but press method returns an image with src attribute. Is there any way to get file object with url? or any other alternative way of achieving press at angularjs and upload to nodejs? Any help appreciated.

Share Improve this question asked Jul 14, 2015 at 6:42 Suresh KotaSuresh Kota 3151 gold badge6 silver badges20 bronze badges 2
  • According to your description, you have JRE on the client site. Could not you upload it to your node server right after pression from java? – Mirek Surma Commented Jul 14, 2015 at 6:51
  • I could not... It says 'request entity too large' as I am trying to upload src attribute – Suresh Kota Commented Jul 14, 2015 at 6:57
Add a ment  | 

2 Answers 2

Reset to default 5

I think ng-image-press will solve your issue. To use this,

  • Download ng-image-press
  • Bower - bower install angular-image-press.
  • Include angular.js and angular-image-press.js in your application and add ngImageCompress as dependency to your main module.

angular.module('myApp', ['ngImageCompress']);

Then you can include "resize-max-height="800" resize-max-width="800" resize-quality="0.7" resize-type="image/jpg" ng-image-press " in your File Type input to press your image.

You can find more details from https://github./oukan/angular-image-press

set req headers Content-Encoding: gzip it will be pressed automatically

发布评论

评论列表(0)

  1. 暂无评论