Skip to content

Commit

Permalink
Switching Android img format from PNG to JPEG
Browse files Browse the repository at this point in the history
  • Loading branch information
Michaël Villeneuve committed Jan 25, 2018
1 parent 42c3100 commit 9b8b188
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

# react-native-convert-image-to-base64
# react-native-image-base64

This repo is a working rewrite of [this](https://github.com/xfumihiro/react-native-image-to-base64) abandonned library.
It provides a very simple way to convert an image to a base64 string.
Expand All @@ -9,18 +9,18 @@ Indeed working with big images on Android might cause very high memory usage.

## Getting started

`npm install react-native-convert-image-to-base64 --save`
`npm install react-native-image-base64 --save`
or
`yarn add react-native-convert-image-to-base64`
`yarn add react-native-image-base64`


## Installation

`$ react-native link react-native-convert-image-to-base64`
`$ react-native link react-native-image-base64`

## Usage
```javascript
import ImgToBase64 from 'react-native-convert-image-to-base64';
import ImgToBase64 from 'react-native-image-base64';

ImgToBase64.getBase64String('file://youfileurl', (err, base64string) => doSomethingWith(base64string));
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public void getBase64String(String uri, Callback callback) {

private String bitmapToBase64(Bitmap bitmap) {
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.PNG, 100, byteArrayOutputStream);
bitmap.compress(Bitmap.CompressFormat.JPEG, 80, byteArrayOutputStream);
byte[] byteArray = byteArrayOutputStream.toByteArray();
return Base64.encodeToString(byteArray, Base64.DEFAULT);
}
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

{
"name": "react-native-convert-image-to-base64",
"version": "0.1.0",
"name": "react-native-image-base64",
"version": "0.1.1",
"description": "Convert image to base64",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit 9b8b188

Please sign in to comment.