Search code examples
android-studiokotlinpicasso

Kotlin: Loading Images using Picasso, Portrait Images Rotated by 90deg


I am allowing users to pick an image from the gallery, but when images are loaded into the application using Picasso they are rotated by 90deg(This is only happening to Portrait Images as Landscape ones are loading fine) can anyone offer a solution to this issue?

Code For Loading Images

 var selectedPhotoUri: Uri? = null

    override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
        super.onActivityResult(requestCode, resultCode, data)

        if (requestCode == 0 && resultCode == Activity.RESULT_OK && data != null) {

            selectedPhotoUri = data.data

            Picasso.get().load(selectedPhotoUri).into(profilePicture_preview)

            button_profilePicture.alpha = 0.3f

        }
    }

I am Loading this Image in Dog Image

However, the image is being displayed like this Image Display Result


Solution

  • After a few days of hopelessly struggling the solution I found was to stop using Picasso and use Glide, this works pretty much the same as Picasso and successfully displayed the Images in their correct orientation.