Skip to content

damirjuretic/react-native-mozjpeg

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

react-native-mozjpeg

Mozjpeg for react native in pure JavaScript. Inspired by mozjpeg-js.

Why another react-native compression library? Most of the react-native compression libraries don't compress as much as server compression libraries like sharp. Mozjpeg will do 2-3 times better compression than other react native libraries.

As this is written in pure Javascript you will get a performance hit if you encode large images. To avoid performance hit is best to compress the image first by react-native-image-crop-picker and return the image in base64 format or you can try to offload main UI js thread by using workers.

Usage

$ npm i -S react-native-mozjpeg

Call encode with a file in base64 format and mozjpeg options

import encode from 'react-native-mozjpeg';
const fileData = encode(fileDataBase64, { quality: 85 });

You can upload a file to s3 using Axios

axios
    .create({
      headers: {
        'Content-Type': contentType,
      },
    })
    .put(uploadUrl, fileData);

About

Mozjpeg for react native

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors