1.1.17 • Published 5 years ago

ts-image-processor v1.1.17

Weekly downloads
30
License
MIT
Repository
github
Last release
5 years ago

TypeScript image processor

This library provides basic image processing functions for use in TypeScript or Angular projects.

Available processing functions:

  • applyExifOrientation
  • resize
  • sharpen
  • rotate
  • mirror
  • noop

For best results I recommend to always use sharpen after resize - that's what Photoshop does, too ;)

Available File/HTMLImageElement utility functions:

  • fileToBase64
  • fileToArrayBuffer
  • base64ToImgElement
  • base64ToArrayBuffer

Advantages

  • Smooth resizing of images in multiple resize-steps
  • Prevents error on iOS Total canvas memory use exceeds the maximum limit by using only one canvas for everything
  • Tree shakable - if you use a bundler like Webpack it will not include unused functions in your project

Demo

See the demo here

Usage

npm i ts-image-processor -S
import { getBlobForFile, imageProcessor, resize, sharpen, output } from 'ts-image-processor';

// If you have a file from <input>, convert it to base64-string first
getBlobForFile(file).then(base64 => {
  // Use any of the functions with an existing blob (base64-string)
  imageProcessor
    .src(base64)
    .pipe(
      resize({maxWidth: 800, maxHeight: 800}),
      sharpen(),
    )
    .then(processedBase64 => {
      // Do whatever with your happy result :)
    });
});

Contribute

Feel free to create pull requests

Todo's

  • Cleanup files/folders + tslint
  • imageProcessor.src() should handle wrong input
  • imageProcessor.src() should accept File
  • imageProcessor.src() should accept FileList
  • imageProcessor.src() should accept File[]
  • imageProcessor.src() should accept string[] (base64-array)
  • rotate() should provide more options than just 90° rotation
  • Process everything within a Web Worker
  • Write advanced documentation with included typedoc
1.1.17

5 years ago

1.1.16

5 years ago

1.1.15

5 years ago

1.1.14

5 years ago

1.1.13

5 years ago

1.1.12

5 years ago

1.1.11

5 years ago

1.1.10

5 years ago

1.1.8

5 years ago

1.1.5

5 years ago

1.1.4

5 years ago

1.1.3

5 years ago

1.1.1

5 years ago

1.0.2

5 years ago

0.0.1

5 years ago

1.0.1

5 years ago