ri

resize-image

Resize images in browser using canvas

Showing:

Popularity

Downloads/wk

1.2K

GitHub Stars

24

Maintenance

Last Commit

4mos ago

Contributors

6

Package

Dependencies

0

Size (min+gzip)

0.5KB

License

MIT

Type Definitions

Tree-Shakeable

No?

Categories

Readme

resize-image

Resize images in browser using canvas

NPM

Build Status Coverage Status

Install

npm

npm i resize-image --save

bower

bower install resize-image --save

Usage

var resizeImage = require('resize-image');

var img = new Image();
img.onload= function () {
  var data = resizeImage.resize(img, 200, 100, resizeImage.PNG);
  console.log(data);
};
img.src = url; // local image url

.resize2Canvas(img, width, height)

resize an <img> or Image or <canvas> to canvas

  • {Image} img: an <img> or Image()
  • {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> or Image()
  • {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/.

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100