Skip to content

thanhcuong1990/react-native-image-editor

 
 

Repository files navigation

react-native-image-editor-next

Image Editor Native module for React Native.

Getting started

Install

yarn add react-native-image-editor-next

or

npm install react-native-image-editor-next --save

Install Pods

npx pod-install

Usage

Start by importing the library:

import ImageEditor from "react-native-image-editor-next";

Crop image

Crop the image specified by the URI param. If URI points to a remote image, it will be downloaded automatically. If the image cannot be loaded/downloaded, the promise will be rejected.

If the cropping process is successful, the resultant cropped image will be stored in the cache path, and the URI returned in the promise will point to the image in the cache path. Remember to delete the cropped image from the cache path when you are done with it.

  ImageEditor.cropImage(uri, cropData).then(url => {
    console.log("Cropped image uri", url);
  })

cropData

Property Required Description
offset Yes The top-left corner of the cropped image, specified in the original image's coordinate space
size Yes Size (dimensions) of the cropped image
displaySize No Size to which you want to scale the cropped image
resizeMode No Resizing mode to use when scaling the image (iOS only, android resize mode is always 'cover') Default value: 'contain'
  cropData = {
    offset: {x: number, y: number},
    size: {width: number, height: number},
    displaySize: {width: number, height: number},
    resizeMode: 'contain' | 'cover' | 'stretch',
  };

For more advanced usage check our example app.

About

react-native-image-editor

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Java 47.9%
  • JavaScript 26.3%
  • Objective-C 19.6%
  • Starlark 4.8%
  • Ruby 1.4%