react-native-image-resizer icon indicating copy to clipboard operation
react-native-image-resizer copied to clipboard

The size of the image is changed after rotation (only on Android)

Open tiavina-mika opened this issue 3 years ago • 0 comments

When I rotate the image, the rotated image size has changed, normally the rotation should not affect the image size. It works fine in IOS.

original image before rotation:

width: 512 height: 628 image

image after rotation:

width: 500 height: 408 image

the code:

onRotateImage = () => {
  const layer = this.props.layer;
  const img = layer.image;

  ImageResizer.createResizedImage(`file://${img.url}`, 500, 500, 'JPEG', 100, (img.rotate + 270) % 360, undefined, true)
    .then((response) => {
      img.thumbnail_url = `file://${response.path}`;

     // the issue is here
      img.width = response.width;
      img.height = response.height;

      img.rotate = (img.rotate + 270) % 360;
      this.props.layer.image = img;
    })
    .catch(err => {
      console.error('[TemplateImageModal] Unable to resize camera image: ', err);
    });
}

tiavina-mika avatar Jan 07 '22 18:01 tiavina-mika