1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import { blob } from "https://esm.town/v/std/blob?v=3";
import Jimp from "npm:jimp";
export async function blobSavePictureExample() {
// Read my profile picture
const img = await Jimp.read("https://val.town/avatar/ec6d37b4-1291-4ea3-93b7-d7972929dc8b?size=32");
// Resize and flip
const buffer = await img
.resize(128, 128)
.flip(false, true)
.getBufferAsync(Jimp.MIME_PNG);
// Save picture to blob storage
await blob.set("profilePicture", buffer);
}
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!
v3
November 14, 2023