cordova-plugin-image-resizer icon indicating copy to clipboard operation
cordova-plugin-image-resizer copied to clipboard

Aspect ratio in IOS

Open vazad28 opened this issue 9 years ago • 6 comments

Am I correct in my impression that the plugin does not keep the aspect ratio of the resized image in ios. In android the aspect ratio is maintained but not so in ios. If true is there a way we can keep the aspect ration as we resize in ios.

vazad28 avatar Nov 21 '16 14:11 vazad28

it seems that there are a lot of troubles in the iOS part... If I have some time I would rewrite it maybe in swift if it's possible.

JoschkaSchulz avatar Nov 22 '16 13:11 JoschkaSchulz

I also have this issue in ios where images after resize don't have the correct aspect ratio. Is there any updates or workaround on this @vazad28 ?

ourarash avatar Nov 05 '17 17:11 ourarash

Here, all viceversa, i need at android to change aspect ratio. If i provide height and width then probably best to change aspect ratio to provided sizes, and if provide just width or just height, then keep aspect ratio as in source.

pyummm avatar Dec 24 '17 13:12 pyummm

@ourarash a workaround is to create an Image object from original one to check its dimensions and calculate the aspect ratio. Then you can resize setting for example the width and calculating the height to keep the aspect ratio.

let img = new Image();
img.onload = () => {
  // Calculate aspect ratio
  let aspectRatio = img.width / img.height;

  let options = {
      uri: uri,
      folderName: 'demo',
      fileName: 'resized.jpg',
      quality: 90,
      width: 700,
      height: 700/aspectRatio
  } as ImageResizerOptions;

  this.imageResizer
      .resize(options)
      .then((filePath) => {
          ...
  });
};

img.src = imageData;

guillermogfer avatar Feb 19 '18 10:02 guillermogfer

Any news on this? @guillermogfer your solution doesn't work and sometimes app crashes if the image is very large

JustasKuizinas avatar Sep 23 '18 21:09 JustasKuizinas

Good day, any update on this yet for Ionic 3.

Vane101 avatar Jul 23 '19 13:07 Vane101