Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Aspect ratio in IOS #19

Open
vazad28 opened this issue Nov 21, 2016 · 6 comments
Open

Aspect ratio in IOS #19

vazad28 opened this issue Nov 21, 2016 · 6 comments
Labels

Comments

@vazad28
Copy link

vazad28 commented Nov 21, 2016

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.

@JoschkaSchulz
Copy link
Owner

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.

@ourarash
Copy link

ourarash commented Nov 5, 2017

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 ?

@pyummm
Copy link

pyummm commented Dec 24, 2017

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.

@guillermogfer
Copy link

@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;

@JustasKuizinas
Copy link

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

@Vane101
Copy link

Vane101 commented Jul 23, 2019

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

7 participants