Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
570 views
in Technique[技术] by (71.8m points)

android - Why image auto rotate when set to Imageview with Picasso

I take photo bt camera on mode landscape, after upload to server...It was landscape to.

But when i load to imageview then display vertical like below image: enter image description here

I using Picasso to load image to Imageview.I want display like original image on ImageView... Please suggest for me...tks so much!

public static void makeImageRequest(Context context, ImageView imageView, final String imageUrl, ProgressBar progressBar) {
        final int defaultImageResId = R.drawable.ic_member;
        Picasso.with(context)
                .load(imageUrl)
                .error(defaultImageResId)
                .resize(80, 80)
                .into(imageView);
                }

ImageView:

<ImageView
                                android:layout_centerInParent="true"
                                android:padding="@dimen/_8sdp"
                                android:id="@+id/img_photo"
                                android:layout_width="@dimen/_80sdp"
                                android:layout_height="@dimen/_80sdp"
                                android:layout_gravity="center"
                                android:scaleType="fitCenter"
                                android:adjustViewBounds="true" />

URL:

https://arubaitobsv.s3-ap-northeast-1.amazonaws.com/images/1487816629838-20170223_092312_HDR.jpg
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

The problem issued here

Picasso auto rotates by 90 degrees an image coming from the web that has the following EXIF data:

Resolution : 3264 x 2448
Orientation : rotate 90

try this code with picasso:

Picasso.with(MainActivity.this)
    .load(imageURL) // web image url
    .fit().centerInside()
    .transform(transformation)
    .rotate(90)                    //if you want to rotate by 90 degrees
    .error(R.drawable.ic_launcher)
    .placeholder(R.drawable.ic_launcher)
    .into(imageview)
    });

You can also use Glide:

    dependencies {
  // Your app's other dependencies
  compile 'com.github.bumptech.glide:glide.3.7.0'
}

laod image using:

Glide.with(this).load("image_url").into(imageView);

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...