-
Sorry I'm new boy with wasm stuff... anyway. I try this example... Here. like this:import * as util from "util";
import * as fs from "fs";
import {ImageMagick,
initializeImageMagick,
} from '@imagemagick/magick-wasm'
const readFile = util.promisify(fs.readFile);
const writeFile = util.promisify(fs.writeFile);
const readSettings = new ImageMagick.MagickReadSettings(
{
format: ImageMagick.MagickFormat.Jpeg
});
const inputData =
await readFile("Higehiro-episode-3.jpg");
await ImageMagick.read(inputData, readSettings, async (image) => {
image.resize(600, 0);
await image.write(async (outputData) => {
await writeFile("test.jpg", outputData);
}, ImageMagick.MagickFormat.Jpeg);
}); But I got: TypeError: Cannot read property 'Jpeg' of undefined at file:///data/data/com.termux/files/home/webStuff/images/main.mjs:11:38 There is something missing I think I need to import something but I don't know what 😓. |
Beta Was this translation helpful? Give feedback.
Answered by
X7md
Oct 7, 2021
Replies: 1 comment
-
Btw, after trying. This work. import * as util from "util";
import * as fs from "fs";
import {ImageMagick,
initializeImageMagick}
from '@imagemagick/magick-wasm'
import * as MagickFormat
from '@imagemagick/magick-wasm/magick-format.js'
import { MagickReadSettings }
from '@imagemagick/magick-wasm/settings/magick-read-settings.js'
const readFile = util.promisify(fs.readFile);
const writeFile = util.promisify(fs.writeFile);
initializeImageMagick().then(async () => {
const readSettings = new MagickReadSettings(
{
format: MagickFormat.Jpeg
});
const inputData =
await readFile("Higehiro-episode-3.jpg");
await ImageMagick.read(inputData, readSettings, async (image) => {
image.resize(600, 0);
await image.write(async (outputData) => {
await writeFile("test.jpg", outputData);
}, MagickFormat.Jpeg);
});
}) |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
X7md
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Btw, after trying.
This work.