简体   繁体   English

角度裁剪的图像文件大小变大

[英]Angular cropped image file size become bigger

I'm using this plugin angular-image-cropper to crop my image and ng-file-upload to upload my image. 我正在使用此插件angular-image-cropper裁剪图像,并使用ng-file-upload上传图片。

The problem is let say my image dimension is 1955px * 1300px with size around 194kb. 问题是我的图像尺寸为1955px * 1300px,大小约为194kb。

After I crop to 800px * 450px the size become around 550kb. 在裁剪为800px * 450px之后,大小变为550kb。

is this correct? 这个对吗? because it become almost 4 times bigger from it's original size 因为它比原来的尺寸大了将近4倍

my html code: 我的html代码:

<div class="form-group">
     <label class="control-label">Cover</label>
     <input type="file" ngf-select="uploadFiles($files,$invalidFiles)" name="cover" id="cover" ngf-pattern="image/*" accept="image/*"
       ng-model="upload.coverSource" ngf-max-size="512KB" ngf-min-width="800" img-cropper-fileread image="upload.coverSource"
       disable-invalid-styling="true" disable-valid-styling="true">

      <canvas ng-show="upload.coverSource" width="500" height="281" id="canvas" image-cropper image="upload.coverSource"
        cropped-image="category.coverCrop" crop-width="800" crop-height="450" keep-aspect="true" crop-area-bounds="bounds">
      </canvas>
</div>

Inside my angular I just tried to console.log both of them: 在我的角度内,我只是尝试console.log他们两个:

console.log($scope.upload.coverSource);

// and i need to convert it to blob first to get the data.
// category.coverCrop value is in data:base64

var cover = Upload.dataUrltoBlob(category.coverCrop);
console.log(cover);

Here is the result screenshot: 这是结果屏幕截图:

截图

Any solution to make the size same or lesser? 有什么解决方法可以使尺寸相同或更小?

In most of the croppers that I've tested, the resulting image gets translated into a raw format making it bigger, in the case of your info, look that the image is in its raw base64 format, also here is an example of a pretty advanced editor that has a similar result: https://www.photoeditorsdk.com/ the thing is that compresion or any further processing is a different task than cropping, and is not usually handled by this libs; 在我测试过的大多数农作物中,生成的图像都会转换为原始格式,从而使其变大,就您的信息而言,看起来该图像是原始base64格式,这也是一个漂亮的示例具有类似结果的高级编辑器: https ://www.photoeditorsdk.com/事实是,压缩或任何进一步的处理都是与裁剪不同的任务,通常不由此库处理; so how you solve it? 那你怎么解决呢? In our case, we integrate with cloudinary.com and use their transformation API to make sure all our images has the right size and quality. 在我们的案例中,我们与cloudinary.com集成并使用其转换API确保我们所有图像的大小和质量都正确。

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

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