resize-image

    0.1.0 • Public • Published

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

    Install

    npm i resize-image

    DownloadsWeekly Downloads

    1,035

    Version

    0.1.0

    License

    MIT

    Unpacked Size

    222 kB

    Total Files

    16

    Last publish

    Collaborators

    • csbun