Need help upgrading to Ionic Framework 4.0? Get assistance with our Enterprise Migration Services EXPLORE NOW

Crop

Improve this doc

Crops images

Repo: https://github.com/jeduan/cordova-plugin-crop

Installation

  1. Install the Cordova and Ionic Native plugins:
    $ ionic cordova plugin add cordova-plugin-crop
    $ npm install --save @ionic-native/crop@4
    
  2. Add this plugin to your app's module

Supported platforms

Usage

import { Crop } from '@ionic-native/crop';

constructor(private crop: Crop) { }

...

this.crop.crop('path/to/image.jpg', {quality: 75})
  .then(
    newImage => console.log('new image path is: ' + newImage),
    error => console.error('Error cropping image', error)
  );

Instance Members

crop(pathToImage, options)

Crops an image

Param Type Details
pathToImage string
options CropOptions

Optional

Returns: Promise<string> Returns a promise that resolves with the new image path, or rejects if failed to crop.

CropOptions

Param Type Details
quality number (optional)
targetHeight number (optional)
targetWidth number (optional)

API

Native

General