rn-img-to-base64

1.0.0 • Public • Published

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

  1. In XCode, in the project navigator, right click LibrariesAdd Files to [your project's name]
  2. Go to node_modulesreact-native-img-to-base64 and add RNImgToBase64.xcodeproj
  3. In XCode, in the project navigator, select your project. Add libRNImgToBase64.a to your project's Build PhasesLink Binary With Libraries
  4. Run your project (Cmd+R)<

Android

  1. 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 the getPackages() method
  1. 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')
    
  2. Insert the following lines inside the dependencies block in android/app/build.gradle:
      compile project(':react-native-img-to-base64')
    

Windows

Read it! :D

  1. In Visual Studio add the RNImgToBase64.sln in node_modules/react-native-img-to-base64/windows/RNImgToBase64.sln folder to their solution, reference from their app.
  2. 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 the List<IReactPackage> returned by the Packages 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);
    });
}
 

Readme

Keywords

Package Sidebar

Install

npm i rn-img-to-base64

Weekly Downloads

1

Version

1.0.0

License

MIT

Unpacked Size

34.8 kB

Total Files

20

Last publish

Collaborators

  • developersoul