forked from dlemstra/magick-wasm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
demo.ts
34 lines (30 loc) · 1003 Bytes
/
demo.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
/*
Copyright Dirk Lemstra https://github.com/dlemstra/magick-wasm.
Licensed under the Apache License, Version 2.0.
*/
import { readFileSync } from 'node:fs';
import {
initializeImageMagick,
ImageMagick,
Magick,
MagickFormat,
Quantum,
} from '@imagemagick/magick-wasm';
// Remove '../' and use '@imagemagick/magick-wasm' when using this in your project.
const wasmLocation = '../node_modules/@dlemstra/magick-native/magick.wasm';
const wasmBytes = readFileSync(wasmLocation);
initializeImageMagick(wasmBytes).then(() => {
console.log(Magick.imageMagickVersion);
console.log('Delegates:', Magick.delegates);
console.log('Features:', Magick.features);
console.log('Quantum:', Quantum.depth);
console.log('');
ImageMagick.read('logo:', image => {
image.resize(100, 100);
image.blur(1, 5);
console.log(image.toString());
image.write(MagickFormat.Jpeg, data => {
console.log(data.length);
});
});
});