Skip to main content

SeamOp

CI License: MIT

seamop is a Python library and command-line tool for content-aware image resizing. It shrinks images by removing connected paths of low-energy pixels instead of scaling every pixel or cropping a fixed region.

Original (1428 × 968) Resized (1000 × 900)
Original castle image Content-aware resized castle image

The current beta supports shrinking by seam removal. Enlargement and seam insertion are not implemented.

Installation

Install from PyPI:

python -m pip install seamop

For development, use the locked uv environment:

uv sync --extra dev --frozen

Compatible wheels include the compiled Rust engine. Installing from a source distribution requires a Rust toolchain to build that engine.

Command line

Resize the smaller example to 400 by 240 pixels:

seamop resize examples/medium.jpg 400 240

This writes medium_resized_400x240.jpg in the current directory. Use --output to choose another path. Existing image outputs are not overwritten.

Preview the pixels that the same resize would remove:

seamop highlight examples/medium.jpg 400 240

Remove ten vertical seams:

seamop remove examples/medium.jpg --direction vertical --count 10

The default backward strategy uses gradient energy. Select pure forward energy with --strategy forward; do not combine it with --energy.

Other commands and options are available through the built-in help:

seamop --help
seamop resize --help
seamop remove --help
seamop highlight --help

CLI dimensions use WIDTH HEIGHT.

Python

resize() accepts a filesystem path, Pillow image, RGB uint8 NumPy array, or nested RGB integer list. It returns a new RGB uint8 NumPy array without mutating the input.

from PIL import Image
import seamop

result = seamop.resize(
    "examples/medium.jpg",
    width=400,
    height=240,
)

Image.fromarray(result).save("medium_resized_400x240.jpg")

Use plan() when the carved result and preview must use the same seam decisions:

resize_plan = seamop.plan(
    "examples/medium.jpg",
    width=400,
    height=240,
)

preview = resize_plan.preview()
result = resize_plan.result()

Both output methods return independent arrays. Calling either method does not change the plan.

The default strategy is backward seam carving with GradientEnergy. The forward strategy can be selected explicitly:

from seamop import CarvingStrategy

result = seamop.resize(
    "examples/medium.jpg",
    width=400,
    height=240,
    strategy=CarvingStrategy.FORWARD,
)

Backward carving also accepts built-in or custom energy callables through energy=. Pure forward carving does not accept an energy callable.

The default gradient path and forward strategy run through the compiled Rust engine. Sobel, Laplacian, and custom energy callables remain on the Python path.

See the Python API guide for input rules, custom energy methods, errors, and the advanced seam-calculation interface.

Documentation

Development

Run the repository checks from the project root:

uv run --frozen ruff check src tests benchmarks
uv run --frozen ruff format --check src tests benchmarks
uv run --frozen mypy
uv run --frozen pytest --cov
uv run --frozen pytest --doctest-modules src/seamop

Benchmarks run separately:

uv run --frozen pytest benchmarks

Limitations

  • Only shrinking is supported.
  • Width is reduced before height when both dimensions change.
  • Results depend on the image and selected carving strategy and energy method.
  • Large reductions can distort important content.

License

MIT

Metadata

Release files for seamop 0.4.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for seamop 0.4.1
File Size Uploaded Provenance Actions
seamop-0.4.1.tar.gz 23.7 kB With provenance Details for seamop-0.4.1.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for seamop 0.4.1
File Actions
seamop-0.4.1-cp310-abi3-win_amd64.whl CPython 3.10 abi3 Windows x86-64 Details for seamop-0.4.1-cp310-abi3-win_amd64.whl
seamop-0.4.1-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.10 abi3 Linux glibc 2.17+ x86-64 Details for seamop-0.4.1-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
seamop-0.4.1-cp310-abi3-macosx_11_0_arm64.whl CPython 3.10 abi3 macOS 11.0+ ARM64 Details for seamop-0.4.1-cp310-abi3-macosx_11_0_arm64.whl
seamop-0.4.1-cp310-abi3-macosx_10_12_x86_64.whl CPython 3.10 abi3 macOS 10.12+ x86-64 Details for seamop-0.4.1-cp310-abi3-macosx_10_12_x86_64.whl

Total release size: 1.1 MB

Release files / seamop-0.4.1.tar.gz

Download URL seamop-0.4.1.tar.gz
Size 23.7 kB
Tags Source
SHA-256 checksum
How to use checksums
35ec00d6b29696398c9609f7e3e2f9611f52a11db1b40e0646966eb91018e375
BLAKE2b-256 checksum
How to use checksums
9c7cea49519793e90052545732e8cbb3948a2deb8de391c3fff686b96b7baaf9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 13, 2026.

Transparency log

Release files / seamop-0.4.1-cp310-abi3-win_amd64.whl

Download URL seamop-0.4.1-cp310-abi3-win_amd64.whl
Size 172.6 kB
Tags CPython 3.10 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
5df636bcbb176f3962dd71650626413e2e02e1a6ce4f9acf9613ef4d7012b0b3
BLAKE2b-256 checksum
How to use checksums
b99a334918469714bd8ebbb5584f35a486102748b4f6f631f4eb102eae4bf05c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 13, 2026.

Transparency log

Release files / seamop-0.4.1-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL seamop-0.4.1-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 321.4 kB
Tags CPython 3.10 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
6fd513c42b0815925379eaab38c020969c39431121177437009cbfe47b006704
BLAKE2b-256 checksum
How to use checksums
afd97bdf66eedb55b420f1f1af53a230f797cb42199a4c27342a99687191f4ba
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 13, 2026.

Transparency log

Release files / seamop-0.4.1-cp310-abi3-macosx_11_0_arm64.whl

Download URL seamop-0.4.1-cp310-abi3-macosx_11_0_arm64.whl
Size 283.2 kB
Tags CPython 3.10 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
c35304a2c43dc602679775ffea0c69c17438e3645ec23a062aef380c8a3de879
BLAKE2b-256 checksum
How to use checksums
6d829b97a8b06d40611f7b125838d83d2a4c72895d9f66ac2dd0f1171146ed22
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 13, 2026.

Transparency log

Release files / seamop-0.4.1-cp310-abi3-macosx_10_12_x86_64.whl

Download URL seamop-0.4.1-cp310-abi3-macosx_10_12_x86_64.whl
Size 283.0 kB
Tags CPython 3.10 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
b2aaeb23cd1d1a9b803ee81a7c1067d9a361b01f1e8c7e257c227b218dcfd5e8
BLAKE2b-256 checksum
How to use checksums
36adb797bc086270ba4b26045368dc924a88980981bfbee3d7fd88e50fe811c5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 13, 2026.

Transparency log

Security for seamop 0.4.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 5 files in this release have been uploaded with provenance metadata.

Select from 5 files

Attestation for seamop-0.4.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 13, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page