Correctly rotate and flip image using Exif attributes. - #443
vanniktech wants to merge 1 commit into
Conversation
|
|
||
| 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.
| } | ||
| } catch (ignored: Exception) { | ||
| fun orientateBitmapByExif(bitmap: Bitmap?, context: Context, uri: Uri): RotateBitmapResult { | ||
| val exifInterface = context.contentResolver.openInputStream(uri)?.use { ExifInterface(it) } |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
calling rotateAndFlipBitmapInt is the fix and once we've flipped and rotated we no longer need to rotate / flip hence 0, false, false
|
Hmm seems like cropping afterwards is broken. Will need to dig a bit further |
|
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 |
|
This should already be good to go right? |
|
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. |
|
I'll get back to it in the future. |
Fixes #439