trekhleb/js-image-carver — explained in plain English
Analysis updated 2026-05-18
Resize a photo so the main subject stays sharp while background clutter shrinks away.
Paint a mask over an unwanted object in a photo and have the tool carve it out seamlessly.
Try the live demo to see how seam carving works on your own uploaded images.
Study the energy-based algorithm to learn how content-aware image resizing works.
| trekhleb/js-image-carver | lightricks/ltx-desktop | lingyichen-ai/jadeai | |
|---|---|---|---|
| Stars | 1,596 | 1,583 | 1,619 |
| Language | TypeScript | TypeScript | TypeScript |
| Setup difficulty | easy | hard | moderate |
| Complexity | 2/5 | 4/5 | 2/5 |
| Audience | developer | vibe coder | general |
Figures from each repo's GitHub metadata at analysis time.
JS Image Carver is a browser-based tool that resizes photos in a smarter way than standard scaling. Instead of stretching or squishing everything uniformly, it uses an algorithm called Seam Carving to find the least important strip of pixels in the image and removes it, repeating that process until the image reaches the desired size. The result is that the interesting parts of the photo, like a hot air balloon or a person, stay intact while the less interesting background areas shrink away. The core idea is that each pixel gets an "energy" score based on how different it is from its neighbors. Pixels at the edge of objects tend to have high energy because there is a big color change there. Pixels in a flat blue sky have low energy. The algorithm removes the path of lowest-energy pixels from edge to edge, which typically means background pixels go first. This same energy system also enables object removal. If you paint a mask over something you want to delete, the tool artificially sets those pixels to very low energy, making the algorithm treat the masked area as if it were unimportant background. The object gets carved out and the surrounding image closes in around it, without needing any other editing tool. The project includes a live demo where you can upload your own image and watch the carving happen in real time. There is also a blog post and a link to the original academic paper for anyone who wants to understand the math behind it. The current version supports downscaling and object removal, upscaling is listed as a planned future addition. The source code is written in TypeScript and is available on GitHub.
A browser-based tool that resizes photos using seam carving, shrinking backgrounds while keeping the main subject intact, and can also remove unwanted objects.
Mainly TypeScript. The stack also includes TypeScript.
No license information is given in the README.
Setup difficulty is rated easy, with roughly 5min to a first successful run.
Mainly developer.
This repo across BitVibe Labs
Verify against the repo before relying on details.