You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I want to crop the attached image using the image cropper. The original image has a size of 5.5KB. However, the resulting base64 of the cropped and minified image (also attached) has a size of 8KB. How is it possible that the cropped image size (150x150) is larger than the original's image (900x600) size.
myConfig: ImgCropperConfig = {
// autoCrop: true,
width: 150, // Default `250`
height: 150, // Default `200`
fill: '#ff2997', // Default transparent if type = png else #000
type: 'image/png' // Or you can also use `image/jpeg`
};
to
myConfig: ImgCropperConfig = {
// autoCrop: true,
width: 150, // Default `250`
height: 150, // Default `200`
fill: '#ff2997', // Default transparent if type = png else #000
type: 'image/jpeg' // Or you can also use `image/jpeg`
};
I uploaded the attached originalImage.jpg, clicked on "crop" and copied the resulting base64 code of the cropped image into the txt file. I converted the base64 code via https://onlinejpgtools.com/convert-base64-to-jpg and downloaded the cropped jpeg.
@xemedo With the given example it is expected that the size of the cropped image will be less, however, that did not happen xD.
So converting from Canvas to image does not optimize the result, but a little optimization can be done by setting the quality when cropping the image (not yet implemented).
But there are other options so that the resulting image is the most optimized. You can use sharp, use data from ImgCropperEvent to crop images on server side.
Minimal Reproduction
I want to crop the attached image using the image cropper. The original image has a size of 5.5KB. However, the resulting base64 of the cropped and minified image (also attached) has a size of 8KB. How is it possible that the cropped image size (150x150) is larger than the original's image (900x600) size.
Ways to reproduce: I used https://stackblitz.com/angular/vbbxkpkndnq?file=app%2Fimage-cropper-example-01.component.ts for this test.
I changed
to
I uploaded the attached originalImage.jpg, clicked on "crop" and copied the resulting base64 code of the cropped image into the txt file. I converted the base64 code via https://onlinejpgtools.com/convert-base64-to-jpg and downloaded the cropped jpeg.
Original image:
Cropped image:
Base64 code:
croppedbase64.txt
The text was updated successfully, but these errors were encountered: