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

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

seamop-0.4.1.tar.gz (23.7 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

seamop-0.4.1-cp310-abi3-win_amd64.whl (172.6 kB view details)

Uploaded CPython 3.10+Windows x86-64

seamop-0.4.1-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (321.4 kB view details)

Uploaded CPython 3.10+manylinux: glibc 2.17+ x86-64

seamop-0.4.1-cp310-abi3-macosx_11_0_arm64.whl (283.2 kB view details)

Uploaded CPython 3.10+macOS 11.0+ ARM64

seamop-0.4.1-cp310-abi3-macosx_10_12_x86_64.whl (283.0 kB view details)

Uploaded CPython 3.10+macOS 10.12+ x86-64

File details

Details for the file seamop-0.4.1.tar.gz.

File metadata

  • Download URL: seamop-0.4.1.tar.gz
  • Upload date:
  • Size: 23.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for seamop-0.4.1.tar.gz
Algorithm Hash digest
SHA256 35ec00d6b29696398c9609f7e3e2f9611f52a11db1b40e0646966eb91018e375
MD5 7fa765b86c7a0e1b57a25f697762422a
BLAKE2b-256 9c7cea49519793e90052545732e8cbb3948a2deb8de391c3fff686b96b7baaf9

See more details on using hashes here.

Provenance

The following attestation bundles were made for seamop-0.4.1.tar.gz:

Publisher: release.yml on okinealb/seamop

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file seamop-0.4.1-cp310-abi3-win_amd64.whl.

File metadata

  • Download URL: seamop-0.4.1-cp310-abi3-win_amd64.whl
  • Upload date:
  • Size: 172.6 kB
  • Tags: CPython 3.10+, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for seamop-0.4.1-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 5df636bcbb176f3962dd71650626413e2e02e1a6ce4f9acf9613ef4d7012b0b3
MD5 d950a32c440dab01758a80ff32691859
BLAKE2b-256 b99a334918469714bd8ebbb5584f35a486102748b4f6f631f4eb102eae4bf05c

See more details on using hashes here.

Provenance

The following attestation bundles were made for seamop-0.4.1-cp310-abi3-win_amd64.whl:

Publisher: release.yml on okinealb/seamop

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file seamop-0.4.1-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for seamop-0.4.1-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 6fd513c42b0815925379eaab38c020969c39431121177437009cbfe47b006704
MD5 579af82788c5377528c4b060d2534d42
BLAKE2b-256 afd97bdf66eedb55b420f1f1af53a230f797cb42199a4c27342a99687191f4ba

See more details on using hashes here.

Provenance

The following attestation bundles were made for seamop-0.4.1-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: release.yml on okinealb/seamop

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file seamop-0.4.1-cp310-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for seamop-0.4.1-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c35304a2c43dc602679775ffea0c69c17438e3645ec23a062aef380c8a3de879
MD5 43aef0b50bc25664754372425ac3f8d5
BLAKE2b-256 6d829b97a8b06d40611f7b125838d83d2a4c72895d9f66ac2dd0f1171146ed22

See more details on using hashes here.

Provenance

The following attestation bundles were made for seamop-0.4.1-cp310-abi3-macosx_11_0_arm64.whl:

Publisher: release.yml on okinealb/seamop

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file seamop-0.4.1-cp310-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for seamop-0.4.1-cp310-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 b2aaeb23cd1d1a9b803ee81a7c1067d9a361b01f1e8c7e257c227b218dcfd5e8
MD5 41286553e049eadf2c703d685df51426
BLAKE2b-256 36adb797bc086270ba4b26045368dc924a88980981bfbee3d7fd88e50fe811c5

See more details on using hashes here.

Provenance

The following attestation bundles were made for seamop-0.4.1-cp310-abi3-macosx_10_12_x86_64.whl:

Publisher: release.yml on okinealb/seamop

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

0.4.1 This release

5 files

0.4.0

2 files

0.3.0

2 files

0.2.0

2 files

0.1.5

2 files

0.1.4

2 files

0.1.3

2 files

0.1.2

2 files

0.1.1

2 files

0.1.0

2 files

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