ahdin
TypeScript icon, indicating that this package has built-in type declarations

1.1.0 • Public • Published

Ahdin

Lossy image compression module for JavaScript applications. It takes image Files or Blobs and compresses them to Blobs. It also fixes image orientation according to image's EXIF metadata.

Install

$ npm install --save ahdin

Usage

const Ahdin = require('ahdin');

Ahdin
  .compress(
    source,
    {
      maxWidth: 1000,
      outputFormat: 'png'
    }
  )
  .then((compressedBlob) => {
    doSomething(compressedBlob);
  });

API

compress(source, [options])

Returns: a Promise that resolves to a compressed image as a Blob.

source

Type: Blob

A JPEG or PNG image to be compressed.

options

maxWidth

Type: number
Default: original image width

Maximum width of the compressed image in pixels.

maxHeight

Type: number
Default: original image height

Maximum height of the compressed image in pixels.

outputFormat

Type: string
Default: 'jpeg'

The image format for the compressed image. Accepted values: 'jpeg' and 'png'.

quality

Type: number
Default: 0.8

Image quality, when desired outputFormat is 'jpeg'. The quality must be a number between 0 and 1. If outputFormat is png, this has no effect.

License

MIT © Fast Monkeys

Readme

Keywords

none

Package Sidebar

Install

npm i ahdin

Weekly Downloads

0

Version

1.1.0

License

MIT

Unpacked Size

10.6 MB

Total Files

18

Last publish

Collaborators

  • jpvanhal
  • vesauimonen