Skip to main content

autocrop-rs

Python bindings for the autocrop screenshot content-rectangle detector, built with PyO3 and maturin. The package installs as autocrop-rs and imports as autocrop_rs.

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.0.tar.gz (893.0 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.0-cp311-abi3-win_amd64.whl (820.8 kB view details)

Uploaded CPython 3.11+Windows x86-64

autocrop_rs-0.1.0-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.0-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.0-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (920.5 kB view details)

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

autocrop_rs-0.1.0-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.0-cp311-abi3-macosx_11_0_arm64.whl (841.9 kB view details)

Uploaded CPython 3.11+macOS 11.0+ ARM64

autocrop_rs-0.1.0-cp311-abi3-macosx_10_12_x86_64.whl (891.2 kB view details)

Uploaded CPython 3.11+macOS 10.12+ x86-64

File details

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

File metadata

  • Download URL: autocrop_rs-0.1.0.tar.gz
  • Upload date:
  • Size: 893.0 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.0.tar.gz
Algorithm Hash digest
SHA256 a32bbb369f1ef12fd4bfc255efde450b248ae3b72362d83d48aee6ae0d1a55e1
MD5 14092fd7146a27349eb3e0f914bebe84
BLAKE2b-256 c3777c8f30ba621899d67143388984f20ff6932f8045670e02c46884001aab53

See more details on using hashes here.

Provenance

The following attestation bundles were made for autocrop_rs-0.1.0.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.0-cp311-abi3-win_amd64.whl.

File metadata

  • Download URL: autocrop_rs-0.1.0-cp311-abi3-win_amd64.whl
  • Upload date:
  • Size: 820.8 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.0-cp311-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 51bca3d4f5e0688b3314268e3d2a54d08b01d6ddc5b8178cdd469322dcbd7b2b
MD5 c58002529c001c58583df8efbd50dc2f
BLAKE2b-256 8fc89e644ca9221145f1867641b0d81da10b866c8eb9710447587fc88000cbf9

See more details on using hashes here.

Provenance

The following attestation bundles were made for autocrop_rs-0.1.0-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.0-cp311-abi3-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for autocrop_rs-0.1.0-cp311-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 99f09b09c211b906ef5756f71dfda61d3eebf52402881019c9f70627d4337309
MD5 6cc8027774c362921005a7fa5e691465
BLAKE2b-256 479a171ed93bd21c8ff224a6fc5f777e4f306c8fb1506a241aad7d5961dbe0cb

See more details on using hashes here.

Provenance

The following attestation bundles were made for autocrop_rs-0.1.0-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.0-cp311-abi3-musllinux_1_2_aarch64.whl.

File metadata

File hashes

Hashes for autocrop_rs-0.1.0-cp311-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 1892b74d7abf1790adf2236ef025a0b08627d329d83f8bbb6c0de15407313c43
MD5 8fa0123c1b6ec8930d3105e6326b7d21
BLAKE2b-256 0fdab36cf4d7d41171de32cc72e6f87d895028615c7136e1d23ade6b63aa1dcb

See more details on using hashes here.

Provenance

The following attestation bundles were made for autocrop_rs-0.1.0-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.0-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for autocrop_rs-0.1.0-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 47e095a1f85733d6177c686e9554d5f492acd2e0394b7d3503e655221d9adb0b
MD5 c44fce73a1406d1caa600cfdba8a1b2d
BLAKE2b-256 29a252f20f82a885c4631cea6335daa02bc898266cf4023e2f441451a1464769

See more details on using hashes here.

Provenance

The following attestation bundles were made for autocrop_rs-0.1.0-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.0-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for autocrop_rs-0.1.0-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 90e21adc8848e4faf22f5f9582519e23020d01be4c87772aab9ce56cdd6ac4f5
MD5 a48fc70a7607119613feb06c5b409afa
BLAKE2b-256 4f878a80363c06782fcb73fd7eaa8f31f7394acc28c2170be7a9c29623edf12c

See more details on using hashes here.

Provenance

The following attestation bundles were made for autocrop_rs-0.1.0-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.0-cp311-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for autocrop_rs-0.1.0-cp311-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 0024e949c72f7dff90de833f07e4134a1a143cde9a2a1025900d25f8b84da65e
MD5 b1735c36a72d3a01b4d729fa4cfdbd98
BLAKE2b-256 b9b882df6feb2c800e9c3d72b766b2c7418daf6c4db32ef742ec04ef905a5938

See more details on using hashes here.

Provenance

The following attestation bundles were made for autocrop_rs-0.1.0-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.0-cp311-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for autocrop_rs-0.1.0-cp311-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 06af12fa854c9e836e36e7c3e8823eb670b2ea365e200a423dac8cd17ed54669
MD5 26702be094fa85919b6b1febc99f39e5
BLAKE2b-256 5bd86252acdd71b87eeb57e17ff57943bc77444772f1786045037d918692327d

See more details on using hashes here.

Provenance

The following attestation bundles were made for autocrop_rs-0.1.0-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

0.1.1

8 files

This release

0.1.0 This release

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