11import { v2 , type PolycentricClient } from '@polycentric/react-native' ;
22import { File } from 'expo-file-system' ;
33import { isWeb } from '@/src/common/util/platform' ;
4+ import { normalizeImage } from './normalizeImage' ;
45
56/** Default variant edge lengths. */
67export const DEFAULT_IMAGE_VARIANT_SIZES = [ 48 , 128 , 512 ] ;
@@ -25,13 +26,18 @@ export async function processAndUploadImage(
2526 const sizes = options . sizes ?? DEFAULT_IMAGE_VARIANT_SIZES ;
2627 const mode = options . mode ?? 'fill' ;
2728
29+ // Decode via the platform's native image pipeline first: this handles
30+ // formats the core can't (HEIC/HEIF) and bakes EXIF orientation into
31+ // upright pixels, so the core only ever sees an upright JPEG.
32+ const normalizedUri = await normalizeImage ( uri ) ;
33+
2834 // RN's `fetch` can't read `file://` URIs on Android (and is
2935 // unreliable on iOS), so go through `expo-file-system` on
3036 // native. Web stays on `fetch` to handle `blob:` / `data:` URIs
3137 // from `<input type="file">`.
3238 const buffer = isWeb
33- ? await ( await fetch ( uri ) ) . arrayBuffer ( )
34- : await new File ( uri ) . arrayBuffer ( ) ;
39+ ? await ( await fetch ( normalizedUri ) ) . arrayBuffer ( )
40+ : await new File ( normalizedUri ) . arrayBuffer ( ) ;
3541 const raw = new Uint8Array ( buffer ) ;
3642
3743 const variants = await Promise . all (
0 commit comments