Skip to content

Conversation

@vanelizarov
Copy link
Contributor

@vanelizarov vanelizarov commented May 17, 2019

Getting EXIF in such manual way is caused by ExifInterface incompatibility with API versions lower than 24 (flutter_compress_image is at version 16)
However, this manual method works fine and is much simpler:

val exifRotate = Exif.getRotationDegrees(arr)

vs

val exifInterface = ExifInterface(ByteArrayInputStream(arr))
val orientation = exifInterface.getAttributeInt(ExifInterface.TAG_ORIENTATION, 1)
var exifRotate = 0

when (orientation) {
    ExifInterface.ORIENTATION_ROTATE_90 -> exifRotate = 90
    ExifInterface.ORIENTATION_ROTATE_180 -> exifRotate = 180
    ExifInterface.ORIENTATION_ROTATE_270 -> exifRotate = 270
}

Possibly it would be also good for compressAssetImage, compressAndGetFile and compressWithFile to support this orientation fix

@CaiJingLong
Copy link
Member

So this fix is only for Android.
And it's not about keeping EXIF, it's just about "correcting" the angle.

@vanelizarov
Copy link
Contributor Author

@CaiJingLong on iOS there is no such problem
And yes, it just corrects the angle

@CaiJingLong
Copy link
Member

LGTM
Thanks for job.

@CaiJingLong CaiJingLong merged commit d00d819 into fluttercandies:master May 17, 2019
@CaiJingLong
Copy link
Member

CaiJingLong commented May 17, 2019

@vanelizarov
I think a parameter should be added to let the user decide whether to turn on the "Auto Correction Angle" option, which consumes slightly more performance, especially for File.
If the user chooses not, the code to get the angle is not called.
What do you think?


In addition, if you set this option, you think it's better to set it to true or false.

True meets the general expectations, but for users who used the library in the past, they might rotate repeatedly by finding their own angles and setting rotate attributes.

If set to false, there is no breaking change.

I prefer to add this param and set it to false by default.

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.

2 participants