I’m trying to crop image from photo library by adding allowEdit property. But I can’t set custom height and width. It always looks like square. I can’t setting up it to 400x600(for example).
Is it known problem or I’m doing something wrong?
For the code below I always get square image with 400px.
When specify targetWidth and targetHeight in Cordova Camera Plugin,
It always remains aspect ratio of selected image,
That’s why it always select image with square.
If you want to crop image without square format then,
Don’t specify targetWidth and targetHeight attributes.
There are several plugins available for crop image.
This is a great thread. Of the suggestion above, ngImgCrop seems to have the exact features I need, HOWEVER, I am having a heck of a time trying to get it to work properly in an $ionicModal view. There is something in the CSS that always seems to set the cropping canvas to around 100px x 100px instead of the width and height of the parent <div>.
I would appreciate it if anyone else who has played with ngImgCrop can give me a heads up…
Hi leob, ngImgCrop seems great. You say that this fork allows rectangle cropping, can you say more about this ? I’m stuck with the circle or square cropping. Thx !
ngImgCrop works great for me on both Android and iOS. However, you can’t do pinch to zoom, you must use the indicators in each corner. It works great, but when I showed my client it for the first time, they kept trying to pinch to crop/expand the selection and it seemed buggy. Once I showed them you just drag the corners, it worked great.
Possibly a small issue, but I just wanted to share my experience with this plugin. I highly recommend it.
Yes, the fork allows you to specify an aspect ratio in your Angular controller like this:
var relativeWidth = 3;
var relativeHeight = 1;
$scope.image = {
originalImage: image,
croppedImage: '',
aspectRatio: relativeWidth + "x" + relativeHeight
};
In this case, you get an aspect ratio of “3x1” (width is 3 times the height). If you want it the other way around you specify “1x3”. And the default (of you specify nothing) is “1x1” (square).
The README has instructions on how to install and run it (there’s also a Wiki with instructions specifically on the image functionality and how to configure/run it).
When specify targetWidth and targetHeight in Cordova Camera Plugin,
It always remains aspect ratio of selected image,
That’s why it always select image with square.
This doesn’t make sense. If you specify a width of 600 and a height of 400 and you get a square, what are the dimensions of the square?