cordova-plugin-imagemin

1.0.2 • Public • Published

cordova-plugin-imagemin

npm

A cordova android plugin for image compress.

Install

cordova plugin install cordova-plugin-imagemin;

Usage (Ionic Angular)

// typings.d.ts

declare var imagemin: any;

// demo.page.ts

const imgData = `/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAMCAgICAgMCAgIDAwMDBAYEBAQEBAgGBgUGC...`;

/**
 * `imagemin.compress()` is the entry method of "cordova-plugin-imagemin".
 *
 * @interface imagemin.compress(
 *    imgBase64: string,
 *    option: {
 *       encodeQuality: number;        
 *       outputImgType: 'jpeg' | 'png';
 *    },
 *    success: (res: { data: string }) => void,
 *    error: (err: Error) => void
 * )
 *
 * @param imgBase64: string;  A base64 string of input image which shoud not starts with `data:image/*;base64,` prefix.
 *                            If it starts with such prefix, please remove the prefix first.
 *
 * @param options: {
 *    bitmapConfig:  'ARGB_8888' | 'ARGB_4444' | 'RGB_565';   default null
 *    encodeQuality: number;                                  0-100, default 60
 *    outputImgType: 'jpeg' | 'png';                          default 'jpeg'
 * }
 *
 * @param success: (res: { data: string }) => void;  The callback param `data` is olso a image base64 string.
 *
 * @param error (err: Error) => void;   Compress failed.
 *
 */
imagemin.compress(imgBase64, { encodeQuality: 30 }, ({ data }) => {
  console.log(data);
}, (err: any) => {
  console.error(err);
});

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.0.2
    1
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 1.0.2
    1
  • 1.0.1
    1
  • 1.0.0
    1

Package Sidebar

Install

npm i cordova-plugin-imagemin

Weekly Downloads

3

Version

1.0.2

License

MIT

Unpacked Size

7.4 kB

Total Files

5

Last publish

Collaborators

  • cntower