Readme
See @postpostscript/provideBlobExample for full example. You will need to fork this val to use provideBlob
on your projects as it uses @std/blob for storage
import { Image } from "https://deno.land/x/imagescript@1.2.17/mod.ts";
import { htmlResponse } from "https://esm.town/v/postpostscript/html";
import { provideBlob } from "https://esm.town/v/postpostscript/provideBlob";
export default async function(req: Request) {
const image = provideBlob(async () => {
const png = new Image(100, 100);
png.drawCircle(50, 50, 50, 100);
return png.encode();
}).jsPromise();
return htmlResponse`
<div id="image"></div>
<script>
${image}.then(blob => {
const $img = document.createElement("img")
$img.src = URL.createObjectURL(blob)
document.getElementById("image").appendChild($img)
})
</script>
`;
}
Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
postpostscript-provideblob.web.val.run
Updated: February 29, 2024
Cool! I'm getting an error at the moment:
Oh, I see, the demo is here: https://www.val.town/v/postpostscript/provideBlobExample