mirror of
https://github.com/danielsogl/awesome-cordova-plugins.git
synced 2025-01-19 16:52:53 +08:00
Image resizer plugin class (#355)
This commit is contained in:
parent
41c9adf55a
commit
40bd9bb20d
@ -49,6 +49,7 @@ import {Hotspot} from './plugins/hotspot';
|
|||||||
import {Httpd} from './plugins/httpd';
|
import {Httpd} from './plugins/httpd';
|
||||||
import {IBeacon} from './plugins/ibeacon';
|
import {IBeacon} from './plugins/ibeacon';
|
||||||
import {ImagePicker} from './plugins/imagepicker';
|
import {ImagePicker} from './plugins/imagepicker';
|
||||||
|
import {ImageResizer} from './plugins/imageresizer';
|
||||||
import {InAppBrowser} from './plugins/inappbrowser';
|
import {InAppBrowser} from './plugins/inappbrowser';
|
||||||
import {Insomnia} from './plugins/insomnia';
|
import {Insomnia} from './plugins/insomnia';
|
||||||
import {Keyboard} from './plugins/keyboard';
|
import {Keyboard} from './plugins/keyboard';
|
||||||
@ -96,6 +97,7 @@ export * from './plugins/googlemaps';
|
|||||||
export * from './plugins/httpd';
|
export * from './plugins/httpd';
|
||||||
export * from './plugins/ibeacon';
|
export * from './plugins/ibeacon';
|
||||||
export * from './plugins/imagepicker';
|
export * from './plugins/imagepicker';
|
||||||
|
export * from './plugins/imageresizer';
|
||||||
export * from './plugins/inappbrowser';
|
export * from './plugins/inappbrowser';
|
||||||
export * from './plugins/launchnavigator';
|
export * from './plugins/launchnavigator';
|
||||||
export * from './plugins/localnotifications';
|
export * from './plugins/localnotifications';
|
||||||
@ -205,6 +207,7 @@ window['IonicNative'] = {
|
|||||||
Httpd: Httpd,
|
Httpd: Httpd,
|
||||||
IBeacon: IBeacon,
|
IBeacon: IBeacon,
|
||||||
ImagePicker: ImagePicker,
|
ImagePicker: ImagePicker,
|
||||||
|
ImageResizer: ImageResizer,
|
||||||
InAppBrowser: InAppBrowser,
|
InAppBrowser: InAppBrowser,
|
||||||
Keyboard: Keyboard,
|
Keyboard: Keyboard,
|
||||||
LaunchNavigator: LaunchNavigator,
|
LaunchNavigator: LaunchNavigator,
|
||||||
|
77
src/plugins/imageresizer.ts
Normal file
77
src/plugins/imageresizer.ts
Normal 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; }
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user