img-reduce-size-js

1.4.0 • Public • Published

img-resize-js

image resize using js. reduce image size and ready to upload. image resize and return BLOB can be converted into Base64

NPM

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.

Package Sidebar

Install

npm i img-reduce-size-js

Weekly Downloads

2

Version

1.4.0

License

ISC

Unpacked Size

5.38 kB

Total Files

4

Last publish

Collaborators

  • arsalanakhtar11