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

Correctly rotate and flip image using Exif attributes. #443

Closed
wants to merge 1 commit into from
Closed

Correctly rotate and flip image using Exif attributes. #443

wants to merge 1 commit into from

Conversation

vanniktech
Copy link
Contributor

Fixes #439

@vanniktech vanniktech requested a review from a team as a code owner September 28, 2022 09:42

return when (bitmap) {
null -> RotateBitmapResult(null, degrees, flipHorizontally, flipVertically)
else -> RotateBitmapResult(rotateAndFlipBitmapInt(bitmap, degrees, flipHorizontally, flipVertically), 0, false, false)

Check warning

Code scanning / detekt

Line detected that is longer than the defined maximum line length in the code style.

Line detected that is longer than the defined maximum line length in the code style.
}
} catch (ignored: Exception) {
fun orientateBitmapByExif(bitmap: Bitmap?, context: Context, uri: Uri): RotateBitmapResult {
val exifInterface = context.contentResolver.openInputStream(uri)?.use { ExifInterface(it) }
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now we close every single time just like in #440


return when (bitmap) {
null -> RotateBitmapResult(null, degrees, flipHorizontally, flipVertically)
else -> RotateBitmapResult(rotateAndFlipBitmapInt(bitmap, degrees, flipHorizontally, flipVertically), 0, false, false)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

calling rotateAndFlipBitmapInt is the fix and once we've flipped and rotated we no longer need to rotate / flip hence 0, false, false

@vanniktech vanniktech marked this pull request as draft September 28, 2022 10:10
@vanniktech
Copy link
Contributor Author

Hmm seems like cropping afterwards is broken. Will need to dig a bit further

@vanniktech
Copy link
Contributor Author

I've tried but I gave up for now. The moment I change something, another feature breaks. It seems like everything is calibrated to behave on certain not so true data.

For the time being, I'll just copy what's inside rotateAndFlipBitmapInt and do that before passing a bitmap / uri to the library, then it works 🤷

@basurahan
Copy link

This should already be good to go right?

@vanniktech
Copy link
Contributor Author

Unfortuantely not. The cropping logic which crops the image after you've resized / rotated ect relies on the broken image and when fixing it and rotating it, like I've done here the output is just wrong. I haven't had time to look into this yet plus I've got my workaround which seems to be working.

@vanniktech vanniktech closed this by deleting the head repository Oct 19, 2022
@vanniktech
Copy link
Contributor Author

I'll get back to it in the future.

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

Successfully merging this pull request may close these issues.

[BUG] - CropRect has mixed up width / height ⚠️ ⚠️
2 participants