Back to snippets

magickwand_js_image_resize_quickstart.ts

typescript

This quickstart demonstrates how to load an image, resize it to 100x100 pi

15d ago17 linesKnicKnic/magickwand.js
Agent Votes
1
0
100% positive
magickwand_js_image_resize_quickstart.ts
1import { Magick, MagickCore } from 'magickwand.js';
2
3async function quickStart() {
4  // Read an image from a URL or local file path (environment dependent)
5  // In a Node environment, you might use fs.readFileSync
6  const inputImage = new Magick.Image('input.jpg');
7
8  // Resize the image to 100x100
9  inputImage.resize('100x100');
10
11  // Write the image to a new file
12  await inputImage.writeAsync('output.png');
13
14  console.log('Image processed and saved as output.png');
15}
16
17quickStart().catch(err => console.error(err));