mducc
mducc

Reputation: 743

Picasso auto rotate photo captured from camera, but not rotate image downloaded from internet

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)

Upvotes: 4

Views: 2501

Answers (1)

Erselan Khan
Erselan Khan

Reputation: 845

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);

Upvotes: 4

Related Questions