aboutsummaryrefslogtreecommitdiff
path: root/src/utils/camera.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/utils/camera.ts')
-rw-r--r--src/utils/camera.ts38
1 files changed, 38 insertions, 0 deletions
diff --git a/src/utils/camera.ts b/src/utils/camera.ts
index 4f933b0c..9e37d62e 100644
--- a/src/utils/camera.ts
+++ b/src/utils/camera.ts
@@ -8,6 +8,7 @@ import {
TakePictureOptions,
TakePictureResponse,
} from 'react-native-camera';
+import {ProcessingManager} from 'react-native-video-processing';
import ImagePicker, {ImageOrVideo, Video} from 'react-native-image-crop-picker';
import {ERROR_UPLOAD} from '../constants/strings';
@@ -116,3 +117,40 @@ export const showGIFFailureAlert = (onSuccess: () => void) =>
),
},
);
+
+export const cropVideo = (
+ sourceUri: string,
+ handleData: (data: any) => any,
+ videoCropValues?: {
+ cropWidth?: number;
+ cropHeight?: number;
+ cropOffsetX?: number;
+ cropOffsetY?: number;
+ },
+) => {
+ ProcessingManager.crop(sourceUri, {
+ cropWidth: videoCropValues
+ ? videoCropValues.cropWidth
+ ? Math.round(videoCropValues.cropWidth)
+ : 100
+ : 100,
+ cropHeight: videoCropValues
+ ? videoCropValues.cropHeight
+ ? Math.round(videoCropValues.cropHeight)
+ : 100
+ : 100,
+ cropOffsetX: videoCropValues
+ ? videoCropValues.cropOffsetX
+ ? Math.round(videoCropValues.cropOffsetX)
+ : 0
+ : 0,
+ cropOffsetY: videoCropValues
+ ? videoCropValues.cropOffsetY
+ ? Math.round(videoCropValues.cropOffsetY)
+ : 0
+ : 0,
+ quality: 'highest',
+ }).then((data: any) => {
+ handleData(data);
+ });
+};