Writes a copy of an image whose longest side fits within MAX_IMAGE_DIMENSION.
The source is left untouched. When the image already fits, its format cannot
be preserved, or decoding/encoding fails, the original URI is returned with
resized: false so callers can fall back to storing the source as-is.
The source is decoded once, directly at the reduced size, so no full-size
bitmap is ever built; the decoder applies EXIF orientation. Both native
references are released before returning so peak bitmap memory does not
depend on the JS collector.
Parameters
sourceUri: string
URI of the image to downscale
extension: string
Source file extension, used to keep the container format
Writes a copy of an image whose longest side fits within MAX_IMAGE_DIMENSION.
The source is left untouched. When the image already fits, its format cannot be preserved, or decoding/encoding fails, the original URI is returned with
resized: falseso callers can fall back to storing the source as-is.The source is decoded once, directly at the reduced size, so no full-size bitmap is ever built; the decoder applies EXIF orientation. Both native references are released before returning so peak bitmap memory does not depend on the JS collector.