Image resizer plugin class (#355)

This commit is contained in:
Marcin Wadoń 2016-07-28 18:46:48 +02:00 committed by Ibrahim Hadeed
parent 41c9adf55a
commit 40bd9bb20d
2 changed files with 80 additions and 0 deletions

View File

@ -49,6 +49,7 @@ import {Hotspot} from './plugins/hotspot';
import {Httpd} from './plugins/httpd';
import {IBeacon} from './plugins/ibeacon';
import {ImagePicker} from './plugins/imagepicker';
import {ImageResizer} from './plugins/imageresizer';
import {InAppBrowser} from './plugins/inappbrowser';
import {Insomnia} from './plugins/insomnia';
import {Keyboard} from './plugins/keyboard';
@ -96,6 +97,7 @@ export * from './plugins/googlemaps';
export * from './plugins/httpd';
export * from './plugins/ibeacon';
export * from './plugins/imagepicker';
export * from './plugins/imageresizer';
export * from './plugins/inappbrowser';
export * from './plugins/launchnavigator';
export * from './plugins/localnotifications';
@ -205,6 +207,7 @@ window['IonicNative'] = {
Httpd: Httpd,
IBeacon: IBeacon,
ImagePicker: ImagePicker,
ImageResizer: ImageResizer,
InAppBrowser: InAppBrowser,
Keyboard: Keyboard,
LaunchNavigator: LaunchNavigator,

View File

@ -0,0 +1,77 @@
import { Cordova, Plugin } from './plugin';
export interface ImageResizerOptions {
/**
* The URI for the image on the device to get scaled
*/
uri: string;
/**
* The width of the new image
*/
width: number;
/**
* The height of the new image
*/
height: number;
/**
* The name of the folder the image should be put
* (Android only)
*/
folderName?: string;
/**
*
* Quality given as Number for the quality of the new image
* (Android and iOS only)
*/
quality?: number;
/**
* A custom name for the file. Default name is a timestamp
* (Android and Windows only)
*/
fileName?: string;
}
/**
* @name ImageResizer
* @description
* Cordova Plugin For Image Resize
*
* Requires plugin `info.protonet.imageresizer` - use the Ionic CLI and type in the following command:
* `ionic plugin add https://github.com/protonet/cordova-plugin-image-resizer.git`
*
* For more info, please see the https://github.com/protonet/cordova-plugin-image-resizer
*
* @usage
* ```typescript
* import { ImageResizer, ImageResizerOptions } from 'ionic-native';
*
* let options = {
* uri: uri,
* folderName: 'Protonet',
* quality: 90,
* width: 1280,
* height: 1280
* } as ImageResizerOptions;
*
* ImageResizer
* .resize(options)
* .then(
* (filePath: string) => { console.log('FilePath', filePath); },
* () => { console.log('Error occured'); }
* )
* ```
*/
@Plugin({
plugin: 'https://github.com/protonet/cordova-plugin-image-resizer.git',
pluginRef: 'window.ImageResizer',
repo: 'https://github.com/protonet/cordova-plugin-image-resizer'
})
export class ImageResizer {
@Cordova()
static resize(options: ImageResizerOptions): Promise<any> { return; }
}