resize-image

Resize images in browser using canvas

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
resize-image
2870.1.06 years ago9 years agoMinified + gzip package size for resize-image in KB

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/.