// Fetch the original image
fetch("png-logo.png")
// Retrieve its body as ReadableStream
.then((response) => response.body)
.then((body) => body.pipeThrough(new PNGTransformStream()))
.then((rs) => rs.pipeTo(new FinalDestinationStream()));ReadableStream: pipeTo() method / notebook
ReadableStream: pipeTo() method
Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.
(async () => {
// Fetch the original image
const response = await fetch("png-logo.png");
// Retrieve its body as ReadableStream
await response.body
.pipeThrough(new PNGTransformStream())
.pipeTo(new FinalDestinationStream());
})();