btastic / flutter_native_image

Native Flutter Image tools
Other
340 stars 138 forks source link

Correct way to use cropImage #75

Open ricardonior29 opened 4 years ago

ricardonior29 commented 4 years ago

Can someone explain to me how to use the cropImage function please..

<< FlutterNativeImage.cropImage(file.path, originX, originY, width, height); >> What means originX, originY, what if with>height... things like that.

Constantly i get this error: java.lang.IllegalArgumentException: x + width must be <= bitmap.width() Thanks.

btastic commented 3 years ago

@a-leblond did this feature. Can you maybe tell him, what he is doing wrong?

a-leblond commented 3 years ago

Hi,

If i remember correctly originX, originY are the coordinates of the top left corner where you want your cropped image to start, and width and height the desired size of the cropped image.

So if you have an image 120px width and 100px height, and you want to crop a square of 100px taking full height but centered horizontally, it should be originX = 10, originY = 0, height = 100, width = 100. This will crop a square, removing 10px at the start of the image and 10px at the end.