Readme

Code from https://deno.com/blog/build-image-resizing-api

Useful for compressing an image before sending to chatgpt4v, for example

1
2
3
4
5
6
7
8
9
10
11
12
13
import { ImageMagick, initializeImageMagick, MagickGeometry } from "https://deno.land/x/imagemagick_deno@0.0.14/mod.ts";
export async function modifyImage(
input: Uint8Array | "logo:",
) {
return new Promise<File>((resolve) => {
ImageMagick.read(input, (image) => {
image.trim();
image.repage();
image.write((data) => resolve(new File([data], "logo.png", { type: "image/png" })));
});
});
}
Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
Comments
Nobody has commented on this val yet: be the first!
June 18, 2024