Crop the shape of a square Android image in an application

I want to create an application that allows the user to resize the image in the form of a square (length = width).

I know that you can use the gallery to do this as follows:

private void crop(Uri photoUri) { Intent intent = new Intent("com.android.camera.action.CROP"); intent.setData(photoUri); intent.putExtra("outputX", 200); intent.putExtra("outputY", 200); intent.putExtra("aspectX", 1); intent.putExtra("aspectY", 1); intent.putExtra("scale", true); intent.putExtra("return-data", true); startActivityForResult(intent, RESULT_CROP); } 

But I would like to know if there is a library that allows you to do this directly in the application?

Thanks in advance!

+6
source share
2 answers

I found my solution here , but I accept other answers !!

Cropper

+11
source

I used this library https://arthurhub.imtqy.com/Android-Image-Cropper/

See the sample code in the sample project in addition to the fact that you have to correct the aspect ratio and set the scale to 1.

 cropImageView.setFixedAspectRatio(true); cropImageView.setScaleX(1.0f); cropImageView.setScaleY(1.0f); 
0
source

Source: https://habr.com/ru/post/945184/


All Articles