whatisgithub

What is js-image-carver?

trekhleb/js-image-carver — explained in plain English

Analysis updated 2026-05-18

1,596TypeScriptAudience · developerComplexity · 2/5Setup · easy

In one sentence

A browser-based tool that resizes photos using seam carving, shrinking backgrounds while keeping the main subject intact, and can also remove unwanted objects.

Mindmap

mindmap
  root((JS Image Carver))
    What it does
      Seam carving resize
      Content-aware scaling
      Object removal
    Tech stack
      TypeScript
      Browser based
    Use cases
      Resizing photos
      Removing objects from images
      Learning image algorithms
    Audience
      Developers
      Designers
    Status
      Downscaling supported
      Upscaling planned

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

What do people build with it?

USE CASE 1

Resize a photo so the main subject stays sharp while background clutter shrinks away.

USE CASE 2

Paint a mask over an unwanted object in a photo and have the tool carve it out seamlessly.

USE CASE 3

Try the live demo to see how seam carving works on your own uploaded images.

USE CASE 4

Study the energy-based algorithm to learn how content-aware image resizing works.

What is it built with?

TypeScript

How does it compare?

trekhleb/js-image-carverlightricks/ltx-desktoplingyichen-ai/jadeai
Stars1,5961,5831,619
LanguageTypeScriptTypeScriptTypeScript
Setup difficultyeasyhardmoderate
Complexity2/54/52/5
Audiencedevelopervibe codergeneral

Figures from each repo's GitHub metadata at analysis time.

How do you get it running?

Difficulty · easy Time to first run · 5min
No license information is given in the README.

So what is it?

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.

Copy-paste prompts

Prompt 1
Explain how seam carving calculates pixel energy and decides which pixels to remove.
Prompt 2
Show me how to use the live demo to remove an object from a photo with a mask.
Prompt 3
Help me understand the academic paper behind seam carving in plain terms.
Prompt 4
Walk me through how this differs from simply cropping or stretching an image.

Frequently asked questions

What is js-image-carver?

A browser-based tool that resizes photos using seam carving, shrinking backgrounds while keeping the main subject intact, and can also remove unwanted objects.

What language is js-image-carver written in?

Mainly TypeScript. The stack also includes TypeScript.

What license does js-image-carver use?

No license information is given in the README.

How hard is js-image-carver to set up?

Setup difficulty is rated easy, with roughly 5min to a first successful run.

Who is js-image-carver for?

Mainly developer.

Open on GitHub → Ask about another repo

This repo across BitVibe Labs

Verify against the repo before relying on details.