Files
iNaturalistReactNative/src/sharedHelpers/resizeImage.ts
Ryan Stelly b78be9243d lint rule & autofix for "trailing comma" (#3299)
* (lint) MOB-1063 enforce trailing commas

* autofix trailing commas

* manually fix newly introduced maxlen violations

* add trailing comma convention to i18n build
2025-12-22 20:17:13 -06:00

44 lines
943 B
TypeScript

import ImageResizer from "@bam.tech/react-native-image-resizer";
const resizeImage = async (
pathOrUri: string,
options: {
width: number;
height?: number;
rotation?: number;
outputPath?: string;
imageOptions?: {
mode?: string;
onlyScaleDown?: boolean;
};
},
): Promise<string> => {
const {
width,
height,
rotation,
outputPath,
imageOptions,
} = options;
// Note that the default behavior of this library is to resize to contain,
// i.e. it will not adjust aspect ratio
const resizedPhoto = await ImageResizer.createResizedImage(
pathOrUri,
width, // maxWidth
height || width, // maxHeight
"JPEG", // compressFormat
100, // quality
rotation || 0, // rotation
outputPath, // outputPath
true, // keep metadata,
imageOptions, // mode and scale options
);
const { uri } = resizedPhoto;
return uri;
};
export default resizeImage;