baronha / react-native-photo-editor

🌄 Photo editor using native modules for iOS and Android. Inherit from 2 available libraries, ZLImageEditor (iOS) and PhotoEditor (Android)
MIT License
397 stars 132 forks source link

What should the path to the local file look like? #20

Open vrchvngel opened 2 years ago

vrchvngel commented 2 years ago

Hi, what should the path to the local file look like? It just works with web URL. I've tried:

const result = await PhotoEditor.open({ path: './assets/logo.png' });

and

const result = await PhotoEditor.open({ path: require('./assets/logo.png') });

and it doesn't work.

khanh21011999 commented 2 years ago

I have same problem, don't know what happenned

erjondev commented 2 years ago

I have the same issue, did you found the solution ?

bastiantowers commented 2 years ago

As far I had tested, it should be an absolute path of the form of "file://...", for both platforms as well. So you should use a library able to open files from the phone filesystem.

It seems like this library is designed to work well with other libraries for reading files or opening files from photo gallery or with the camera, but I don't know if they think of the use case of bringing a file of a form of './assets/...' and other similar cases.

ItxAltaf commented 5 months ago

you need to add image picker first and then you can use it like that

try { ImageCropPicker.openPicker(gStyles.imgPicker).then(image => { PhotoEditor.open({ path: image.path, stickers: [ 'https://cdn-icons-png.flaticon.com/512/5272/5272912.png', 'https://cdn-icons-png.flaticon.com/512/5272/5272913.png', 'https://cdn-icons-png.flaticon.com/512/5272/5272916.png', ], }).then(result => { console.log('result', result); setFile({path: result}) }); }); } catch (error) {}