4

I writting a application. My app will select photo from gallery. I use Picasso to load Image to ImageView.

Problem is Picasso auto rotate any photo captured from camera, but not rotate any image downloaded and saved to internal storage from internet

This is image download from internet:

enter image description here

This is photo captured from camera, Picasso auto rotate it, i want fix it:

enter image description here

This is my code:

picasso
       .load(uriPhoto)
       .resize(newWidthBitmap.toInt(), newHeightBitmap.toInt())
       .centerInside()
       //.rotate(90f)
       .into(target_image)
2
  • Do the images that are not getting autorotated have the required EXIF data that allows them to be autorotated?
    – LarsH
    Aug 20, 2018 at 17:54
  • I use EXIF to get degrees, but all image is 0 degrees
    – mducc
    Aug 20, 2018 at 17:57

1 Answer 1

4

First cross check that your camera image bitmap is rotated or not because some phones like samsung s4 rotates image 90 degree when taking image from camera. If image not rotated then use glide for loading image because picasso rotates image to 90 degree when it's size is bigger.

For Glide there is documentation how to use : https://github.com/bumptech/glide

Gradle:

root:

repositories {
  mavenCentral()
  google()
}

app:

dependencies {
  implementation 'com.github.bumptech.glide:glide:4.8.0'
  annotationProcessor 'com.github.bumptech.glide:compiler:4.8.0'
}

How to set your uri data on glide:

Glide.with(mContext)
    .load(new File(pictureUri.getPath())) // Uri of the picture
    .transform(new CircleTransform(..))
    .into(image);
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.