1.0.5 • Published 2 years ago

resizer-image v1.0.5

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

Resizer-Image

A library to resize images in file or base64.

Demo

Code Sandbox

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')
ParamDescriptionExample
inputa file or base64 srce.target.files[0]
sizesan array of sizes{ w: 160, h: 90 },{ w: 320, h: 180 }
typeimage typepng, 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

1.0.5

2 years ago

1.0.4

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago