I'm using react native image picker and image resizer to pick and then resize an image. How do I get the base64 of the image once it has been resized?
ImagePickerManager.showImagePicker(imagepicker_options, (response) => {
ImageResizer.createResizedImage(response.uri, 550, null, 'JPEG', 100).then((resizedImageUri) => {
//get base64 of image
});
});
Base64 encoding is a way to encode binary data in ASCII text. It's primarily used to store or transfer images, audio files, and other media online. It is also often used when there are limitations on the characters that can be used in a filename for various reasons.
... import Share from 'react-native-share'; const App = () => { ... const shareImage = async () => { try { // capture component const uri = await captureRef(viewRef, { format: 'png', quality: 0.8, }); // share const shareResponse = await Share. open({url: uri}); } catch (error) { console.
https://libraries.io/npm/react-native-asset-library-to-base64
ImagePickerManager.showImagePicker(imagepicker_options, (response) => {
ImageResizer.createResizedImage(response.uri, 550, null, 'JPEG', 100).then((resizedImageUri) => {
//get base64 of image, uri is link to asset-library://
ReadImageData.readImage(uri, (imageBase64) => {
console.log(imageBase64);
});
});
});
you might also want to read this if you haven't https://github.com/facebook/react-native/issues/1158
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With