私はしばらくの間EXIFを把握しようとしていましたが、問題の後、問題があっただけです。私は誰かが私のためにこれについていくつかの光を当てることができることを望んでいます。Exif情報ローテーションファイルが見つかりません例外
は、私は、ユーザーが押したボタンを持っており、それはここで
private int PICK_IMAGE_REQUEST = 1;
を次の私のOnActivityResultあるようPICK_IMAGE_REQUESTがある。この目的
Intent intent = new Intent();
// Show only images, no videos or anything else
intent.setType("image/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
// Always show the chooser (if there are multiple options available)
startActivityForResult(Intent.createChooser(intent, "Select Picture"), PICK_IMAGE_REQUEST);
ありません。
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == PICK_IMAGE_REQUEST && resultCode == RESULT_OK && data != null && data.getData() != null) {
mMediaUri = data.getData();
try {
Bitmap bitmap = MediaStore.Images.Media.getBitmap(getContentResolver(), mMediaUri);
String fileName2 = FileHelper.getFileName(UserProfileActivity.this, mMediaUri, "image");
try {
ExifInterface exifInterface = new ExifInterface(fileName2);
int orientation = exifInterface.getAttributeInt(ExifInterface.TAG_ORIENTATION, 1);
System.out.println(orientation + "---------------------------");
Matrix matrix = new Matrix();
if (orientation == 6) {
System.out.println("oritation 6, rotate 90");
matrix.postRotate(90);
} else if (orientation == 3) {
System.out.println("oritation 3, rotate 180");
matrix.postRotate(180);
} else if (orientation == 8) {
System.out.println("oritation 8, rotate 270");
matrix.postRotate(270);
}
bitmap = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, true);
} catch (Exception e) {
System.out.println(e.getMessage());
}
//friendsProfilePic imageView = (ImageView) findViewById(R.id.imageView);
if (userChangedImage){
userProfileImage.setImageBitmap(bitmap);
}
userProfileImageEditProfile.setImageBitmap(bitmap);
final ParseQuery<ParseUser> queryUser = ParseUser.getQuery();
try {
byte[] fileBytes = FileHelper.getByteArrayFromFile(UserProfileActivity.this, mMediaUri);
if (fileBytes == null) {
//there was an error
Toast.makeText(getApplicationContext(), "There was an error. Try again!", Toast.LENGTH_LONG).show();
} else {
fileBytes = FileHelper.reduceImageForUpload(fileBytes);
String fileName = FileHelper.getFileName(UserProfileActivity.this, mMediaUri, "image");
userChangedImageFile = new ParseFile(fileName, fileBytes);
userChangedImage = true;
}
} catch (Exception e1) {
e1.printStackTrace();
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
最後に、これはコンソールの内部を読み込んでいます。
System.out: image.png (No such file or directory)
これについてのお手伝いがあれば幸いです! ありがとう
をすべき回避URIパスで(
ContentResolver
から)InputStream
でExifInterface(PIOR API < 24)をインスタンス化することができるようになりますコードをデバッグして、実際にdata.getData()がどのように見えるかを確認してください。 – Ridcully