Skip to content
This repository has been archived by the owner on Sep 27, 2020. It is now read-only.

New option "keepAspectRatio" #77

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open

Conversation

rastafan
Copy link

This PR adds a new option "keepAspectRatio", to manage the ability to change the cropped image's aspect ratio.

OLD BEHAVIOUR:
-Android : Aspect ratio il locked to 1:1 if targetWidth and targetHeight are equal or if both are -1, else it is not locked;
-iOS : Aspect ratio is always locked to the one specified by targetWidth:targetHeight

NEW BEHAVIOUR:
-Android AND iOS : If keepAspectRatio!=0, aspect ratio is locked to targetWidth:targetHeight (or 1:1 if they are equal). If KeepAspectRatio==0, the ratio is unlocked and can be modified as desired;

Also, on iOS, it now respects the size specified with targetWidth and targetHeight, instead of starting always with a square cropped image. If -1 is specified on one of the two dimension, that dimension is replaced by the picture corrisponding dimension.

This may be resolving #49, #50, #75 and #76

-new parameter: keepAspectRatio to edit aspect ratio
fix test keepAspectRatio
keepAspectRatio doc update
keepAspectRation on Android
On iOS, it now respects the size specified with targetWidth and targetHeight, instead of starting always with a square cropped image. If -1 is specified on one of the two dimension, that dimension is replaced by the picture corrisponding dimension.
version bump and install command fix
@rjurado01
Copy link

I have check it and it works, please merge !!

Thanks @rastafan

@mbenfriha
Copy link

how to use "keepAspectRatio" in ionic ?

@rjurado01
Copy link

rjurado01 commented Mar 5, 2020

@mbenfriha

plugins.crop(function success () {
}, function fail () {
}, '/path/to/image', {keepAspectRatio: 0})

See Readme: https://github.com/jeduan/cordova-plugin-crop/pull/77/files

Fixed crop ratio for iOS. Now it works in the same way as Android.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants