Skip to main content

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.

extract_blues

Selects all pixels that have the blue pixel above a certain limit and either green or red the minimum difference blow the blue pixel. The selected pixels will be output as completely black while any other pixel is output as white.

import img_utils
img_utils.extract_blues(
    src_path="in_file.jpg",
    dst_path="out_file.jpg",
    min_diff=30,
    min_blue=100,
)

will take the in_file.jpg and any pixel that has the blue pixel 100 or higher and either red or green pixel at 70 or lower (100 - 30) will be black, all others will be white.

Performance comparison

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

darken_pixels

*** Testing small size
Python_Darken: 12.14 ms avg (412 runs)
Rust_Darken: 1.15 ms avg (4357 runs)

Rust is 10.58x faster for small size

*** Testing normal size
Python_Darken: 1103.74 ms avg (5 runs)
Rust_Darken: 46.41 ms avg (108 runs)

Rust is 23.78x faster for normal size

extract_blues

*** Testing small size
Python_Extract: 4.94 ms avg (1012 runs)
Rust_Extract: 1.17 ms avg (4282 runs)

Rust is 4.23x faster for small size

*** Testing normal size
Python_Extract: 392.25 ms avg (13 runs)
Rust_Extract: 47.71 ms avg (105 runs)

Rust is 8.22x faster for normal size

Release files for rusty-img-utils 0.3.1

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

Built distributions (wheels)

Table of built distributions (wheels) for rusty-img-utils 0.3.1
File
rusty_img_utils-0.3.1-cp38-cp38-manylinux1_x86_64.whl CPython 3.8 CPython 3.8 Linux glibc 2.5+ x86-64 Details
rusty_img_utils-0.3.1-cp38-cp38-macosx_10_7_x86_64.whl CPython 3.8 CPython 3.8 macOS 10.7+ x86-64 Details
rusty_img_utils-0.3.1-cp37-cp37m-manylinux1_x86_64.whl CPython 3.7 CPython 3.7 pymalloc Linux glibc 2.5+ x86-64 Details
rusty_img_utils-0.3.1-cp37-cp37m-macosx_10_7_x86_64.whl CPython 3.7 CPython 3.7 pymalloc macOS 10.7+ x86-64 Details
rusty_img_utils-0.3.1-cp36-cp36m-manylinux1_x86_64.whl CPython 3.6 CPython 3.6 pymalloc Linux glibc 2.5+ x86-64 Details
rusty_img_utils-0.3.1-cp36-cp36m-macosx_10_7_x86_64.whl CPython 3.6 CPython 3.6 pymalloc macOS 10.7+ x86-64 Details
rusty_img_utils-0.3.1-cp35-cp35m-manylinux1_x86_64.whl CPython 3.5 CPython 3.5 pymalloc Linux glibc 2.5+ x86-64 Details
rusty_img_utils-0.3.1-cp35-cp35m-macosx_10_7_x86_64.whl CPython 3.5 CPython 3.5 pymalloc macOS 10.7+ x86-64 Details

Total release size: 4.3 MB

Release files / rusty_img_utils-0.3.1-cp38-cp38-manylinux1_x86_64.whl

Download URL rusty_img_utils-0.3.1-cp38-cp38-manylinux1_x86_64.whl
Size 566.4 kB
Tags CPython 3.8 Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
58550f951dc35ff9e6fb404c6d154b3c1a816607927c3162320e0924975fdc30
BLAKE2b-256 checksum
How to use checksums
3a711c3bb5b5e40f2cccb402e2066c4d9d44b8cb29f2a74ed198792b705eeb5f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/0.7.6

Release files / rusty_img_utils-0.3.1-cp38-cp38-macosx_10_7_x86_64.whl

Download URL rusty_img_utils-0.3.1-cp38-cp38-macosx_10_7_x86_64.whl
Size 507.0 kB
Tags CPython 3.8 macOS 10.7+ x86-64
SHA-256 checksum
How to use checksums
a50ccf6f80388bcb0d824161f771239a56f85f1ab0b6f9f4ab97a263ce030106
BLAKE2b-256 checksum
How to use checksums
d620fd3042e05718822ec435788b751b492db5a928451516dc74321abe50813c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/0.7.6

Release files / rusty_img_utils-0.3.1-cp37-cp37m-manylinux1_x86_64.whl

Download URL rusty_img_utils-0.3.1-cp37-cp37m-manylinux1_x86_64.whl
Size 566.4 kB
Tags CPython 3.7 CPython 3.7 pymalloc Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
a89d7d72b57c4d7a13b07c800bc8abe25b6f1156068cf3ad12e6ca4535308bc8
BLAKE2b-256 checksum
How to use checksums
6bc4a7eafaa18d55aa903a4c77aeffe83905b5102bed90e69fe0cf2223e4f466
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/0.7.6

Release files / rusty_img_utils-0.3.1-cp37-cp37m-macosx_10_7_x86_64.whl

Download URL rusty_img_utils-0.3.1-cp37-cp37m-macosx_10_7_x86_64.whl
Size 507.0 kB
Tags CPython 3.7 CPython 3.7 pymalloc macOS 10.7+ x86-64
SHA-256 checksum
How to use checksums
4a7202ae116282cbf019d69e3492567614eb472d80d97c3795fb20a3d7a6b555
BLAKE2b-256 checksum
How to use checksums
c106ae6ac85c373f1f236e424ccefd62f2ab8588585afce666ae41bcb23774bb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/0.7.6

Release files / rusty_img_utils-0.3.1-cp36-cp36m-manylinux1_x86_64.whl

Download URL rusty_img_utils-0.3.1-cp36-cp36m-manylinux1_x86_64.whl
Size 566.4 kB
Tags CPython 3.6 CPython 3.6 pymalloc Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
23b00f8a06a30fe639094b2a22f4ffc01cf33e823c8eba804f56e2b56431fb76
BLAKE2b-256 checksum
How to use checksums
0e8c8a7d430226a72568e4890e6985bef52a385afd28ff333b755650e65edf2b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/0.7.6

Release files / rusty_img_utils-0.3.1-cp36-cp36m-macosx_10_7_x86_64.whl

Download URL rusty_img_utils-0.3.1-cp36-cp36m-macosx_10_7_x86_64.whl
Size 507.0 kB
Tags CPython 3.6 CPython 3.6 pymalloc macOS 10.7+ x86-64
SHA-256 checksum
How to use checksums
f772c19b945622afaf749f4b3029821ee70b17dc854fe804498cb3f42c133d17
BLAKE2b-256 checksum
How to use checksums
a724bddbd01caf059542f69fba968173fe764bbb916e27cf25189fe5d7095efc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/0.7.6

Release files / rusty_img_utils-0.3.1-cp35-cp35m-manylinux1_x86_64.whl

Download URL rusty_img_utils-0.3.1-cp35-cp35m-manylinux1_x86_64.whl
Size 566.4 kB
Tags CPython 3.5 CPython 3.5 pymalloc Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
f95db95c7f98be8daad044387c36b66357074db5f66c10e50321b7d576bf3e75
BLAKE2b-256 checksum
How to use checksums
fd318922fc7319a9809a8af66f8c5dce256f710e0c4c6ecf7ce75b2853e6301e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/0.7.6

Release files / rusty_img_utils-0.3.1-cp35-cp35m-macosx_10_7_x86_64.whl

Download URL rusty_img_utils-0.3.1-cp35-cp35m-macosx_10_7_x86_64.whl
Size 507.0 kB
Tags CPython 3.5 CPython 3.5 pymalloc macOS 10.7+ x86-64
SHA-256 checksum
How to use checksums
ab63eb372280446073d5eaf709ca509c3670af7c2d49e48138639dca6ef495c0
BLAKE2b-256 checksum
How to use checksums
2321a8979cc4b9a7f38d8769c6f2256f05c250ad495c8a404ac7ee02f1102e95
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/0.7.6

Release history Release notifications | RSS feed

This release

0.3.1 This release

8 release files

0.3.0

6 release files

0.2.0

6 release files

0.1.5

6 release files

0.1.4

6 release files

0.1.3

6 release 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