Skip to content

oceanByte/bunsquash

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

🐰 bunsquash

A tiny Squoosh like image compressor in a single 100-line file, powered by Bun's built-in image processing. No dependencies.

bunsquash

Run

bun squash.ts
# → http://localhost:3000

(Use bun --hot squash.ts for live reload while editing.)

Use

  1. Drop an image onto the frame (or click to pick one).
  2. Choose a format (webp / jpeg / png) and drag the quality slider.
  3. Drag the divider to compare the original (left) against the compressed result (right).
  4. Hit Download to save the compressed file.

It recompresses on load, when you release the quality slider, and when you switch format.

How it works

The browser POSTs the raw image bytes to /compress?format=…&quality=…. The server pipes them through Bun.Image and streams the result back:

const img = new Bun.Image(await req.arrayBuffer())
const out = img[fmt](fmt === 'png' ? { compression: 9 } : { quality })
return new Response(out) // Content-Type set automatically

That is the whole engine: no sharp or native install step.

Notes

  • Everything (server + UI) lives in squash.ts.

About

A tiny Squoosh-style image compressor app in a single 100-line file. Powered by Bun.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors