Skip to content

Super simple way to resize image in browser. A part of @supersimplethings project.

Notifications You must be signed in to change notification settings

leeratyou/resize-image-in-browser

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

@supersimplethings/resize-image-in-browser

npm (scoped)

Things should be simple to use

Just put in resizer image before uploading it to server.

Usage

const veryBigImage = document.getElementById('input').files[0];
const resizedImage = await resize(veryBigImage, someOptionsObject)

Installation

With npm:

npm install @supersimplethings/resize-image-in-browser

With yarn:

yarn add @supersimplethings/resize-image-in-browser

API

type Resize = (file: File, options?: Options) => Promise<dataURL|Blob|File>

interface Options {
  maxWidth?: number   (1024) // in pixels // Aspect ratio will be saved
  maxHeight?: number  (768) // in pixels  // Smaller one dimension would be applied
  output?: Output     (jpeg)
  format?: Format     (dataURL)
  quality?: number    (1.0) // from 0.1 to 1.0 (only 'jpeg')
}

enum Format {
  png = 'png',
  jpeg = 'jpeg',
  webp = 'webp',
  bmp = 'bmp'
}

enum Output {
  dataURL = 'dataURL',
  File = 'File',
  Blob = 'Blob'
}

License

MIT

About

Super simple way to resize image in browser. A part of @supersimplethings project.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published