Repository navigation
Conversation
… path `getOrientation` resolved the source to a `File` first, which only works for `file:` URIs and for `content:` URIs that expose `MediaStore.DATA` (usually not the case under scoped storage). For `https:` and `data:` sources it returned 0, so the crop coordinates were never remapped — while `BitmapRegionDecoder` crops raw, un-rotated pixels. A portrait photo taken with `Orientation=Rotate90` and served over HTTPS cropped the wrong part of the image entirely, and the crop was transposed. iOS and web both handle this correctly, so Android was the odd one out for every remote rotated image. Read the tag from a stream over the source instead, which works for every URI scheme the module accepts. Sources without Exif data stay upright rather than failing the crop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
H1: wrong crop. EXIF orientation is now read from the image data (
ExifInterface(InputStream)) instead of afile://path.getOrientationfirst resolved the source to aFile. That only works forfile:URIs and forcontent:URIs that exposeMediaStore.DATA, which scoped storage usually hides. Forhttps:anddata:sources it returned 0, so the crop rect was never remapped, whileBitmapRegionDecodercrops raw, unrotated pixels. A portraitOrientation=Rotate90photo served over HTTPS cropped the wrong region, transposed. iOS and web handle this correctly.The existing display→raw rect remapping is kept, because it was already correct. It just never got a non-zero orientation for remote sources.
Cost: for remote URIs the source is opened a second time per crop (EXIF needs a stream, region decode needs random access). This is cheap on a Fresco disk-cache hit. Without Fresco it means a second download.
Known limitation, not changed here: EXIF mirror values 5–8 fall into
else -> 0, so a mirrored source stays mirrored.Verification
Not compiled. No
:android:compileDebugKotlinrun and nothing run on a device. The Kotlin was checked for syntax errors only, and the external API signatures were checked against the published artifacts.Split out of #221 (now closed), which bundled six Android fixes in
ImageEditorModuleImpl.kt. Each one can be reviewed and merged separately.