Skip to content

rnrn/nativescript-imagecropper

 
 

Repository files navigation

A {N} Image Cropping Plugin

License npm npm GitHub release

Notes

iOS 8+

Android 17+

Based on

TOCropViewController for iOS

uCrop for Android

Installation

Run tns plugin add nativescript-imagecropper

Android Install Notes

This plugin is designed according to {N} 2.0 Specs. For Android, you will need to modify the AndroidManifest.xml file.

Add the following to the AndroidManifest.xml

<manifest>
  <application>
    <activity android:name="com.yalantis.ucrop.UCropActivity" android:screenOrientation="portrait"/>
  </application>
</manifest>

Usage

To use the image cropping module you must first require it.

var icModule = require("nativescript-imagecropper");

Methods

show(ImageSource): Returns a cropped ImageSource

var cropper = new icModule.ImageCropper();
cropper.show(picture).then(function(args){
  console.log(JSON.stringify(args));
})
.catch(function(e){
  console.log(e);
});

show(ImageSource,Options): Returns a cropped and resized ImageSource

var cropper = new icModule.ImageCropper();
cropper.show(picture,{width:300,height:300}).then(function(args){
  console.log(JSON.stringify(args));
})
.catch(function(e){
  console.log(e);
});

Options

Option Type Description
width number The width of the image you would like returned.
height number The height of the image you would like returned.

Returned Result Arguments

Argument Type Result(s)
response string Success
Cancelled
Error
image ImageSource null if there was an error or was cancelled
ImageSource on success

About

A nativescript image cropping plugin.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • TypeScript 84.7%
  • JavaScript 13.3%
  • CSS 1.7%
  • Ruby 0.3%