import { handleImageInput, ImageInput, ImageRef, ImageRotation, ParametricFilter, Point, SaveImageOptions, withSBErrorHandling, } from '../types'; import { ScanbotSDKNativeModule } from './ScanbotSDKModule'; /** * @internal * @hidden */ export const ScanbotImageProcessorImpl = { async applyFiltersOnImageFile(params: { imageFileUri: string; filters: ParametricFilter[]; overwrite?: boolean; saveOptions?: SaveImageOptions; }): Promise { return withSBErrorHandling(async () => ScanbotSDKNativeModule.applyFiltersOnImageFile(params)); }, async applyFilters(params: { image: ImageInput; filters: ParametricFilter[]; }): Promise { return withSBErrorHandling(async () => ImageRef.from( await ScanbotSDKNativeModule.applyFiltersOnImage({ filters: params.filters, image: handleImageInput(params.image), }) ) ); }, async rotateImageFile(params: { imageFileUri: string; rotation: ImageRotation; overwrite?: boolean; saveOptions?: SaveImageOptions; }): Promise { return withSBErrorHandling(async () => await ScanbotSDKNativeModule.rotateImageFile(params)); }, async rotate(params: { image: ImageInput; rotation: ImageRotation }): Promise { return withSBErrorHandling(async () => ImageRef.from( await ScanbotSDKNativeModule.rotateImage({ rotation: params.rotation, image: handleImageInput(params.image), }) ) ); }, async readImageData(imageFileUri: string): Promise { return withSBErrorHandling(async () => ScanbotSDKNativeModule.readImageData({ imageFileUri: imageFileUri }) ); }, async resizeImageFile(params: { imageFileUri: string; maxSize: number; overwrite?: boolean; saveOptions?: SaveImageOptions; }): Promise { return withSBErrorHandling(async () => ScanbotSDKNativeModule.resizeImageFile(params)); }, async resize(params: { image: ImageInput; maxSize: number }): Promise { return withSBErrorHandling(async () => ImageRef.from( await ScanbotSDKNativeModule.resizeImage({ maxSize: params.maxSize, image: handleImageInput(params.image), }) ) ); }, async cropImageFile(params: { imageFileUri: string; polygon: Point[]; overwrite?: boolean; saveOptions?: SaveImageOptions; }): Promise { return withSBErrorHandling(async () => ScanbotSDKNativeModule.cropImageFile(params)); }, async crop(params: { image: ImageInput; polygon: Point[] }): Promise { return withSBErrorHandling(async () => ImageRef.from( await ScanbotSDKNativeModule.cropImage({ polygon: params.polygon, image: handleImageInput(params.image), }) ) ); }, };