Skip to main content

autocrop-rs

PyPI crates.io CI

Finds the actual content inside a screenshot and crops away letterbox bars, app chrome and meme text, while leaving photos, art and manga pages untouched. Python bindings for the Rust autocrop crate: the package installs as autocrop-rs, imports as autocrop_rs and ships the command line as uvx autocrop-rs.

Example

A phone screenshot of a tweet with an embedded stream clip (1194 x 2560), the crop autocrop writes (1194 x 670), and a debug overlay showing the row and column profiles the detector works from together with the chosen box.

input crop debug overlay
input crop debug overlay
$ uvx autocrop-rs example.jpg --out out --time
example.jpg: chrome score=0.86 box=Some((0, 822, 1194, 1492))
  decode 16.6 ms, detect 11.0 ms (1194x2560)

Build and test

Rust toolchain required (the extension is compiled on install):

cd python
uv sync            # builds the extension into the venv via maturin
uv run pytest
uv sync --reinstall-package autocrop-rs   # after changing Rust code (uv caches the build)

Released wheels are on PyPI: pip install autocrop-rs (or uv add autocrop-rs). To build one locally: uv run maturin build --release. The wheel is abi3 for CPython 3.11 and newer.

Usage

import autocrop_rs

result = autocrop_rs.detect_file("screenshot.jpg")
if result:  # truthy when a crop was found
    x0, y0, x1, y1 = result.box  # original pixel coordinates
print(result.reason, result.score)

# Encoded bytes (e.g. straight from an HTTP response or a database blob)
result = autocrop_rs.detect_bytes(data)

# An already decoded HxWx3 uint8 RGB array (numpy, or anything with the buffer protocol)
import numpy as np
from PIL import Image

result = autocrop_rs.detect_array(np.asarray(Image.open("screenshot.jpg").convert("RGB")))

# Detect and write the crop in one call (format by extension); writes nothing when box is None
autocrop_rs.crop_file("screenshot.jpg", "out/screenshot.png")

# Bytes in, bytes out: no decoding or re-encoding on the Python side
result, png = autocrop_rs.crop_bytes(data)  # PNG by default
result, jpg = autocrop_rs.crop_bytes(data, format="jpeg", quality=85)
result = autocrop_rs.crop_bytes_to_file(data, "out/screenshot.webp")  # format by extension

# Thresholds
params = autocrop_rs.Params(accept_score=0.5)
result = autocrop_rs.detect_file("screenshot.jpg", params)
params.to_dict()  # every field and its value

All four functions release the GIL while decoding and detecting, so they can run in a thread pool.

Download files

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

Source Distribution

autocrop_rs-0.1.1.tar.gz (893.1 kB view details)

Uploaded Source

Built Distributions

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

autocrop_rs-0.1.1-cp311-abi3-win_amd64.whl (812.7 kB view details)

Uploaded CPython 3.11+Windows x86-64

autocrop_rs-0.1.1-cp311-abi3-musllinux_1_2_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.11+musllinux: musl 1.2+ x86-64

autocrop_rs-0.1.1-cp311-abi3-musllinux_1_2_aarch64.whl (1.1 MB view details)

Uploaded CPython 3.11+musllinux: musl 1.2+ ARM64

autocrop_rs-0.1.1-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (921.1 kB view details)

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

autocrop_rs-0.1.1-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (888.2 kB view details)

Uploaded CPython 3.11+manylinux: glibc 2.17+ ARM64

autocrop_rs-0.1.1-cp311-abi3-macosx_11_0_arm64.whl (842.6 kB view details)

Uploaded CPython 3.11+macOS 11.0+ ARM64

autocrop_rs-0.1.1-cp311-abi3-macosx_10_12_x86_64.whl (889.6 kB view details)

Uploaded CPython 3.11+macOS 10.12+ x86-64

File details

Details for the file autocrop_rs-0.1.1.tar.gz.

File metadata

  • Download URL: autocrop_rs-0.1.1.tar.gz
  • Upload date:
  • Size: 893.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for autocrop_rs-0.1.1.tar.gz
Algorithm Hash digest
SHA256 a9c55628531c0b8cf3366f9c25fa8c0187f252e7ff2086f354e4728d3bf9de01
MD5 ec7654d860d87f14217b736960663f34
BLAKE2b-256 371628c0657eb9d5fb2bf1a0555e2434f874e881295708a6f7f8216a281375fa

See more details on using hashes here.

Provenance

The following attestation bundles were made for autocrop_rs-0.1.1.tar.gz:

Publisher: release.yml on Nachtalb/autocrop-rs

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

File details

Details for the file autocrop_rs-0.1.1-cp311-abi3-win_amd64.whl.

File metadata

  • Download URL: autocrop_rs-0.1.1-cp311-abi3-win_amd64.whl
  • Upload date:
  • Size: 812.7 kB
  • Tags: CPython 3.11+, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for autocrop_rs-0.1.1-cp311-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 e926a096fd8f93787d5f07e086db6d57f3ba6208a72e283f02e03f455305f705
MD5 33860f925759155fbd56a5573f2d5377
BLAKE2b-256 0398427a98f3984130ac6b023ce3186353dcfd497c16f8eed1cefcaae84cca3d

See more details on using hashes here.

Provenance

The following attestation bundles were made for autocrop_rs-0.1.1-cp311-abi3-win_amd64.whl:

Publisher: release.yml on Nachtalb/autocrop-rs

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

File details

Details for the file autocrop_rs-0.1.1-cp311-abi3-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for autocrop_rs-0.1.1-cp311-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 81b7e841b37d2778d59f13e1ff2e819bff71f2e7f8ba69333c83f30670c0b139
MD5 7d4d2c21e307c35eaf7bcd0595f491ca
BLAKE2b-256 a12788fbbf9b24b02d40d4872ef95374c10e34543e41d08375372808677717a5

See more details on using hashes here.

Provenance

The following attestation bundles were made for autocrop_rs-0.1.1-cp311-abi3-musllinux_1_2_x86_64.whl:

Publisher: release.yml on Nachtalb/autocrop-rs

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

File details

Details for the file autocrop_rs-0.1.1-cp311-abi3-musllinux_1_2_aarch64.whl.

File metadata

File hashes

Hashes for autocrop_rs-0.1.1-cp311-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 af74db490a215f0bc34fe2fed24b573207b390ea57873ec98fccee1eb6654d5b
MD5 59c9971771fb7b8367e77d74955097ae
BLAKE2b-256 5f51a2b309c67a4d99fbd3adda69843a13ec677ce10b2a94c6404082cf88c793

See more details on using hashes here.

Provenance

The following attestation bundles were made for autocrop_rs-0.1.1-cp311-abi3-musllinux_1_2_aarch64.whl:

Publisher: release.yml on Nachtalb/autocrop-rs

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

File details

Details for the file autocrop_rs-0.1.1-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for autocrop_rs-0.1.1-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 0be09164fb651bb3bd410a752d6f0cce05b7b4e16dbfe40edeb146b01bbc7355
MD5 7f996f0a4da85d127825df444346ed6b
BLAKE2b-256 08fa1220ee5646f1f5f6d361b6dafc12ebd51c5d1e2780572459686cc04b7113

See more details on using hashes here.

Provenance

The following attestation bundles were made for autocrop_rs-0.1.1-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: release.yml on Nachtalb/autocrop-rs

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

File details

Details for the file autocrop_rs-0.1.1-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for autocrop_rs-0.1.1-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 cfb762439787e9b8d87ea9d8dd5d43c460c8b4b6afbd49d9221f116e1708d383
MD5 c3c6d2b1981bab7e206901dd3ff6f4fc
BLAKE2b-256 4692a07304671f6e57a9f798de1ef22d513e67257504aa1ac8ebb22abdb09359

See more details on using hashes here.

Provenance

The following attestation bundles were made for autocrop_rs-0.1.1-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: release.yml on Nachtalb/autocrop-rs

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

File details

Details for the file autocrop_rs-0.1.1-cp311-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for autocrop_rs-0.1.1-cp311-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 0c323c343878c5e115c324eb55217f73f0fa254ca98363b078f23247677e6109
MD5 e3420e177238ed4e675b1b7042f2a541
BLAKE2b-256 7154b503245846a7954b80da005ee1e034ed1aff70d0700cde22198328fd38b1

See more details on using hashes here.

Provenance

The following attestation bundles were made for autocrop_rs-0.1.1-cp311-abi3-macosx_11_0_arm64.whl:

Publisher: release.yml on Nachtalb/autocrop-rs

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

File details

Details for the file autocrop_rs-0.1.1-cp311-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for autocrop_rs-0.1.1-cp311-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 fcd9f4c4a16f34be82946a3c37f3b5d696c7a898b15f94e77141617b7e40de31
MD5 4475dbb6e6b19099629a2d153b8d8910
BLAKE2b-256 0fdc942a0ad6880d573f94117e2ffb81bdfc914add6ba148a82bf516e6495bae

See more details on using hashes here.

Provenance

The following attestation bundles were made for autocrop_rs-0.1.1-cp311-abi3-macosx_10_12_x86_64.whl:

Publisher: release.yml on Nachtalb/autocrop-rs

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.1.1 This release

8 files

0.1.0

8 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