cordova-plugin-image-resizer-helper
v1.0.0
Published
Cordova Image Resizer Plugin
Downloads
5
Readme
Cordova Image Resizer 
Cordova Image Resizer lets you resize images with a simple Promise-based API:
- iOS/Android: Resizes images using native APIs.
- Returns
{ uri, fileName, fileSize, type, width, height }for the resized image (file copied into app cache).
Requirements: Cordova iOS 6+, Cordova Android 11+. Platforms supported:
Plugin setup
Using this plugin requires Cordova iOS and Cordova Android.
cordova plugin add cordova-plugin-image-resizer-helper--save
Usage
Usage
JavaScript (Global Cordova)
After the device is ready, you can use the plugin via the global cordova.plugins.ImageResizer object:
document.addEventListener('deviceready', async function () {
var ImageResizer = cordova.plugins.ImageResizer;
const options = {
uri: 'file:///path/to/image.jpg',
quality: 80, // 0-100
width: 800, // target width
height: 600 // target height
};
try {
const result = await ImageResizer.resizeImage(options);
console.log('Resized image:', result);
// result: { uri, fileName, fileSize, type, width, height }
} catch (err) {
console.error('Image resizing failed:', err);
}
});- Check the JavaScript source for additional configuration.
TypeScript / ES Module / Ionic You can also use ES module imports (with TypeScript support):
import { ImageResizer, ImageResizerOptions, ImageResizerResult } from 'cordova-plugin-image-resizer-helper';
async function resize() {
const options: ImageResizerOptions = {
uri: 'file:///path/to/image.jpg',
quality: 80,
width: 800,
height: 600
};
const result: ImageResizerResult = await ImageResizer.resizeImage(options);
console.log(result);
// result: { uri, fileName, fileSize, type, width, height }
}TypeScript Types Type definitions are included. You get full autocompletion and type safety in TypeScript/Ionic projects.
- Check the TypeScript definitions for additional configuration.
Notes
iOS/Android: width/height extracted via native APIs. Files are temporary copies in app cache. Delete them when no longer needed.
Communication
- If you need help, use Stack Overflow. (Tag
cordova) - If you found a bug or have a feature request, open an issue.
- If you want to contribute, submit a pull request.
Contributing
Patches welcome! Please submit all pull requests against the master branch. If your pull request contains JavaScript patches or features, include relevant unit tests. Thanks!
Copyright and license
The MIT License (MIT)
Copyright (c) 2024 Okan Beydanol
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.