Vue-Advanced-cropper裁剪大小的图像大于原始图像
我正在实施一个系统,用户选择图像,他必须在保存之前裁剪它;我使用Vue-Advance-Cropper
插件;所有系统均已设置,但结果图像尺寸大于原始系统。
示例:i在307KO插入图像,我得到448KO;我在40ko上插入图像,我获得了206KO;
是否有任何选择使结果尺寸要小于原件的尺寸要小,或者没有什么可以做什么?
I'm implementing a system where user choose image, he must crop it before save; i'm using vue-advance-cropper
plugin; all system is setted up but the result image sized is bigger than the original;
example: i insert image at 307ko i got 448ko; i insert image at 40ko i got 206ko;
is there any option that i missed to make the result lesser size than the original or is there not anything can be done?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
摘要
我想所描述的问题与使用的库没有任何常见。
在裁剪图像格式和原始图像格式之间的差异中,裁剪图像大小大于原始图像大小的最常见原因。
澄清它。如果您上传
JPEG
图像,请裁剪并从toblob
方法,您将默认情况下获得png
图像,因此显然它将比原始图像更大在大多数情况下。那是因为
toblob
从画布创建了一个全新的图像,并且对原始图像属性一无所知。因此,您无法通过这种方法的性质创建原始图像的确切副本,包括其大小。好消息是您可以更接近原始图像。
toblob
方法具有以下签名:因此,您可以设置相同的类型和图像质量的合理值。
解决方案
vue-advanced-cropper
文档。我将显示它的完整版本:此示例将帮助您使Cropper结果大小非常接近原始图像大小。您可以在带有上面代码的较轻版本。
Abstract
I suppose that the described problem has nothing common with the used library.
The most common reason that a cropped image size is larger than an original image size in the difference between a cropped image format and an original image format.
To clarify it. If you upload a
jpeg
image, crop it and get it from the cropper canvas bytoBlob
method, you will get apng
image by default, so it's obviously will be larger than an original image in the most of cases.That's because
toBlob
creates a completely new image from the canvas and it know nothing about original image properties. So you can't create the exact copy of the original image, including its size, by the nature of this approach.The good news is that you can get closer to an original image.
The
toBlob
method has the following signature:So, you can set the same type and the reasonable value of an image quality.
Solution
There is the image uploading example in the
vue-advanced-cropper
documentation. I will show the full version of it bellow:This example will help you make the cropper result size pretty close to the original image size. You can test it online in the sandbox with the lighter version of the code above.