rn-img-to-base64
v1.0.0
Published
Works with image url
Downloads
3
Readme
react-native-img-to-base64
Works with image url
Getting started
$ npm install react-native-img-to-base64 --save
Mostly automatic installation
$ react-native link react-native-img-to-base64
Manual installation
iOS
- In XCode, in the project navigator, right click
Libraries
➜Add Files to [your project's name]
- Go to
node_modules
➜react-native-img-to-base64
and addRNImgToBase64.xcodeproj
- In XCode, in the project navigator, select your project. Add
libRNImgToBase64.a
to your project'sBuild Phases
➜Link Binary With Libraries
- Run your project (
Cmd+R
)<
Android
- Open up
android/app/src/main/java/[...]/MainActivity.java
- Add
import com.developersoul.RNImgToBase64Package;
to the imports at the top of the file - Add
new RNImgToBase64Package()
to the list returned by thegetPackages()
method
- Append the following lines to
android/settings.gradle
:include ':react-native-img-to-base64' project(':react-native-img-to-base64').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-img-to-base64/android')
- Insert the following lines inside the dependencies block in
android/app/build.gradle
:compile project(':react-native-img-to-base64')
Windows
- In Visual Studio add the
RNImgToBase64.sln
innode_modules/react-native-img-to-base64/windows/RNImgToBase64.sln
folder to their solution, reference from their app. - Open up your
MainPage.cs
app
- Add
using Img.To.Base64.RNImgToBase64;
to the usings at the top of the file - Add
new RNImgToBase64Package()
to theList<IReactPackage>
returned by thePackages
method
Usage
import RNImgToBase64 from 'react-native-img-to-base64';
function async getBase64() {
const url = 'https://urltoyourimage.com/image.jpg';
const base64 = await ImgToBase64Module.convert(url);
console.log(base64);
}
or
function getBase64() {
const url = 'https://urltoyourimage.com/image.jpg';
ImgToBase64Module.convert(url).then(base64 => {
console.log(base64);
});
}