react-native-asset-library-to-screen-size-base64

1.0.4 • Public • Published

react-native-asset-library-to-base64

A React Native Module that takes an image's asset-library:// uri and returns base64:

Install

iOS

  1. npm install --save react-native-asset-library-to-screen-size-base64
  2. In the XCode's "Project navigator", right click on your project's Libraries folder ➜ Add Files to <...>
  3. Go to node_modulesreact-native-asset-library-to-base64ios ➜ select AssetLibraryToBase64.m
  4. Make sure AssetLibraryToBase64.m is listed under 'Compile Sources' in your project's 'Build Phases' tab
  5. Compile and have fun

Usage

  1. In your React Native javascript code, bring in the native module:
var ReadImageData = require('NativeModules').ReadImageData;
  1. Use it like so:
// uri is link to asset-library://
ReadImageData.readImage(uri, (imageBase64) => {
console.log(imageBase64);
});

Source

This code was copied from https://github.com/scottdixon/react-native-upload-from-camera-roll/blob/master/RCTCustom.m and https://medium.com/@scottdixon/react-native-creating-a-custom-module-to-upload-camera-roll-images-7a3c26bac309#.xckz6wr87. I just took the example and turned it into a module for ease of use.

Package Sidebar

Install

npm i react-native-asset-library-to-screen-size-base64

Weekly Downloads

2

Version

1.0.4

License

ISC

Last publish

Collaborators

  • steve06m