diff options
| author | CoprDistGit <infra@openeuler.org> | 2023-05-15 03:35:25 +0000 |
|---|---|---|
| committer | CoprDistGit <infra@openeuler.org> | 2023-05-15 03:35:25 +0000 |
| commit | 5683b9b424cc2f1fb76e6efa2b606a64b26b3865 (patch) | |
| tree | b70936e61e2a8b5b4cadc2c165881e939e146171 /python-cykooz-resizer.spec | |
| parent | 2936edfd96028e3be8cc62748e38759bffa477a3 (diff) | |
automatic import of python-cykooz-resizer
Diffstat (limited to 'python-cykooz-resizer.spec')
| -rw-r--r-- | python-cykooz-resizer.spec | 510 |
1 files changed, 510 insertions, 0 deletions
diff --git a/python-cykooz-resizer.spec b/python-cykooz-resizer.spec new file mode 100644 index 0000000..74f9f40 --- /dev/null +++ b/python-cykooz-resizer.spec @@ -0,0 +1,510 @@ +%global _empty_manifest_terminate_build 0 +Name: python-cykooz.resizer +Version: 2.1.2 +Release: 1 +Summary: A fast image resizer +License: Apache Software License +URL: https://pypi.org/project/cykooz.resizer/ +Source0: https://mirrors.nju.edu.cn/pypi/web/packages/7e/28/bb537151c4460d7d2a780cfe2f8b045bc81f8dd1d92482c6fa61812608b0/cykooz.resizer-2.1.2.tar.gz + +Requires: python3-Pillow +Requires: python3-wheel +Requires: python3-maturin +Requires: python3-pytest +Requires: python3-pytest-benchmark +Requires: python3-Pillow +Requires: python3-tabulate + +%description +# cykooz.resizer + +```cykooz.resizer``` is package with optimized version of image resizing +based on Rust's crate [fast_image_resize](https://crates.io/crates/fast_image_resize). + +[CHANGELOG](https://github.com/Cykooz/cykooz.resizer/blob/main/CHANGES.md) + +## Installation + +```shell +python3 -m pip install cykooz.resizer +``` + +Or with automatically installing Pillow: + +```shell +python3 -m pip install cykooz.resizer[pillow] +``` + +## Information + +Supported pixel types and available optimisations: + +| Format | Description | Native Rust | SSE4.1 | AVX2 | +|:------:|:--------------------------------------------------------------|:-----------:|:-------:|:----:| +| U8 | One `u8` component per pixel (e.g. L) | + | partial | + | +| U8x2 | Two `u8` components per pixel (e.g. LA) | + | + | + | +| U8x3 | Three `u8` components per pixel (e.g. RGB) | + | partial | + | +| 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 | + | - | - | + +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 + - lanczos3 +- Super sampling - resizing an image in two steps. + First step uses the "nearest" algorithm. Second step uses "convolution" + with configurable filter. + + +## Usage Examples + +### Resize Pillow's image + +```python +from PIL import Image + +from cykooz.resizer import FilterType, ResizeAlg, Resizer + + +resizer = Resizer(ResizeAlg.convolution(FilterType.lanczos3)) +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 raw image with alpha channel + +```python +from cykooz.resizer import AlphaMulDiv, FilterType, ImageData, PixelType, ResizeAlg, Resizer + +def resize_raw(width: int, height: int, pixels: bytes): + src_image = ImageData( + width, + height, + PixelType.U8x4, + pixels, + ) + alpha_mul_div = AlphaMulDiv() + resizer = Resizer(ResizeAlg.convolution(FilterType.lanczos3)) + dst_image = ImageData(255, 170, PixelType.U8x4) + alpha_mul_div.multiply_alpha_inplace(src_image) + resizer.resize(src_image, dst_image) + alpha_mul_div.divide_alpha_inplace(dst_image) + return dst_image +``` + +### Change used CPU-extensions + +```python +from cykooz.resizer import FilterType, ResizeAlg, Resizer, CpuExtensions + + +resizer = Resizer(ResizeAlg.convolution(FilterType.lanczos3)) +resizer.cpu_extensions = CpuExtensions.sse4_1 +... +``` + +## Benchmarks + +Environment: +- CPU: AMD Ryzen 9 5950X +- RAM: DDR4 3800 MHz +- Ubuntu 22.04 (linux 5.15.0) +- Python 3.9 +- Rust 1.62.0 +- cykooz.resizer = "2.1" + +Other Python libraries used to compare of resizing speed: +- Pillow = "9.2.0" (https://pypi.org/project/Pillow/) + +Resize algorithms: +- Nearest +- Convolution with Bilinear filter +- Convolution with Lanczos3 filter + +### Resize RGBA image 4928x3279 => 852x567 + +- Source image [nasa-4928x3279.png](https://github.com/Cykooz/cykooz.resizer/blob/main/tests/data/nasa-4928x3279.png) + +| Package (time in ms) | nearest | bilinear | lanczos3 | +|:------------------------|----------:|-----------:|-----------:| +| Pillow | 0.66 | 93.16 | 179.96 | +| cykooz.resizer | 0.20 | 39.19 | 76.71 | +| cykooz.resizer - sse4_1 | 0.20 | 15.60 | 25.16 | +| cykooz.resizer - avx2 | 0.20 | 11.95 | 18.54 | + + +### Resize grayscale (U8) image 4928x3279 => 852x567 + +- Source image [nasa-4928x3279.png](https://github.com/Cykooz/cykooz.resizer/blob/main/tests/data/nasa-4928x3279.png) + has converted into grayscale image with one byte per pixel. + +| Package (time in ms) | nearest | bilinear | lanczos3 | +|:---------------------|----------:|-----------:|-----------:| +| Pillow | 0.28 | 20.73 | 51.07 | +| cykooz.resizer | 0.19 | 14.31 | 23.84 | + + + +%package -n python3-cykooz.resizer +Summary: A fast image resizer +Provides: python-cykooz.resizer +BuildRequires: python3-devel +BuildRequires: python3-setuptools +BuildRequires: python3-pip +BuildRequires: python3-cffi +BuildRequires: gcc +BuildRequires: gdb +%description -n python3-cykooz.resizer +# cykooz.resizer + +```cykooz.resizer``` is package with optimized version of image resizing +based on Rust's crate [fast_image_resize](https://crates.io/crates/fast_image_resize). + +[CHANGELOG](https://github.com/Cykooz/cykooz.resizer/blob/main/CHANGES.md) + +## Installation + +```shell +python3 -m pip install cykooz.resizer +``` + +Or with automatically installing Pillow: + +```shell +python3 -m pip install cykooz.resizer[pillow] +``` + +## Information + +Supported pixel types and available optimisations: + +| Format | Description | Native Rust | SSE4.1 | AVX2 | +|:------:|:--------------------------------------------------------------|:-----------:|:-------:|:----:| +| U8 | One `u8` component per pixel (e.g. L) | + | partial | + | +| U8x2 | Two `u8` components per pixel (e.g. LA) | + | + | + | +| U8x3 | Three `u8` components per pixel (e.g. RGB) | + | partial | + | +| 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 | + | - | - | + +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 + - lanczos3 +- Super sampling - resizing an image in two steps. + First step uses the "nearest" algorithm. Second step uses "convolution" + with configurable filter. + + +## Usage Examples + +### Resize Pillow's image + +```python +from PIL import Image + +from cykooz.resizer import FilterType, ResizeAlg, Resizer + + +resizer = Resizer(ResizeAlg.convolution(FilterType.lanczos3)) +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 raw image with alpha channel + +```python +from cykooz.resizer import AlphaMulDiv, FilterType, ImageData, PixelType, ResizeAlg, Resizer + +def resize_raw(width: int, height: int, pixels: bytes): + src_image = ImageData( + width, + height, + PixelType.U8x4, + pixels, + ) + alpha_mul_div = AlphaMulDiv() + resizer = Resizer(ResizeAlg.convolution(FilterType.lanczos3)) + dst_image = ImageData(255, 170, PixelType.U8x4) + alpha_mul_div.multiply_alpha_inplace(src_image) + resizer.resize(src_image, dst_image) + alpha_mul_div.divide_alpha_inplace(dst_image) + return dst_image +``` + +### Change used CPU-extensions + +```python +from cykooz.resizer import FilterType, ResizeAlg, Resizer, CpuExtensions + + +resizer = Resizer(ResizeAlg.convolution(FilterType.lanczos3)) +resizer.cpu_extensions = CpuExtensions.sse4_1 +... +``` + +## Benchmarks + +Environment: +- CPU: AMD Ryzen 9 5950X +- RAM: DDR4 3800 MHz +- Ubuntu 22.04 (linux 5.15.0) +- Python 3.9 +- Rust 1.62.0 +- cykooz.resizer = "2.1" + +Other Python libraries used to compare of resizing speed: +- Pillow = "9.2.0" (https://pypi.org/project/Pillow/) + +Resize algorithms: +- Nearest +- Convolution with Bilinear filter +- Convolution with Lanczos3 filter + +### Resize RGBA image 4928x3279 => 852x567 + +- Source image [nasa-4928x3279.png](https://github.com/Cykooz/cykooz.resizer/blob/main/tests/data/nasa-4928x3279.png) + +| Package (time in ms) | nearest | bilinear | lanczos3 | +|:------------------------|----------:|-----------:|-----------:| +| Pillow | 0.66 | 93.16 | 179.96 | +| cykooz.resizer | 0.20 | 39.19 | 76.71 | +| cykooz.resizer - sse4_1 | 0.20 | 15.60 | 25.16 | +| cykooz.resizer - avx2 | 0.20 | 11.95 | 18.54 | + + +### Resize grayscale (U8) image 4928x3279 => 852x567 + +- Source image [nasa-4928x3279.png](https://github.com/Cykooz/cykooz.resizer/blob/main/tests/data/nasa-4928x3279.png) + has converted into grayscale image with one byte per pixel. + +| Package (time in ms) | nearest | bilinear | lanczos3 | +|:---------------------|----------:|-----------:|-----------:| +| Pillow | 0.28 | 20.73 | 51.07 | +| cykooz.resizer | 0.19 | 14.31 | 23.84 | + + + +%package help +Summary: Development documents and examples for cykooz.resizer +Provides: python3-cykooz.resizer-doc +%description help +# cykooz.resizer + +```cykooz.resizer``` is package with optimized version of image resizing +based on Rust's crate [fast_image_resize](https://crates.io/crates/fast_image_resize). + +[CHANGELOG](https://github.com/Cykooz/cykooz.resizer/blob/main/CHANGES.md) + +## Installation + +```shell +python3 -m pip install cykooz.resizer +``` + +Or with automatically installing Pillow: + +```shell +python3 -m pip install cykooz.resizer[pillow] +``` + +## Information + +Supported pixel types and available optimisations: + +| Format | Description | Native Rust | SSE4.1 | AVX2 | +|:------:|:--------------------------------------------------------------|:-----------:|:-------:|:----:| +| U8 | One `u8` component per pixel (e.g. L) | + | partial | + | +| U8x2 | Two `u8` components per pixel (e.g. LA) | + | + | + | +| U8x3 | Three `u8` components per pixel (e.g. RGB) | + | partial | + | +| 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 | + | - | - | + +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 + - lanczos3 +- Super sampling - resizing an image in two steps. + First step uses the "nearest" algorithm. Second step uses "convolution" + with configurable filter. + + +## Usage Examples + +### Resize Pillow's image + +```python +from PIL import Image + +from cykooz.resizer import FilterType, ResizeAlg, Resizer + + +resizer = Resizer(ResizeAlg.convolution(FilterType.lanczos3)) +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 raw image with alpha channel + +```python +from cykooz.resizer import AlphaMulDiv, FilterType, ImageData, PixelType, ResizeAlg, Resizer + +def resize_raw(width: int, height: int, pixels: bytes): + src_image = ImageData( + width, + height, + PixelType.U8x4, + pixels, + ) + alpha_mul_div = AlphaMulDiv() + resizer = Resizer(ResizeAlg.convolution(FilterType.lanczos3)) + dst_image = ImageData(255, 170, PixelType.U8x4) + alpha_mul_div.multiply_alpha_inplace(src_image) + resizer.resize(src_image, dst_image) + alpha_mul_div.divide_alpha_inplace(dst_image) + return dst_image +``` + +### Change used CPU-extensions + +```python +from cykooz.resizer import FilterType, ResizeAlg, Resizer, CpuExtensions + + +resizer = Resizer(ResizeAlg.convolution(FilterType.lanczos3)) +resizer.cpu_extensions = CpuExtensions.sse4_1 +... +``` + +## Benchmarks + +Environment: +- CPU: AMD Ryzen 9 5950X +- RAM: DDR4 3800 MHz +- Ubuntu 22.04 (linux 5.15.0) +- Python 3.9 +- Rust 1.62.0 +- cykooz.resizer = "2.1" + +Other Python libraries used to compare of resizing speed: +- Pillow = "9.2.0" (https://pypi.org/project/Pillow/) + +Resize algorithms: +- Nearest +- Convolution with Bilinear filter +- Convolution with Lanczos3 filter + +### Resize RGBA image 4928x3279 => 852x567 + +- Source image [nasa-4928x3279.png](https://github.com/Cykooz/cykooz.resizer/blob/main/tests/data/nasa-4928x3279.png) + +| Package (time in ms) | nearest | bilinear | lanczos3 | +|:------------------------|----------:|-----------:|-----------:| +| Pillow | 0.66 | 93.16 | 179.96 | +| cykooz.resizer | 0.20 | 39.19 | 76.71 | +| cykooz.resizer - sse4_1 | 0.20 | 15.60 | 25.16 | +| cykooz.resizer - avx2 | 0.20 | 11.95 | 18.54 | + + +### Resize grayscale (U8) image 4928x3279 => 852x567 + +- Source image [nasa-4928x3279.png](https://github.com/Cykooz/cykooz.resizer/blob/main/tests/data/nasa-4928x3279.png) + has converted into grayscale image with one byte per pixel. + +| Package (time in ms) | nearest | bilinear | lanczos3 | +|:---------------------|----------:|-----------:|-----------:| +| Pillow | 0.28 | 20.73 | 51.07 | +| cykooz.resizer | 0.19 | 14.31 | 23.84 | + + + +%prep +%autosetup -n cykooz.resizer-2.1.2 + +%build +%py3_build + +%install +%py3_install +install -d -m755 %{buildroot}/%{_pkgdocdir} +if [ -d doc ]; then cp -arf doc %{buildroot}/%{_pkgdocdir}; fi +if [ -d docs ]; then cp -arf docs %{buildroot}/%{_pkgdocdir}; fi +if [ -d example ]; then cp -arf example %{buildroot}/%{_pkgdocdir}; fi +if [ -d examples ]; then cp -arf examples %{buildroot}/%{_pkgdocdir}; fi +pushd %{buildroot} +if [ -d usr/lib ]; then + find usr/lib -type f -printf "/%h/%f\n" >> filelist.lst +fi +if [ -d usr/lib64 ]; then + find usr/lib64 -type f -printf "/%h/%f\n" >> filelist.lst +fi +if [ -d usr/bin ]; then + find usr/bin -type f -printf "/%h/%f\n" >> filelist.lst +fi +if [ -d usr/sbin ]; then + find usr/sbin -type f -printf "/%h/%f\n" >> filelist.lst +fi +touch doclist.lst +if [ -d usr/share/man ]; then + find usr/share/man -type f -printf "/%h/%f.gz\n" >> doclist.lst +fi +popd +mv %{buildroot}/filelist.lst . +mv %{buildroot}/doclist.lst . + +%files -n python3-cykooz.resizer -f filelist.lst +%dir %{python3_sitearch}/* + +%files help -f doclist.lst +%{_docdir}/* + +%changelog +* Mon May 15 2023 Python_Bot <Python_Bot@openeuler.org> - 2.1.2-1 +- Package Spec generated |
