Commit f6a87f0
committed
fix(ios): normalize image orientation before crop
Image.crop() on iOS did not normalize non-.up input images before
calling cgImage.cropping(to:). vision-camera v5's Photo.toImageAsync()
constructs UIImage(cgImage:, scale: 1, orientation: sensorOrientation),
so uiImage.size is in display space while cgImage is in sensor space.
The caller's (startX, startY, endX, endY) rect then lands in the wrong
region of cgImage, and UIImage(cgImage:) dropped the source orientation
in the output.
Fix: when imageOrientation != .up or scale != 1, draw the image through
a scale=1 UIGraphicsImageRenderer to bake orientation into pixels before
cropping, then wrap the cropped CGImage with explicit scale=1 and .up so
downstream consumers see consistent state.
The other four bugs from the original PR (crop rect size, renderer scale
in resize/rotate/createBlankImage, and the rotate slow-path bounding
box) are already fixed in 0.15.1, so this branch is rescoped to just the
remaining orientation bug, which also resolves the merge conflicts.1 parent 006c5b9 commit f6a87f0
1 file changed
Lines changed: 20 additions & 2 deletions
Lines changed: 20 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
135 | 135 | | |
136 | 136 | | |
137 | 137 | | |
138 | | - | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
139 | 156 | | |
140 | 157 | | |
141 | 158 | | |
| |||
146 | 163 | | |
147 | 164 | | |
148 | 165 | | |
149 | | - | |
| 166 | + | |
| 167 | + | |
150 | 168 | | |
151 | 169 | | |
152 | 170 | | |
| |||
0 commit comments