Language:
From Camera Roll
PhotoEditor SDK supports importing photos from the camera roll.
Select a photo#
In this example, we are using the expo-image-picker
module to select a video from the camera roll.
Open the editor#
When a photo has been selected we pass the local URI to the openEditor
method to load the photo into the editor and open it.
Once the photo has been exported, we handle the result and possible occurring errors.
File:
import { PESDK } from "react-native-photoeditorsdk";import * as ImagePicker from "expo-image-picker";export const openPhotoFromCameraRollExample = async (): Promise<void> => {try {// Select a photo from the camera roll.let pickerResult = await ImagePicker.launchImageLibraryAsync({mediaTypes: ImagePicker.MediaTypeOptions.Images,});// Return if the image selection has been cancelled.if (pickerResult.cancelled) {return;}// Open the photo editor and handle the export as well as any occuring errors.const result = await PESDK.openEditor(pickerResult.uri);if (result != null) {// The user exported a new photo successfully and the newly generated photo is located at `result.image`.console.log(result.image);} else {// The user tapped on the cancel button within the editor.return;}} catch (error) {console.log(error);}};