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:
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
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);
public class ImageRotationDetectionHelper {
public static int getCameraPhotoOrientation(String imageFilePath) {
int rotate = 0;
try {
ExifInterface exif;
exif = new ExifInterface(imageFilePath);
String exifOrientation = exif
.getAttribute(ExifInterface.TAG_ORIENTATION);
Log.d("exifOrientation", exifOrientation);
int orientation = exif.getAttributeInt(
ExifInterface.TAG_ORIENTATION,
ExifInterface.ORIENTATION_NORMAL);
Log.d(ImageRotationDetectionHelper.class.getSimpleName(), "orientation :" + orientation);
switch (orientation) {
case ExifInterface.ORIENTATION_ROTATE_270:
rotate = 270;
break;
case ExifInterface.ORIENTATION_ROTATE_180:
rotate = 180;
break;
case ExifInterface.ORIENTATION_ROTATE_90:
rotate = 90;
break;
}
} catch (IOException e) {
e.printStackTrace();
}
return rotate;
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With