0.3.0 • Published 1 year ago

ndarray-lanczos v0.3.0

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

ndarray-lanczos

Latest NPM release License Minzipped size CI Coverage

Resize an ndarray with Lanczos resampling.

Quickstart

Installation:

npm install --save ndarray-lanczos

Use:

import ndarray from 'ndarray';
import { getPixels, savePixels } from 'ndarray-pixels';
import { lanczos3 } from 'ndarray-lanczos';

// Read PNG.
const srcPixels = await getPixels('full-size.png');

// Resize with Lanczos 3 resampling.
const dstPixels = ndarray(new Uint8Array(width * height * 4).fill(0), [width, height, 4]);
lanczos3(srcPixels, dstPixels);

// Write PNG.
const data = await savePixels(dstPixels, 'image/png'); // → Uint8Array

Two filtering methods, lanczos3 and lanczos2, are included.

Credits

Thanks to https://github.com/rgba-image/lanczos and https://github.com/nodeca/pica.