Giter Club home page Giter Club logo

resizer-image's Introduction

Resizer-Image

A library to resize images in file or base64.

Demo

Installation

npm i resizer-image

Usage

import { resize } from "resizer-image";
const sizes = [
    { w: 0, h: 0 }, // keeps width, keeps height
    { w: 160, h: 0 }, // changes width, keeps height ratio
    { w: 0, h: 90 }, // changes height, keeps width ratio
    { w: 160, h: 90 },
    { w: 320, h: 180 },
    { w: 480, h: 270 },
    { w: 640, h: 360 }
  ]
  
const resizedImages = await resize(input, sizes); //=> [ "blob:http://....","blob:http://...."] 

Params

resize(input, sizes, type='png')
Param Description Example
input a file or base64 src e.target.files[0]
sizes an array of sizes [{ w: 160, h: 90 },{ w: 320, h: 180 }]
type image type png, jpeg, jpg, webp
  • h=0, keep the ratio of height
  • w=0, keep the ratio of width

Sources

CodeSandbox: https://codesandbox.io/s/resizer-image-demo-l65mhh?file=/src/App.js

Github: https://github.com/vnseattle/resizer-image

Happy coding

Dev9x

resizer-image's People

Contributors

henryspudnik avatar vnseattle avatar

Stargazers

Matheus Cristian avatar Mark Gavagan avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.