问题
I am using Fresco to load images from phone storage by uri into SimpleDraweeView (both internal and external, using content provider - 'content://'). They are loading fine, but keep rotating if they have orientation set in their properties. I tried to set imageRequest with .setAutoRotateEnabled(true) property, but for some reason it doesn't work for me. Any suggestions on how to rotate images to display them properly?
imageView.setController(
controllerBuilder
.setOldController(imageView.getController())
.setImageRequest(imageRequestBuilder
.setSource(uri)
.setAutoRotateEnabled(true)
.setResizeOptions(null)
.build())
.build());
回答1:
I had this issue solved by setting .setDownsampleEnabled(false). I don't know why, but I guess that downsampling is REALLY experimantal yet and prevents auto-rotating to happen.
回答2:
Auto-rotate is the default, so the image will rotate if the orientation is set. Try setting it to false if that's not what you want.
回答3:
I also had the same issue, where having downsampling enabled in Fresco prevents you from being able to disable auto-rotation of images with EXIF data.
I recently opened an issue about this, and the fact that auto-rotation is on by default but this is not documented anywhere, which caused me hours of head-scratching. No response from Fresco devs as yet.
EDIT: The issue is now fixed in Fresco v0.14.
回答4:
For some reason setAutoRotateEnabled(true) also didn't work for me so I forced to always rotate to 90 degrees
Kotlin code
val request = ImageRequestBuilder.newBuilderWithSource(uri)
.setResizeOptions(ResizeOptions(width, height))
.setRotationOptions(RotationOptions.forceRotation(RotationOptions.ROTATE_90))
.build()
来源:https://stackoverflow.com/questions/34514161/android-how-to-rotate-image-using-fresco