Resize and rotate images with TypeScript/Angular
npm install ts-image-processorThis 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
Total canvas memory use exceeds the maximum limit by using only one canvas for everything
npm i ts-image-processor -S
``
import { getBlobForFile, imageProcessor, resize, sharpen, output } from 'ts-image-processor';// If you have a file from , 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 :)
});
});
`$3
Feel free to create pull requests$3
- [ ] 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