callstack / react-native-image-editor

A library providing an API for cropping images from the web and the local file system.
MIT License
379 stars 118 forks source link

Output size of ImageEditor.cropImage become smaller #45

Closed mingxin-yang closed 8 months ago

mingxin-yang commented 4 years ago

Bug

Output size of ImageEditor.cropImage become smaller

Environment info

React native info output:

 // paste it here

Library version: 2.1.0

Steps To Reproduce

my code:

    const cropData = {
      offset: { x, y },
      size: { width, height },
      displaySize:{width,height},
      resizeMode: "cover"
    };
    RNFS.stat(this.props.imageUri).then((value)=>{
      console.warn("this.props.imageUri",value) // size is 2302015
    })
    console.warn("imageUri",this.props.imageUri,this.state.rotation);
    RNImageRotate.rotateImage(
      this.props.imageUri,
      this.state.rotation,
      rotatedUri => {
        ImageEditor.cropImage(
          this.props.imageUri,
          cropData,
          croppedUri => {
           RNFS.stat(croppedUri).then((value)=>{
                 console.warn("croppedUri",value) // size is 818649
            })
            this.props.onDone(croppedUri);
          },
          err => {
            console.log("cropping error");
            console.log(err);
          }
        );

      },
      err => {
        alert(err);
        console.log(err);
      }
    );

Describe what you expected to happen:

when the width and height is origin of the image, output size is 2302015

Reproducible sample code

linhmimoza commented 4 years ago

try displaySize: {width 4 ,height 4} It worked for me

s123121 commented 4 years ago

I have tried various combination, one thing stood out to me is the cropped image quality is always degraded compared to the input ( which you can see clearly with your eyes)

retyui commented 8 months ago

3.1.0 releases include a new feature: number prop that lets you adjust the size of the picture. That should solve your issue