img-reduce-size-js
v1.4.0
Published
Reduce image using js
Downloads
18
Maintainers
Readme
img-resize-js
image resize using js. reduce image size and ready to upload. image resize and return BLOB can be converted into Base64
Installation
npm install --save img-reduce-size-js
Also available to install globally:
npm install --global img-reduce-size-js
Usage
To include img-reduce-size-js on your website or npm application, use any of the following methods.
ES5
const { imageResize } = require("img-reduce-size-js");
ES6
import { imageResize } from "img-reduce-size-js"
imageResize({
file: e.target.files[0],
maxSize: 500
}).then(function (resizedImage) {
console.log("upload resized image", resizedImage)
}).catch(function (err) {
console.error(err);
});
FOR BASE64
imageResize({
file: e.target.files[0],
maxSize: 500
}).then(function (blob) {
var reader = new FileReader();
reader.readAsDataURL(blob);
reader.onloadend = function () {
var base64data = reader.result;
console.log(base64data);
}
}).catch(function (err) {
console.error(err);
});
License
Apache-2.0. Copyright (c) Arsalan Akhtar, Inc.