widthとheightが逆?
以下の様なコードでwidth、heightを取得したら
どう見ても縦長の画像なのにwidthのほうが大きい。。。
BitmapFactory.Options options = new BitmapFactory.Options();
BitmapFactory.decodeFile(imagePath, options);
int width = options.outWidth;
int height = options.outHeight;
結果
色々調べた結果、この画像のExifには”向きは90°回転だよ”って情報が入ってました。
try {
ExifInterface ex = new ExifInterface(imagePath);
// orienatation定義
// 1 そのまま
// 2 上下反転(上下鏡像?)
// 3 180度回転
// 4 左右反転
// 5 上下反転、時計周りに270度回転
// 6 時計周りに90度回転
// 7 上下反転、時計周りに90度回転
// 8 時計周りに270度回転
String orientation = ex.getAttribute(ExifInterface.TAG_ORIENTATION);
// →orientationが6だった
} catch (IOException e) {
}
なるほど、この場合、BitmapFactoryでは回転前の縦横長さが返ってきてたようですね。