-
Notifications
You must be signed in to change notification settings - Fork 59
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
exif tags not honored when applying image preprocessing chain #99
Comments
Hey @jdale38, Could you please add the steps to reproduce this issue? Thanks |
Steps:
Let me know if there's anything else I can shed some light on. Thanks, |
Hi @jdale38. We've forwarded this issue to our engineers to review. Updates to follow. |
@roeeba thank you! Let me know if there's any other info you and your team needs. |
Hi @jdale38. We've tried to recreate the issue (tested on real device and the emulator as per their spec; pixel 2, android 9) and we didn't see an issue with the rotation of the image. EXIF data is indeed not retained (seems like a minor issue, which we'll investigate) but the rotation is still handled correctly automatically. |
here is how I solved missing rotation public int getExifAngle(String filePath) {
int angle = 0;
try {
ExifInterface exif = new ExifInterface(filePath);
int orientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, 1);
Log.d("EXIF", "Exif: " + orientation);
switch (orientation) {
case ExifInterface.ORIENTATION_ROTATE_90:
angle = 90;
break;
case ExifInterface.ORIENTATION_ROTATE_180:
angle = 180;
break;
case ExifInterface.ORIENTATION_ROTATE_270:
angle = 270;
break;
}
} catch (IOException e) {
e.printStackTrace();
}
return angle;
}
// ------
....
uploadRequest.preprocess(
ImagePreprocessChain.limitDimensionsChain(MAX_IMAGE_DIMENSION, MAX_IMAGE_DIMENSION)
.addStep(new DimensionsValidator(10, 10, MAX_IMAGE_DIMENSION, MAX_IMAGE_DIMENSION))
.addStep(new Rotate(angle))
.saveWith(new BitmapEncoder(BitmapEncoder.Format.JPEG, 80)) |
@dimaportenko Thank you for the update. We will have a look into it. |
It looks like
BitmapDecoder
used inImageProcessChain
does not rotate images with the included exif orientation tags on a photo. Not including any preprocessing chains for photo uploads resolves this issue.A possible solution -> applying
Matrix#postRotate()
with a newly created bitmap during bitmap decoding (https://github.com/cloudinary/cloudinary_android/blob/master/lib/src/main/java/com/cloudinary/android/preprocess/BitmapDecoder.java#L82).Device info:
Android 9
Pixel 2 emulator
SDK info:
1.26.0
The text was updated successfully, but these errors were encountered: