resize-image
Resize images in browser using canvas
Install
npm
npm i resize-image --save
bower
bower install resize-image --save
Usage
var resizeImage = ; var img = ;img { var data = resizeImage; console;};imgsrc = url; // local image url
.resize2Canvas(img, width, height)
resize an <img>
or Image
or <canvas>
to canvas
- {Image} img: an
<img>
orImage()
- {number} [width]: output image width
- {number} [height]: output image height
.resize(img, width, height, type)
resize an <img>
or Image
or <canvas>
to base64
- {Image} img: an
<img>
orImage()
- {number} [width]: output image width
- {number} [height]: output image height
- {string} [type]: output image type
types
- .PNG (default)
- .GIF
- .BMP
- .JPEG
- .WEBP
Examples
yarn
npm run example
And visit http://localhost:9000/.