1、// //获取图片真正的宽高,不读入内存
// BitmapFactory.Options options = new BitmapFactory.Options();
// options.inJustDecodeBounds = true;
// Bitmap bitmap = BitmapFactory.decodeFile(path, options);
// options.inSampleSize = 1;
// options.inJustDecodeBounds = false;
//
// int width = options.outWidth;
// int height = options.outHeight;
第二种
// Glide.with(BottomDialogFragment.this.getContext())
// .load(p.getImgUrl())
// .asBitmap()//强制Glide返回一个Bitmap对象
// .into(new SimpleTarget<Bitmap>() {
// @Override
// public void onResourceReady(Bitmap bitmap, GlideAnimation<? super Bitmap> glideAnimation) {
// int width = bitmap.getWidth();
// int height = bitmap.getHeight();
// Log.e("xudong3","====================");
// Log.e("xudong3",p.getImgUrl());
// Log.e("xudong3", "width " + width); //200px
// Log.e("xudong3", "height " + height); //200px
// }
// });
第三种
ExifInterface exifInterface = new ExifInterface(path);
int rotation = exifInterface.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL);
int width = exifInterface.getAttributeInt(ExifInterface.TAG_IMAGE_WIDTH, 0);
int height = exifInterface.getAttributeInt(ExifInterface.TAG_IMAGE_LENGTH, 0);
if (rotation == ExifInterface.ORIENTATION_ROTATE_90 || rotation == ExifInterface.ORIENTATION_ROTATE_270) {
// 图片被旋转90或者270,使用时候将width、height换下
int temp = height;
height = width;
width = temp;
}else {
// 宽高对应
}