Skip to main content
Language

From Local Path

PhotoEditor SDK supports loading photos from the local file system such as the documents or a temporary directory, as well as the application resources.

Open the editor#

To load the photo into the editor simply specify it as the image parameter inside the asynchronous PESDK.openEditor function. In this example, we load a photo from the local path into the editor.

Handle events#

Once the editor finishes, a PhotoEditorResult is returned which contains the edited image at PhotoEditorResult.image. If no result is returned, the user has canceled the editing process by clicking the cancel button inside the editor.

import { PESDK } from "react-native-photoeditorsdk";
export const openPhotoFromLocalPathExample = async (): Promise<void> => {
try {
// Add a photo from the assets directory.
const photo = require("../../../../../assets/pesdk/LA.jpg");
// Open the photo editor and handle the export as well as any occuring errors.
const result = await PESDK.openEditor(photo);
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) {
// There was an error generating the photo.
console.log(error);
}
};