Skip to main content

cykooz_resizer

cykooz_resizer is package with the optimized version of image resizing based on Rust's crate fast_image_resize.

CHANGELOG

Installation

python3 -m pip install cykooz-resizer

Or with automatically installing Pillow:

python3 -m pip install cykooz-resizer[pillow]

Information

Supported pixel types and available optimisations:

Format Description SSE4.1 AVX2 Neon
U8 One u8 component per pixel (e.g. L) + + +
U8x2 Two u8 components per pixel (e.g. LA) + + +
U8x3 Three u8 components per pixel (e.g. RGB) + + +
U8x4 Four u8 components per pixel (e.g. RGBA, RGBx, CMYK) + + +
U16 One u16 components per pixel (e.g. L16) + + +
U16x2 Two u16 components per pixel (e.g. LA16) + + +
U16x3 Three u16 components per pixel (e.g. RGB16) + + +
U16x4 Four u16 components per pixel (e.g. RGBA16, RGBx16, CMYK16) + + +
I32 One i32 component per pixel - - -
F32 One f32 component per pixel + + -
F32x2 Two f32 components per pixel (e.g. LA32F) + + -
F32x3 Three f32 components per pixel (e.g. RGB32F) + + -
F32x4 Four f32 components per pixel (e.g. RGBA32F) + + -

Implemented resize algorithms:

  • Nearest - is nearest-neighbor interpolation, replacing every pixel with the nearest pixel in the output; for upscaling this means multiple pixels of the same color will be present.
  • Convolution with different filters:
    • box
    • bilinear
    • catmull_rom
    • mitchell
    • gaussian
    • lanczos3
  • Super sampling - is resizing an image in two steps. The first step uses the "nearest" algorithm. The second step uses "convolution" with a configurable filter.

Usage Examples

Resize Pillow's image

from PIL import Image

from cykooz_resizer import FilterType, ResizeAlg, Resizer, ResizeOptions


resizer = Resizer()
dst_size = (255, 170)
dst_image = Image.new('RGBA', dst_size)

for i in range(1, 10):
    image = Image.open('nasa_%d-4928x3279.png' % i)
    resizer.resize_pil(image, dst_image)
    dst_image.save('nasa_%d-255x170.png' % i)

# Resize using a bilinear filter and ignoring an alpha channel.
image = Image.open('nasa-4928x3279.png')
resizer.resize_pil(
    image,
    dst_image,
    ResizeOptions(
        resize_alg=ResizeAlg.convolution(FilterType.bilinear),
        use_alpha=False,
    )
)

Resize the raw image with an alpha channel

from cykooz_resizer import ImageData, PixelType, Resizer


def resize_raw(width: int, height: int, pixels: bytes):
    src_image = ImageData(
        width,
        height,
        PixelType.U8x4,
        pixels,
    )
    resizer = Resizer()
    dst_image = ImageData(255, 170, PixelType.U8x4)
    # By default, Resizer multiplies and divides by alpha channel
    # images with `U8x2`, `U8x4`, `U16x2` and `U16x4` pixels.
    resizer.resize(src_image, dst_image)
    return dst_image

Change used CPU-extensions

from cykooz_resizer import Resizer, CpuExtensions


resizer = Resizer()
resizer.cpu_extensions = CpuExtensions.sse4_1
...

Resize with using thread-pool

from cykooz_resizer import Resizer, ResizeOptions, ResizerThreadPool


...
thread_pool = ResizerThreadPool(num_threads=6)
resizer = Resizer()
resizer.resize(
    src_image,
    dst_image,
    ResizeOptions(thread_pool=thread_pool),
)
...

Benchmarks

Environment:

  • CPU: AMD Ryzen 9 5950X
  • RAM: DDR4 4000 MHz
  • Ubuntu 24.04 (linux 7.0.0)
  • Python 3.12
  • Rust 1.97.1
  • cykooz_resizer = "4.0" (single-threaded mode)

Other Python libraries used to compare of resizing speed:

Resize algorithms:

  • Nearest
  • Convolution with Bilinear filter
  • Convolution with Lanczos3 filter

Resize RGBA image 4928x3279 => 852x567

Package (time in ms) nearest bilinear lanczos3
Pillow 1.22 110.44 206.34
cykooz_resizer - none 0.21 26.52 51.28
cykooz_resizer - sse4_1 0.21 13.48 26.97
cykooz_resizer - avx2 0.21 10.79 26.72

Resize grayscale (U8) image 4928x3279 => 852x567

  • Source image nasa-4928x3279.png has converted into a grayscale image with one byte per pixel.
Package (time in ms) nearest bilinear lanczos3
Pillow 0.28 21.42 51.72
cykooz_resizer - none 0.18 5.21 12.07
cykooz_resizer - sse4_1 0.18 2.22 5.91
cykooz_resizer - avx2 0.18 1.78 4.35

Download files

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

Source Distribution

cykooz_resizer-4.0.1.tar.gz (29.8 kB view details)

Uploaded Source

Built Distributions

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

cykooz_resizer-4.0.1-cp314-cp314-win_amd64.whl (1.9 MB view details)

Uploaded CPython 3.14Windows x86-64

cykooz_resizer-4.0.1-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.9 MB view details)

Uploaded CPython 3.14manylinux: glibc 2.17+ x86-64

cykooz_resizer-4.0.1-cp314-cp314-macosx_11_0_arm64.whl (1.5 MB view details)

Uploaded CPython 3.14macOS 11.0+ ARM64

cykooz_resizer-4.0.1-cp314-cp314-macosx_10_12_x86_64.whl (1.9 MB view details)

Uploaded CPython 3.14macOS 10.12+ x86-64

cykooz_resizer-4.0.1-cp313-cp313-win_amd64.whl (1.9 MB view details)

Uploaded CPython 3.13Windows x86-64

cykooz_resizer-4.0.1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.9 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

cykooz_resizer-4.0.1-cp313-cp313-macosx_11_0_arm64.whl (1.5 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

cykooz_resizer-4.0.1-cp313-cp313-macosx_10_12_x86_64.whl (1.9 MB view details)

Uploaded CPython 3.13macOS 10.12+ x86-64

cykooz_resizer-4.0.1-cp312-cp312-win_amd64.whl (1.9 MB view details)

Uploaded CPython 3.12Windows x86-64

cykooz_resizer-4.0.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.9 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

cykooz_resizer-4.0.1-cp312-cp312-macosx_11_0_arm64.whl (1.5 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

cykooz_resizer-4.0.1-cp312-cp312-macosx_10_12_x86_64.whl (1.9 MB view details)

Uploaded CPython 3.12macOS 10.12+ x86-64

cykooz_resizer-4.0.1-cp311-cp311-win_amd64.whl (1.9 MB view details)

Uploaded CPython 3.11Windows x86-64

cykooz_resizer-4.0.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.9 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

cykooz_resizer-4.0.1-cp311-cp311-macosx_11_0_arm64.whl (1.5 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

cykooz_resizer-4.0.1-cp311-cp311-macosx_10_12_x86_64.whl (1.9 MB view details)

Uploaded CPython 3.11macOS 10.12+ x86-64

cykooz_resizer-4.0.1-cp310-cp310-win_amd64.whl (1.9 MB view details)

Uploaded CPython 3.10Windows x86-64

cykooz_resizer-4.0.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.9 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

cykooz_resizer-4.0.1-cp310-cp310-macosx_11_0_arm64.whl (1.5 MB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

cykooz_resizer-4.0.1-cp310-cp310-macosx_10_12_x86_64.whl (1.9 MB view details)

Uploaded CPython 3.10macOS 10.12+ x86-64

File details

Details for the file cykooz_resizer-4.0.1.tar.gz.

File metadata

  • Download URL: cykooz_resizer-4.0.1.tar.gz
  • Upload date:
  • Size: 29.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for cykooz_resizer-4.0.1.tar.gz
Algorithm Hash digest
SHA256 ffee2213a458b11ec5eb044afc7e169ba9913758a53d357ee8cb8a949e4e386c
MD5 055be1b7570dd4599baa52515873edeb
BLAKE2b-256 c8f2ce96d7a92da27a45fd7f62552f52421f0b98b28f0369dbf31704c2b5862b

See more details on using hashes here.

File details

Details for the file cykooz_resizer-4.0.1-cp314-cp314-win_amd64.whl.

File metadata

File hashes

Hashes for cykooz_resizer-4.0.1-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 c081e67d1d57bac9464f47aafb80b936ed8ef889d25c42784fc55fc922ce30f7
MD5 843e8eed1fe8d0b73d97fc9f04b178b9
BLAKE2b-256 0ea67a7a869313d4260f2ffafb927bb8a5b5e714b3db405aa7055eeb11191d3c

See more details on using hashes here.

File details

Details for the file cykooz_resizer-4.0.1-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for cykooz_resizer-4.0.1-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 5ca303d4c2bb4c6ae4ff07b175c2cdd02ea943a2fe45c62e23e40588c4141270
MD5 f666f91a14b13137e1caadc0be5d9ebc
BLAKE2b-256 1f9bd4812a24cf77d731cbcc5cbf6707675c25f948f23fb91465f2c0a17b9345

See more details on using hashes here.

File details

Details for the file cykooz_resizer-4.0.1-cp314-cp314-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for cykooz_resizer-4.0.1-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 abef4f4667899391461004fa160d74275abb181d4d6c80d317c6e84fbd74a9af
MD5 41bd5d27232e9ee98da439b98da53705
BLAKE2b-256 2f8c78dbc208574296c6d52097bcc38e7936983e6a265e149c77ba59c5dd950b

See more details on using hashes here.

File details

Details for the file cykooz_resizer-4.0.1-cp314-cp314-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for cykooz_resizer-4.0.1-cp314-cp314-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 99718b0e172cbdb6937d56244f560f6c60b297b0fdba95fdef0aaffef085809d
MD5 61adb073d285d68ad44869b776bd7e38
BLAKE2b-256 90d08d9ba5c8fffd1591e82da525035db4dadeb08233ecc56ee49ebfaac0be1c

See more details on using hashes here.

File details

Details for the file cykooz_resizer-4.0.1-cp313-cp313-win_amd64.whl.

File metadata

File hashes

Hashes for cykooz_resizer-4.0.1-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 df59a80b0c0f64ec8d5fc1839938a8882e229f25050ac0a398b3c3b88c93ecc6
MD5 8e8abd6cd1927b79a0d579b0a51c506c
BLAKE2b-256 cbc513d72fd59616fa626dfebce677052ccb2121948cdda1c54a5529cb55a978

See more details on using hashes here.

File details

Details for the file cykooz_resizer-4.0.1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for cykooz_resizer-4.0.1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 cb45939c40364702230cfc580f655fb8099ba27443d9d30384232b40388b3bc0
MD5 f9e6ef65a9d5ae51e78edb19f2ccc5d7
BLAKE2b-256 021b402593cf20ecbec7786a14b1ad1d0ee5839ab2af06ae75be13a9c02b1495

See more details on using hashes here.

File details

Details for the file cykooz_resizer-4.0.1-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for cykooz_resizer-4.0.1-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 cef513d4759fff1484061a23bc3de90c476efd131dcc50aa4e3b444ea9f21b08
MD5 37f4e2eaee1b34c1fc80e2fcf489e4fe
BLAKE2b-256 ff70fcef13a7d558670986f3decf9bf4284baa6a713e7891761271ee4283fd66

See more details on using hashes here.

File details

Details for the file cykooz_resizer-4.0.1-cp313-cp313-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for cykooz_resizer-4.0.1-cp313-cp313-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 55cbfcb0da88dabb7cdba7ae80491431896594521db20aa1d339a54990329451
MD5 5c2a572c55ed867fa30f90c6fd4d0e64
BLAKE2b-256 b3997ded811d7f60bc9711d5a5fd9b94571358fc6f3e24fd98ecc3aac6698de4

See more details on using hashes here.

File details

Details for the file cykooz_resizer-4.0.1-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for cykooz_resizer-4.0.1-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 8e23bd602ba0fb0d47b23fdeeeef87330222d46a6e9caeca63490dcc6aae97cb
MD5 29297d8ef5994be6def2786df11f8b34
BLAKE2b-256 01c6cab3e8eca752fade0e67c70f0aba6d4fd645f4f0652203f652bf91f75f1d

See more details on using hashes here.

File details

Details for the file cykooz_resizer-4.0.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for cykooz_resizer-4.0.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 d9f11f1ff9c467f763a49a723dadc1535b23e130fb29038f1e914b7a4422d91d
MD5 d67ff476c4e6ace76a04e23e865ba211
BLAKE2b-256 525db233be6d12a3e95f364606c860d34f1eff988ff3cc37d7b45d8dc7d54c19

See more details on using hashes here.

File details

Details for the file cykooz_resizer-4.0.1-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for cykooz_resizer-4.0.1-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 fc9248fe877fd82ef3c169f10c4c9a365c4feada3678d845d888dd15b1c1039a
MD5 4d4b24dbf780d0b207d331c631212772
BLAKE2b-256 21071f1878e11a3fe87bcbbe7e855c7f29d156caeac8863532535f69af2c0d58

See more details on using hashes here.

File details

Details for the file cykooz_resizer-4.0.1-cp312-cp312-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for cykooz_resizer-4.0.1-cp312-cp312-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 57d70b2270debf5ea724d561ce761c3476e43c3390859e9b0443e7593279bb92
MD5 6723fdb626283081d0f6cd8136b04ab7
BLAKE2b-256 72ebf10043a3eee4af2c63bc84e21b5005e7d1045496815106f88a93d2e5d5c2

See more details on using hashes here.

File details

Details for the file cykooz_resizer-4.0.1-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for cykooz_resizer-4.0.1-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 24d5be46d76740cf8ad90fd3ef93ba00ae6b98585eb77a864146b987be153ae2
MD5 64e6024578361d1624c8a2ad2fd8d2bc
BLAKE2b-256 81345a3497b647ed325ae5acdf457b4e438055bb2f17432d6512bea25330826b

See more details on using hashes here.

File details

Details for the file cykooz_resizer-4.0.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for cykooz_resizer-4.0.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 3d61ad8dc8840ef818116b08070d1d25a40355ab4b812d52829a92618b9ec8c9
MD5 f079361a85a5d14f249f78170b786e3c
BLAKE2b-256 d9ccd3305c306b11fb6fda4cfa054bc34522bb29b4bd692d54c4c1dcf153f720

See more details on using hashes here.

File details

Details for the file cykooz_resizer-4.0.1-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for cykooz_resizer-4.0.1-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 79905f12c122ba70086c200e16c0d4ad7a49be740b127718b24470ed5eb67cb7
MD5 7a0f5d264588676a40e24d44bb39dc90
BLAKE2b-256 a44c4de1d47c02d33555a759c579bf8e1d2d7a93e8bac8bb4ef2a3b1ed9665a9

See more details on using hashes here.

File details

Details for the file cykooz_resizer-4.0.1-cp311-cp311-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for cykooz_resizer-4.0.1-cp311-cp311-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 31956f382ab58a1f165ad3fa7d12e0982f73dd79be509d7a3e7db178b06e2fb0
MD5 cbf00bfb928391acd203a96961134965
BLAKE2b-256 c625e17c96affe43d3caacc1d04ca1b4c3b56a6024c2679cbf1fa114d45ec04d

See more details on using hashes here.

File details

Details for the file cykooz_resizer-4.0.1-cp310-cp310-win_amd64.whl.

File metadata

File hashes

Hashes for cykooz_resizer-4.0.1-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 d8eab27636046eb58cd12420f95aefc1ef7f7839ebdd73c731f74d4060506408
MD5 77bd96ebb59dfc1631c8c9b489da05a8
BLAKE2b-256 8600ef40f5ee5cf1db39469948ecb3a9b1167058affa21f96eaa739cb5931bde

See more details on using hashes here.

File details

Details for the file cykooz_resizer-4.0.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for cykooz_resizer-4.0.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 e08c736fef8c2a46728967ac20c31be92a3930a6f9d0e5d5473e561cb067ad8e
MD5 dd8ec4c7c21319b24f7939d853cd08b9
BLAKE2b-256 c22f66c5a75a73c9dce0daec305d5707a01403e2357ae3718184222c2e8f6e73

See more details on using hashes here.

File details

Details for the file cykooz_resizer-4.0.1-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for cykooz_resizer-4.0.1-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 14bd30c7a3cbc1de36653cc37ba530458f97a2bc4297e0fb73fc3404f39b68a1
MD5 89c943646da02ce62b710efeaa212f4f
BLAKE2b-256 3cfcb26729b4fd27dbcce5fd9863b89a7f59a8ec713fea1181bc9951848e9835

See more details on using hashes here.

File details

Details for the file cykooz_resizer-4.0.1-cp310-cp310-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for cykooz_resizer-4.0.1-cp310-cp310-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 166a6e18ed88522bddee1f76764525d2538ed4c1e9d8a3b18566f65374179d8a
MD5 d50e87936cd9834c7ecd386d9ef33070
BLAKE2b-256 10b0a2bdd24da73e2562a687a9ec0741e94a35f2449b2b749236f33261bf0a04

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

4.0.1 This release

21 files

3.1.1

21 files

3.1.0

21 files

3.0.0

21 files

2.2.1

19 files

2.2.0

19 files

2.1.2

16 files

2.1.1

13 files

2.1

14 files

2.0

14 files

1.1

16 files

1.0

15 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page