Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

imageCaptureBuild Image rotate #44

Open
developerGM opened this issue Oct 25, 2023 · 4 comments
Open

imageCaptureBuild Image rotate #44

developerGM opened this issue Oct 25, 2023 · 4 comments

Comments

@developerGM
Copy link

Hi,
I am testing your library, really usefully, thanks

I am using new FilePicker.Builder(mContext).imageCaptureBuild(new ImageCaptureConfig())
and I am receiving an image with a 90° rotation

@ChochaNaresh
Copy link
Owner

Hi @developerGM
Please provide more details about the library version and phone details.

@developerGM
Copy link
Author

Hi,
the library version is 0.2.2

Mobile phone: Xiaomi 9T, Android 10

@developerGM
Copy link
Author

Hi @ChochaNaresh
any news about this issue?

@ChochaNaresh
Copy link
Owner

Hi @developerGM

You can use the following code to find the rotation, then save the rotation picture as a new file to resolve your issue.

`
String selectedImage = data.getData();
String[] filePathColumn = {MediaStore.Images.Media.DATA};

Cursor cursor = getContentResolver().query(selectedImage, filePathColumn, null, null, null);
cursor.moveToFirst();

int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
filePath = cursor.getString(columnIndex);
cursor.close();

int rotateImage = getCameraPhotoOrientation(MyActivity.this, selectedImage, filePath);
`

`
public int getCameraPhotoOrientation(Context context, Uri imageUri, String imagePath){
int rotate = 0;
try {
context.getContentResolver().notifyChange(imageUri, null);
File imageFile = new File(imagePath);

    ExifInterface exif = new ExifInterface(imageFile.getAbsolutePath());
    int orientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL);

    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;
    }

    Log.i("RotateImage", "Exif orientation: " + orientation);
    Log.i("RotateImage", "Rotate value: " + rotate);
} catch (Exception e) {
    e.printStackTrace();
}
return rotate;

}
`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants