Skip to main content

Image utilities with python bindings

Project description

Rusty Image Utils

Port of some slow functions from Python to a Rust library with Python bindings, mainly to experiment with rust-cpython

Published as rusty-img-utils on pypi for Python 3.5, 3.6 and 3.7 on linux and macos

Functions

darken_pixels

Darkens all pixels in the image by percentage, specified by amount. Any pixel that doesn't have a subpixel below than the cutoff will be ignored.

import img_utils
img_utils.darken_pixels(
    src_path="in_file.jpg",
    dst_path="out_file.jpg",
    amount=80,
    cutoff=200,
)

will take the in_file.jpg and lower each subpixel of the image by 80%, unless all the subpixels are above 200.

The RGB pixel 100, 220, 220 will be turned into 20, 44, 44 while 210, 220, 230 will be left alone.

Performance comparison

Testing with 100x100 and 1000x1000 random noise images on a 2018 MBP

darken_pixels

*** Testing small size
Python: 12.46 ms avg (402 runs)
Rust: 1.10 ms avg (4534 runs)

Rust is 11.30x faster for small size

*** Testing normal size
Python: 1138.35 ms avg (5 runs)
Rust: 49.45 ms avg (102 runs)

Rust is 23.02x faster for normal size

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

rusty_img_utils-0.1.4-cp37-cp37m-manylinux1_x86_64.whl (629.5 kB view hashes)

Uploaded CPython 3.7m

rusty_img_utils-0.1.4-cp37-cp37m-macosx_10_7_x86_64.whl (558.0 kB view hashes)

Uploaded CPython 3.7m macOS 10.7+ x86-64

rusty_img_utils-0.1.4-cp36-cp36m-manylinux1_x86_64.whl (629.5 kB view hashes)

Uploaded CPython 3.6m

rusty_img_utils-0.1.4-cp36-cp36m-macosx_10_7_x86_64.whl (558.0 kB view hashes)

Uploaded CPython 3.6m macOS 10.7+ x86-64

rusty_img_utils-0.1.4-cp35-cp35m-manylinux1_x86_64.whl (629.5 kB view hashes)

Uploaded CPython 3.5m

rusty_img_utils-0.1.4-cp35-cp35m-macosx_10_7_x86_64.whl (558.0 kB view hashes)

Uploaded CPython 3.5m macOS 10.7+ x86-64

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page