Croppie icon indicating copy to clipboard operation
Croppie copied to clipboard

Image size (in kb) is getting increased

Open angshujit opened this issue 8 years ago • 7 comments

Hello,

We tried to use Croppie in our application. We used basic settings and be able to incorporate correctly. However after cropping the image size is getting increased. Say we uploaded a image of 100kb. Now we cropped one part of it. When we ware checking the raw output we found that size of the image was around 110kb (though it was a part of the image). If we zoom in the image before cropping the size is getting increased by 4-5 times!.

Can you please let me know what we are doing wrong, and how to solve the issue.

angshujit avatar Feb 28 '17 07:02 angshujit

Have a look at the "result" method.

MentalGear avatar Mar 02 '17 14:03 MentalGear

I'm also facing the issue. For my case, the size is growing to almost 4-5 times. This is the result format I'm using:

$uploadCrop.croppie('result', 'blob').then(function (resp) { 
    popupResult({ 
      src: resp 
    }); 
  });

avi885 avatar Apr 28 '17 19:04 avi885

It's happening the same to me. We want to only work with jpeg. A 10MB input image outputs a 12xMB image (with Chrome, inspecting the network, i see a 125MB Content Length).

Our croppie is the same as @avi885

$uploadCrop.croppie('result', 'blob').then(function (resp) { popupResult({ src: resp }); });

JOGUI22 avatar Jun 09 '17 10:06 JOGUI22

I had the same problem and came to this conclusion:

The JPG I used was stored compressed with reduced file size but once you load it in the browser it gets uncompressed to be viewed. This uncompressed BLOB is what croppie deals with and its size basically the original size of the uncompressed image.

I used a image from my DSLR with an resolution of 4000*3000 pixels. The JPG size was around 7 MB but the BLOB returned from croppie was around 22MB

The easy for me was to configure the size croppie should output via the options passed to the result method:

croppie.cropper.result(
      {
        type:   'blob',
        size:   {
          width:  740,
          height: undefined,
        },
        format: 'jpeg',
        quality:0.8,
      });

This gave me the image in the desire size at around 1MB If you do not want a fixed width, have a look at the other options possible for the size option

lukas-zech-software avatar Jul 24 '17 17:07 lukas-zech-software

I have the same issue. Following is my result method. I'm going to upload cropped image to sever. Currently, I'm using blob. will it decrease the size of cropped image, by using other type like canvas?

crop.croppie('result', { type: 'blob', format: 'png', circle: false, quality: 1, size: image_type == 'avatar' ? undefined : 'original' })

ericlormul avatar Aug 15 '17 18:08 ericlormul

Same issue after 3 years and we got some satisfaction with lukas-zech-software answer, looks like repository is no longer maintained.

ismailansari avatar Jul 24 '20 06:07 ismailansari

I had a similar issue. I changed my format from 'jpg' to 'jpeg' in the results call and the compression worked very well.

Jonathan2313 avatar Nov 16 '22 08:11 Jonathan2313