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);
}
👆 This is a val. Vals are TypeScript snippets of code, written in the browser and run on our servers. Create scheduled functions, email yourself, and persist small pieces of data — all from the browser.