Search code examples
androidimagecrop

Cropping image in a given square size in Android?


I am using this library simplecropimage this works fine but I want the cropping area in a square(in this it can be resizable and rectangular) and the square can be move. I want to crop the image in a square keeping the same aspect ratio.


Solution

  • When you call your crop class using intent

    just use this

         Intent intent = new Intent(YOUR_CLASS.this, CropImage.class);
    
        // tell CropImage activity to look for image to crop
    
        intent.putExtra(CropImage.IMAGE_PATH, filePath);
    
        intent.putExtra(CropImage.SCALE, true);
    
        // use same aspect ratio for square size crop
        intent.putExtra(CropImage.ASPECT_X, 1);
        intent.putExtra(CropImage.ASPECT_Y, 1);
    
        startActivityForResult(intent, REQUEST_CODE);
    

    HOPE IT HELPS..!