Croppie icon indicating copy to clipboard operation
Croppie copied to clipboard

How can i keep the quality original image after cropping ?

Open lminhphuongtma opened this issue 8 years ago • 8 comments

I have a original image with resolution 96(pixels/inch). After cropping the new picture just have 72 (pixels/inch). Will I be able to use Croppies to crop photos without losing quality? ---INFO: Original Image:

  • width x height: 1000x565
  • resolution: 96 Pixels/inch New Image:
  • width x heigth: 330 x205 = viewport
  • resolution: 72 Pixels/inch $uploadCrop.croppie('result', { type: 'canvas', size: 'viewport', quality:1 }).then(function (resp) { if(resp != 'data:,') $('#imgReview').attr("src",resp); });

lminhphuongtma avatar Dec 13 '17 09:12 lminhphuongtma

You can change your size from size: 'viewport' to size: 'original' ' to keep the original image's quality

AlexanderLyon avatar Apr 19 '18 15:04 AlexanderLyon

no it doesn't ...

if you set the

viewport: { width: 200, height: 200 }, boundary: { width: 250, height: 250 }

on a image of 1000x1000 pixels

when crop with :

vanilla.result( 'canvas' , 'original' , 'jpeg' , 1 , false )

it will save an image of 200x200

... any news on this ?

ghost avatar Jun 14 '18 13:06 ghost

@lminhphuongtma This may be because of how big the size difference is, I've heard of other people experiencing this. We might be able to overcome it by incrementally scaling down our canvas. Currently we just go from image dimensions to output dimensions. This SO post could be a starting point: https://stackoverflow.com/questions/28498014/canvas-drawimage-poor-quality

@ilmetu , your post is a little too vague. If that's really how you're using the result method, you're using it wrong. Result takes in an object, not multiple arguments.

vanilla.result({type: 'canvas', size: 'original', format: 'jpeg', quality: 1, circle: false });

thedustinsmith avatar Jun 14 '18 13:06 thedustinsmith

yes sorry my fault ! it works like a charm 👍

ghost avatar Jun 14 '18 13:06 ghost

@thedustinsmith , it didn't work to me.

`$image_crop = $('#image_demo').croppie({ enableExif: true, viewport: { width:270, height:180, type:'square' //circle }, boundary:{ width:300, height:300 } });

		  $image_crop.result({type: 'canvas', size: 'original', format: 'jpeg', quality: 1, circle: false });`

Can you help me?

vini2001 avatar Aug 06 '18 20:08 vini2001

You can change your size from size: 'viewport' to size: 'original' ' to keep the original image's quality

Doesn't that ignore cropping, just keeps an original image?

alissonalberini avatar Sep 04 '19 14:09 alissonalberini

You can change your size from size: 'viewport' to size: 'original' ' to keep the original image's quality

Doesn't that ignore cropping, just keeps an original image?

No, this is about the size, not the proportion or the cropping.

vini2001 avatar Sep 04 '19 15:09 vini2001

I am still struggling here

cropper setting

$uploadCrop = $("#upload-demo").croppie({
                        viewport: {
                          width: 1000,
                          height: 567,
                          type: "rectangle",
                          visible: true
                        },
                        boundary: { width: 1200, height: 675 },
                        
                       
                       
                      });
                      
 $uploadCrop.croppie('result', {
                               type: 'base64',
                               format: 'png',
                               quality: 1.0,
                               size:'original'
                           })
                           

Say for example if image is of 1600x1000 pixel the cropped version is not of same I want cropped version to be of same width and height

Harsh4999 avatar Apr 02 '23 21:04 Harsh4999