Giter Site home page Giter Site logo

kenlaikh / image-blob-reduce Goto Github PK

View Code? Open in Web Editor NEW

This project forked from nodeca/image-blob-reduce

0.0 0.0 0.0 82 KB

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

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

License: MIT License

JavaScript 99.35% HTML 0.65%

image-blob-reduce's Introduction

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 image-blob-reduce

Usage

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

//...

reduce
  .toBlob(image_blob, { maxWidth: 1000, maxHeight: 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, options) => Promise(out_blob)

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

Options:

  • maxWidth - max allowed image width.
  • maxHeight - max allowed image height.
  • pica .resize() options - alpha, unsharpAmount, unsharpRadius, unsharpThreshold, cancelToken

.toCanvas(in_blob, options) => Promise(out_canvas)

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

.utils

require('./lib/utils'), to simplify modifications.

Reexports

More relinking:

  • ImageBlobReduce.pica => require('pica')
  • ImageBlobReduce.utils => require('./lib/utils')

image-blob-reduce's People

Contributors

kenlaikh avatar rlidwka avatar tanmuhittin avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.