1.0.6 • Published 11 months ago

@supersimplethings/resize-image-in-browser v1.0.6

Weekly downloads
27
License
MIT
Repository
github
Last release
11 months ago

@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

1.0.6

11 months ago

1.0.2

4 years ago