A small CPU image scaling library with SIMD support on x86_64 and Arm (Neon). This project is aimed to replace OpenCV for image resizing, resolving installation inconveniences and compatibility issues. We developed this for future use in Gymnasium and PettingZoo wrappers.
Installation
You can install from PyPI using pip install tinyscaler. Linux and macOS with Python >=3.8 are supported.
Usage
Tinyscaler contains a single external function, scale that using a numpy array input for the image and the new resized shape, returns the resized image.
import numpy as np
import tinyscaler
img = np.random.rand(64, 64, 4).astype(np.float32)
resize_img = tinyscaler.scale(img, (32, 32))
print(resize_img.shape, resize_img.dtype) # (32, 32) np.float32
TinyScaler supports mode='area', mode='bilinear', and mode='nearest' filtering. It also allows one to pass a destination buffer in order to avoid duplicate memory allocations.
Area filtering is only really useful for downscaling, bilinear will be used even when area filtering is set if upscaling. Area filtering is also likely not worth it when downscaling less than or equal to 2x.
TinyScaler is used through a single function. The full signature is:
scale(src : np.ndarray, size : tuple, mode='area', dst : np.ndarray = None)
Note that the size tuple parameter is (width, height). However, the numpy arrays have dimensions ordered as (height, width, channels). This is similar to OpenCV.
TinyScaler expects a contiguous numpy array. If it is not contiguous, it will throw an error. You can make a non-contiguous numpy array contiguous by calling np.ascontiguousarray. Usually a numpy array will already be contiguous.
If the final array dimension is not 4 (RGBA), it will automatically convert to it. Further, if the array is uint8, it will be converted to float32. So the prefered array has a shape (height, width, 4) and dtype=np.float32.
Finally, downscaling is the focus of TinyScaler. It can also upscale, but it will not be as fast as a more complex separable algorithm in that case.
Performance
In a simple benchmark, we resized the same image (4928x3279) down to (852x567) 100 times using bilinear filtering with several libraries. Here are the times (in seconds) spent (measured with Python's perf_counter) on a AMD 1950x:
Time elapsed for tinyscaler: 0.7968465110002398
Time elapsed for OpenCV: 0.48667862100001
Time elapsed for Pillow: 12.672875003999707
Time elapsed for skimage: 164.45401711399973
And with area filtering (just TinyScaler and OpenCV):
Time elapsed for tinyscaler: 4.34793155800071
Time elapsed for OpenCV: 8.118138265999733
All methods were forced to use a single thread. OpenCV is slightly faster than TinyScaler for bilinear filtering, but TinyScaler remains very fast regardless.
Interestingly, for area filtering, TinyScaler is faster (almost 2x).
Metadata
Release files for tinyscaler 1.2.8
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| tinyscaler-1.2.8.tar.gz | 156.9 kB | Without provenance | Details for tinyscaler-1.2.8.tar.gz |
Built distributions (wheels)
Total release size: 4.2 MB
Release files / tinyscaler-1.2.8.tar.gz
| Download URL | tinyscaler-1.2.8.tar.gz |
|---|---|
| Size | 156.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0ce3b77562f1db74b2035ccaf62807af043333ce655e71effd6ec85fbf8ded06
|
|
BLAKE2b-256 checksum How to use checksums |
0d596b6495fe9bb3153306a4bd6dd24c78ff74eaf64f90fc6e545ede0574cfbe
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.0 CPython/3.12.4
|
Release files / tinyscaler-1.2.8-cp312-cp312-win_amd64.whl
| Download URL | tinyscaler-1.2.8-cp312-cp312-win_amd64.whl |
|---|---|
| Size | 83.8 kB |
| Tags | CPython 3.12 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
6a7c18d9c082f30193bd23a6eb8ad84d2ee9b224138c8c25a76db96cba71a473
|
|
BLAKE2b-256 checksum How to use checksums |
68d00b0abfde6acdf79b41ea685067a52d3e47f3b1fb4a0f4f49d9c6f281a3c7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.0 CPython/3.12.4
|
Release files / tinyscaler-1.2.8-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | tinyscaler-1.2.8-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 563.6 kB |
| Tags | CPython 3.12 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
7474fe93740b0aa045e4e2ad60f8df6d5d570c4ea903c6d63ca3868efd8f4e22
|
|
BLAKE2b-256 checksum How to use checksums |
b7cf528a73de4ad128de99bf7cc0e80f236aeeb36fda1e2768a7eb73210a91ff
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.0 CPython/3.12.4
|
Release files / tinyscaler-1.2.8-cp312-cp312-macosx_10_9_universal2.whl
| Download URL | tinyscaler-1.2.8-cp312-cp312-macosx_10_9_universal2.whl |
|---|---|
| Size | 179.8 kB |
| Tags | CPython 3.12 macOS 10.9+ universal2 (ARM64, x86-64) |
|
SHA-256 checksum How to use checksums |
fcafd6a8b7ac8c8eabc560f99f987e3e9c00b32a5f3472b28ee865db9bf264b2
|
|
BLAKE2b-256 checksum How to use checksums |
4b6506fa456d375b71672affd292dd79f199b21a574eb0501afa142f85133b99
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.0 CPython/3.12.4
|
Release files / tinyscaler-1.2.8-cp311-cp311-win_amd64.whl
| Download URL | tinyscaler-1.2.8-cp311-cp311-win_amd64.whl |
|---|---|
| Size | 84.0 kB |
| Tags | CPython 3.11 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
93869b729bc2d596e2b2e0803d2f9e0e1a0baced6c96b8c21af178b3061b3fba
|
|
BLAKE2b-256 checksum How to use checksums |
218fc064ace9fe32a3968eedd1ae19f079020f0fdd55e811dfd1c7a2b6cc442f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.0 CPython/3.12.4
|
Release files / tinyscaler-1.2.8-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | tinyscaler-1.2.8-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 563.3 kB |
| Tags | CPython 3.11 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
a7dbf9f80ba08918c304261e2f8e3356eccbc925364b706cef2997f0abf0fc91
|
|
BLAKE2b-256 checksum How to use checksums |
3b0ec52b316dccb2181521a5faca6ef404670e567dddb6f38cbd72175af23d49
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.0 CPython/3.12.4
|
Release files / tinyscaler-1.2.8-cp311-cp311-macosx_10_9_universal2.whl
| Download URL | tinyscaler-1.2.8-cp311-cp311-macosx_10_9_universal2.whl |
|---|---|
| Size | 178.3 kB |
| Tags | CPython 3.11 macOS 10.9+ universal2 (ARM64, x86-64) |
|
SHA-256 checksum How to use checksums |
57ad9b0203e984ad140b31f0fe82f8bd82e4c31574461264a9a6e7f7d105eb50
|
|
BLAKE2b-256 checksum How to use checksums |
01c9a2dbce5c9ecfaff4887bc0f5ff2288c678e25810801e84ddd737d4c0f3e8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.0 CPython/3.12.4
|
Release files / tinyscaler-1.2.8-cp310-cp310-win_amd64.whl
| Download URL | tinyscaler-1.2.8-cp310-cp310-win_amd64.whl |
|---|---|
| Size | 83.9 kB |
| Tags | CPython 3.10 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
34d43fad3e09331b7a9259ee11ff4c209c31f00129b3a0c98480f7e43c789c2f
|
|
BLAKE2b-256 checksum How to use checksums |
707eb42030012265686e2f95f2449dd7e40b1e54d92a371f90b11c11bdd8b6c3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.0 CPython/3.12.4
|
Release files / tinyscaler-1.2.8-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | tinyscaler-1.2.8-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 522.8 kB |
| Tags | CPython 3.10 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
fb30db6782df95c34b294266876e71fd3d32dd3d33bf4c8ec72d07f570ae7bca
|
|
BLAKE2b-256 checksum How to use checksums |
b7b23c38f6727b1618160248b6c56486eb006db153c2ca99381251343cd54376
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.0 CPython/3.12.4
|
Release files / tinyscaler-1.2.8-cp310-cp310-macosx_10_9_universal2.whl
| Download URL | tinyscaler-1.2.8-cp310-cp310-macosx_10_9_universal2.whl |
|---|---|
| Size | 178.5 kB |
| Tags | CPython 3.10 macOS 10.9+ universal2 (ARM64, x86-64) |
|
SHA-256 checksum How to use checksums |
b69a0414d626ba5d075b93546f37ece0c10f690f7d3ce3f162c2316ac1667511
|
|
BLAKE2b-256 checksum How to use checksums |
96140b47fbc882faa2358fc205734bd4b872c84539ef8231bbf1ef2eb5e99506
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.0 CPython/3.12.4
|
Release files / tinyscaler-1.2.8-cp39-cp39-win_amd64.whl
| Download URL | tinyscaler-1.2.8-cp39-cp39-win_amd64.whl |
|---|---|
| Size | 84.5 kB |
| Tags | CPython 3.9 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
17409e85ff23d5eb29da65d6cdfdeafeb7d94b7c8051b1ab8457886ceb61b234
|
|
BLAKE2b-256 checksum How to use checksums |
4f2f263d8d100c501959662986b065e91f9fc59e5ff4cecc0b511009eac97711
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.0 CPython/3.12.4
|
Release files / tinyscaler-1.2.8-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | tinyscaler-1.2.8-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 524.8 kB |
| Tags | CPython 3.9 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
aa5eb3d4ba1fb803e1616fde7f58126355a47c6ca79c3393907e21c677bc5d37
|
|
BLAKE2b-256 checksum How to use checksums |
eb31c54ebf036e092cc31ecfd7ccc2970165ce72679f3c1be43f7cddc1aa5e2d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.0 CPython/3.12.4
|
Release files / tinyscaler-1.2.8-cp39-cp39-macosx_10_9_universal2.whl
| Download URL | tinyscaler-1.2.8-cp39-cp39-macosx_10_9_universal2.whl |
|---|---|
| Size | 179.7 kB |
| Tags | CPython 3.9 macOS 10.9+ universal2 (ARM64, x86-64) |
|
SHA-256 checksum How to use checksums |
3143352056dc9ac2ab87795fa3f36498c52ae603b76b3b73189544c588f46d77
|
|
BLAKE2b-256 checksum How to use checksums |
6b1bb291ab1c819a1bca3e6fa1f924d5fa14fc12603504bc7f5cf63599fe7878
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.0 CPython/3.12.4
|
Release files / tinyscaler-1.2.8-cp38-cp38-win_amd64.whl
| Download URL | tinyscaler-1.2.8-cp38-cp38-win_amd64.whl |
|---|---|
| Size | 84.6 kB |
| Tags | CPython 3.8 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
a6fbaf0417e6b76c063431675d4f22090c5d34667f6cc5f7c6334e144053611d
|
|
BLAKE2b-256 checksum How to use checksums |
112337dc9a8de2a4cdd8e85b38aa97f1bc8d7985b50f9b1d981336120fca1fd6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.0 CPython/3.12.4
|
Release files / tinyscaler-1.2.8-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | tinyscaler-1.2.8-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 534.4 kB |
| Tags | CPython 3.8 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
7969396adaaaf65694e2cacda394922f6c1939afff7c1202f3a32ee9a0067e30
|
|
BLAKE2b-256 checksum How to use checksums |
c2f821cde699fcc1b75abc64e0d74c4551a116e30fd0f0e25fe97ce4dd8b2c81
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.0 CPython/3.12.4
|
Release files / tinyscaler-1.2.8-cp38-cp38-macosx_11_0_universal2.whl
| Download URL | tinyscaler-1.2.8-cp38-cp38-macosx_11_0_universal2.whl |
|---|---|
| Size | 179.3 kB |
| Tags | CPython 3.8 macOS 11.0+ universal2 (ARM64, x86-64) |
|
SHA-256 checksum How to use checksums |
393aafdbbf0733cd328ee07b07ea3be442f640b232c0c3d31915ed047ea93162
|
|
BLAKE2b-256 checksum How to use checksums |
bcc3278017fafb1ca9c66c7f520bcf66b73d501b0a4555d4b7b3eade464d5168
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.0 CPython/3.12.4
|
Security for tinyscaler 1.2.8
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.