esimov/caire
Content aware image resize library
What it solves
Caire solves the problem of resizing images (shrinking or enlarging) without distorting or cropping important content. Traditional scaling treats all pixels equally, so key objects like faces can become deformed or lost. Caire uses a technique called seam carving to intelligently remove or add paths of pixels that are least noticeable, keeping the important parts intact.
How it works
Caire first analyzes the image to detect edges, creating an energy map that highlights where visual detail is concentrated. It then finds the least important paths (seams) across the image, either from top to bottom or left to right, by computing cumulative energy values with a dynamic programming approach. The lowest-energy seam is removed (or duplicated for enlarging), and the process repeats until the desired dimensions are reached. The library also includes extra features like face detection to avoid seams passing through faces, and the ability to use masks to protect or remove specific areas.
Who it's for
Caire is for developers, photographers, and anyone who needs high-quality, content-aware image resizing in an automated or command-line environment. It is written in Go and can be used as a library or as a standalone tool, making it easy to integrate into scripts, web services, or pipelines. It is particularly useful when preserving the visual integrity of images matters, such as in portfolio generation, thumbnailing, or batch processing.
Highlights
- Uses seam carving for content-aware resizing that preserves important areas.
- Supports both shrinking and enlarging images, vertically and horizontally.
- Includes face detection to avoid deforming human faces.
- Supports multiple output formats: jpg, jpeg, png, bmp.
- Can process entire directories concurrently.
- Supports stdin/stdout piping for easy integration.
- Offers a GUI preview mode to visualize the process in real time.
- Supports protective and removal masks for fine control.
- Can square images or scale by percentage with a single command.
Related
- Project
- Project
- Project
- Project