1.1.2 • Published 3 years ago

client-side-image-resize v1.1.2

Weekly downloads
-
License
ISC
Repository
github
Last release
3 years ago

client-side-image-resize

...with proportial resize support!

This project is a fork of https://www.npmjs.com/package/image-file-resize.

This node module to resize the image file according to width and height. Also you can change the extension of a file. And also it is very lightweight.

Live demo

Install

npm install client-side-image-resize --save

Examples of how to use it

    import convert from 'client-side-image-resize';

    convert({ 
        file: e.target.files[0],  
        width: 600, 
        height: 400, // You can ommit width or height and it will resize proportionally.
        type: 'jpeg'
        }).then(resp => {
            // Response contain compressed and resized file
        }).catch(error => {
             // Error
        })

Parameter to send

Object need to send as a parameter and contain these data.

KeyRequired/OptionalDescription
fileRequiredContain browser file object.
widthOptionalWidth of image required Default is auto
heightOptionalHeight of image required Default is auto
typeOptionalType of image required Default is jpeg

Remember: one of width or height is required.

You can convert image only in jpg, gif, bmp, png, jpeg.