tanmuhittin / image-blob-reduce

Resize image blobs with high quality. Pica's wrapper to work with file inputs.

Home Page:https://nodeca.github.io/image-blob-reduce/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

image-blob-reduce - downscale blobs with images inside

Build Status NPM version

Wrapper for pica to work with blobs, with some sugar.

This is pica wrapper for convenient work with images from file input fields. While pica works with raw bitmaps, this package operates with "image files". Additional features are:

  • [jpeg] Apply orientation to downscaled result.
  • [jpeg] Keep metadata, but with patched orientation & removed original color profile.
  • Easy to monkey-patch for your needs.

Demo

Install

npm install pica

Usage

const reduce = require('image-blob-reduce')();

//...

reduce.toBlob(image_blob, { max: 1000 })
.then(blob => { ... });

API

new ImageBlobReduce([options])

Create new reducer. Options:

  • pica - instance of pica, if you wish different defaults or shareable webworkers pool.

Short call: require('image_blob_reduce')()

.toBlob(in_blob, { max: size }) => Promise(out_blob)

Downscale image to fit into max*max size. If blob contains jpeg, then orientation is applied and metadata from original image reused (with minimal change).

.toCanvas(in_blob, { max: size }) => Promise(out_canvas)

The same as .toBlob(), but with canvas output.

.pica

Reexport of require('pica'), for convenience.

About

Resize image blobs with high quality. Pica's wrapper to work with file inputs.

https://nodeca.github.io/image-blob-reduce/

License:MIT License


Languages

Language:JavaScript 99.3%Language:HTML 0.7%