Search code examples
androidimagelistviewandroid-gallery

Multiple Image Crop Android


I am making an application that allows the user to upload multiple images from the gallery. The user selects the photos and they are displayed in a list view and the user clicks an upload button. It was working fine until i discovered some images were changing orientation on the list view and on upload. I asked around about the issue and someone told me that i had to allow for cropping before upload. Should i make the user crop every selected image from gallery or how should i go about it?

if (requestCode == SELECT_MULTIPLE_PHOTOS) {

        String imagesArray = data.getStringExtra(EXTRA_SELECTED_PHOTOS);//get Intent data

        //Convert string array into List by splitting by ',' and substring after '[' and before ']'
        List<String> selectedImages =
                Arrays.asList(imagesArray.substring(1, imagesArray.length() - 1)
                        .split(", "));

        Log.d(TAG, "Selected images is " + selectedImages.size());

        mPhotosPathList = new ArrayList<String>(selectedImages);

        Log.d(TAG, "Selected images path is " + mPhotosPathList.size());


    }

Solution

  • Get the image orientation. If it is not in the correct orientation, the get the correct orientation, Try this link