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

Image Resizer

Improve this doc

Cordova Plugin For Image Resize

Repo: https://github.com/JoschkaSchulz/cordova-plugin-image-resizer

Installation

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

Supported platforms

Usage

import { ImageResizer, ImageResizerOptions } from '@ionic-native/image-resizer';

constructor(private imageResizer: ImageResizer) { }

...

let options = {
 uri: uri,
 folderName: 'Protonet',
 quality: 90,
 width: 1280,
 height: 1280
} as ImageResizerOptions;

this.imageResizer
  .resize(options)
  .then((filePath: string) => console.log('FilePath', filePath))
  .catch(e => console.log(e));

Instance Members

resize()

Returns: Promise<any>

ImageResizerOptions

Param Type Details
uri string

The URI for the image on the device to get scaled

folderName string

The name of the folder the image should be put (Android only)

(optional)
fileName string

A custom name for the file. Default name is a timestamp. You have to set this value on iOS

(optional)
quality number

Quality given as Number for the quality of the new image (Android and iOS only)

(optional)
width number

The width of the new image

height number

The height of the new image

base64 boolean

Whether or not to return a base64 encoded image string instead of the path to the resized image. iOS only

(optional)

API

Native

General