diff options
| author | CoprDistGit <infra@openeuler.org> | 2023-05-17 05:14:41 +0000 |
|---|---|---|
| committer | CoprDistGit <infra@openeuler.org> | 2023-05-17 05:14:41 +0000 |
| commit | c7d906181e64011082d10d2b9696f2d56601048d (patch) | |
| tree | c9032468d69925d9aa7d61b32614b9b444a0cae5 /python-webp.spec | |
| parent | 002bc174bfc621eb41aabd3ee08290e92de666ef (diff) | |
automatic import of python-webp
Diffstat (limited to 'python-webp.spec')
| -rw-r--r-- | python-webp.spec | 521 |
1 files changed, 521 insertions, 0 deletions
diff --git a/python-webp.spec b/python-webp.spec new file mode 100644 index 0000000..32d8baf --- /dev/null +++ b/python-webp.spec @@ -0,0 +1,521 @@ +%global _empty_manifest_terminate_build 0 +Name: python-webp +Version: 0.1.6 +Release: 1 +Summary: Python bindings for WebP +License: MIT +URL: https://github.com/anibali/pywebp +Source0: https://mirrors.nju.edu.cn/pypi/web/packages/65/6d/f7401c6284beb5f5736ec23967b6b1e3d7cd64b987e1b03225b5830af063/webp-0.1.6.tar.gz + +Requires: python3-Pillow +Requires: python3-cffi +Requires: python3-numpy + +%description +# WebP Python bindings + +[](https://actions-badge.atrox.dev/anibali/pywebp/goto) +[](https://github.com/anibali/pywebp/blob/master/LICENSE) +[](https://pypi.org/project/webp/) +[](https://github.com/anibali/pywebp) + +## Installation + +```sh +pip install webp +``` + +On Windows you may encounter the following error during installation: + +``` +conans.errors.ConanException: 'settings.compiler' value not defined +``` + +This means that you need to install a C compiler and configure Conan so that it knows which +compiler to use. See https://github.com/anibali/pywebp/issues/20 for more details. + +### Requirements + +* Python 3.8+ + +## Usage + +```python +import webp +``` + +### Simple API + +```python +# Save an image +webp.save_image(img, 'image.webp', quality=80) + +# Load an image +img = webp.load_image('image.webp', 'RGBA') + +# Save an animation +webp.save_images(imgs, 'anim.webp', fps=10, lossless=True) + +# Load an animation +imgs = webp.load_images('anim.webp', 'RGB', fps=10) +``` + +If you prefer working with numpy arrays, use the functions `imwrite`, `imread`, `mimwrite`, +and `mimread` instead. + +### Advanced API + +```python +# Encode a PIL image to WebP in memory, with encoder hints +pic = webp.WebPPicture.from_pil(img) +config = WebPConfig.new(preset=webp.WebPPreset.PHOTO, quality=70) +buf = pic.encode(config).buffer() + +# Read a WebP file and decode to a BGR numpy array +with open('image.webp', 'rb') as f: + webp_data = webp.WebPData.from_buffer(f.read()) + arr = webp_data.decode(color_mode=WebPColorMode.BGR) + +# Save an animation +enc = webp.WebPAnimEncoder.new(width, height) +timestamp_ms = 0 +for img in imgs: + pic = webp.WebPPicture.from_pil(img) + enc.encode_frame(pic, timestamp_ms) + timestamp_ms += 250 +anim_data = enc.assemble(timestamp_ms) +with open('anim.webp', 'wb') as f: + f.write(anim_data.buffer()) + +# Load an animation +with open('anim.webp', 'rb') as f: + webp_data = webp.WebPData.from_buffer(f.read()) + dec = webp.WebPAnimDecoder.new(webp_data) + for arr, timestamp_ms in dec.frames(): + # `arr` contains decoded pixels for the frame + # `timestamp_ms` contains the _end_ time of the frame + pass +``` + +## Features + +* Picture encoding/decoding +* Animation encoding/decoding +* Automatic memory management +* Simple API for working with `PIL.Image` objects + +### Not implemented + +* Encoding/decoding still images in YUV color mode +* Advanced muxing/demuxing (color profiles, etc.) +* Expose all useful fields + +## Developer notes + +### Setting up + +1. Install `mamba` and `conda-lock`. The easiest way to do this is by installing + [Mambaforge](https://github.com/conda-forge/miniforge#mambaforge) and then + running `mamba install conda-lock`. +2. Create and activate the Conda environment: + ```console + $ conda-lock install -n webp + $ mamba activate webp + ``` +3. Install PyPI dependencies: + ```console + $ poetry install + ``` + +### Running tests + +```console +$ pytest tests/ +``` + +### Cutting a new release + +1. Ensure that tests are passing and everything is ready for release. +2. Create and push a Git tag: + ```console + $ git tag v0.1.6 + $ git push --tags + ``` +3. Download the artifacts from GitHub Actions, which will include the source distribution tarball and binary wheels. +4. Create a new release on GitHub from the tagged commit and upload the packages as attachments to the release. +5. Also upload the packages to PyPI using Twine: + ```console + $ twine upload webp-*.tar.gz webp-*.whl + ``` +6. Bump the version number in `pyproject.toml` and create a commit, signalling the start of development on the next version. + +These files should also be added to a GitHub release. + +## Known issues + +* An animation where all frames are identical will "collapse" in on itself, + resulting in a single frame. Unfortunately, WebP seems to discard timestamp + information in this case, which breaks `webp.load_images` when the FPS + is specified. +* There are currently no 32-bit binaries of libwebp uploaded to Conan Center. If you are running + 32-bit Python, libwebp will be built from source. + + + +%package -n python3-webp +Summary: Python bindings for WebP +Provides: python-webp +BuildRequires: python3-devel +BuildRequires: python3-setuptools +BuildRequires: python3-pip +BuildRequires: python3-cffi +BuildRequires: gcc +BuildRequires: gdb +%description -n python3-webp +# WebP Python bindings + +[](https://actions-badge.atrox.dev/anibali/pywebp/goto) +[](https://github.com/anibali/pywebp/blob/master/LICENSE) +[](https://pypi.org/project/webp/) +[](https://github.com/anibali/pywebp) + +## Installation + +```sh +pip install webp +``` + +On Windows you may encounter the following error during installation: + +``` +conans.errors.ConanException: 'settings.compiler' value not defined +``` + +This means that you need to install a C compiler and configure Conan so that it knows which +compiler to use. See https://github.com/anibali/pywebp/issues/20 for more details. + +### Requirements + +* Python 3.8+ + +## Usage + +```python +import webp +``` + +### Simple API + +```python +# Save an image +webp.save_image(img, 'image.webp', quality=80) + +# Load an image +img = webp.load_image('image.webp', 'RGBA') + +# Save an animation +webp.save_images(imgs, 'anim.webp', fps=10, lossless=True) + +# Load an animation +imgs = webp.load_images('anim.webp', 'RGB', fps=10) +``` + +If you prefer working with numpy arrays, use the functions `imwrite`, `imread`, `mimwrite`, +and `mimread` instead. + +### Advanced API + +```python +# Encode a PIL image to WebP in memory, with encoder hints +pic = webp.WebPPicture.from_pil(img) +config = WebPConfig.new(preset=webp.WebPPreset.PHOTO, quality=70) +buf = pic.encode(config).buffer() + +# Read a WebP file and decode to a BGR numpy array +with open('image.webp', 'rb') as f: + webp_data = webp.WebPData.from_buffer(f.read()) + arr = webp_data.decode(color_mode=WebPColorMode.BGR) + +# Save an animation +enc = webp.WebPAnimEncoder.new(width, height) +timestamp_ms = 0 +for img in imgs: + pic = webp.WebPPicture.from_pil(img) + enc.encode_frame(pic, timestamp_ms) + timestamp_ms += 250 +anim_data = enc.assemble(timestamp_ms) +with open('anim.webp', 'wb') as f: + f.write(anim_data.buffer()) + +# Load an animation +with open('anim.webp', 'rb') as f: + webp_data = webp.WebPData.from_buffer(f.read()) + dec = webp.WebPAnimDecoder.new(webp_data) + for arr, timestamp_ms in dec.frames(): + # `arr` contains decoded pixels for the frame + # `timestamp_ms` contains the _end_ time of the frame + pass +``` + +## Features + +* Picture encoding/decoding +* Animation encoding/decoding +* Automatic memory management +* Simple API for working with `PIL.Image` objects + +### Not implemented + +* Encoding/decoding still images in YUV color mode +* Advanced muxing/demuxing (color profiles, etc.) +* Expose all useful fields + +## Developer notes + +### Setting up + +1. Install `mamba` and `conda-lock`. The easiest way to do this is by installing + [Mambaforge](https://github.com/conda-forge/miniforge#mambaforge) and then + running `mamba install conda-lock`. +2. Create and activate the Conda environment: + ```console + $ conda-lock install -n webp + $ mamba activate webp + ``` +3. Install PyPI dependencies: + ```console + $ poetry install + ``` + +### Running tests + +```console +$ pytest tests/ +``` + +### Cutting a new release + +1. Ensure that tests are passing and everything is ready for release. +2. Create and push a Git tag: + ```console + $ git tag v0.1.6 + $ git push --tags + ``` +3. Download the artifacts from GitHub Actions, which will include the source distribution tarball and binary wheels. +4. Create a new release on GitHub from the tagged commit and upload the packages as attachments to the release. +5. Also upload the packages to PyPI using Twine: + ```console + $ twine upload webp-*.tar.gz webp-*.whl + ``` +6. Bump the version number in `pyproject.toml` and create a commit, signalling the start of development on the next version. + +These files should also be added to a GitHub release. + +## Known issues + +* An animation where all frames are identical will "collapse" in on itself, + resulting in a single frame. Unfortunately, WebP seems to discard timestamp + information in this case, which breaks `webp.load_images` when the FPS + is specified. +* There are currently no 32-bit binaries of libwebp uploaded to Conan Center. If you are running + 32-bit Python, libwebp will be built from source. + + + +%package help +Summary: Development documents and examples for webp +Provides: python3-webp-doc +%description help +# WebP Python bindings + +[](https://actions-badge.atrox.dev/anibali/pywebp/goto) +[](https://github.com/anibali/pywebp/blob/master/LICENSE) +[](https://pypi.org/project/webp/) +[](https://github.com/anibali/pywebp) + +## Installation + +```sh +pip install webp +``` + +On Windows you may encounter the following error during installation: + +``` +conans.errors.ConanException: 'settings.compiler' value not defined +``` + +This means that you need to install a C compiler and configure Conan so that it knows which +compiler to use. See https://github.com/anibali/pywebp/issues/20 for more details. + +### Requirements + +* Python 3.8+ + +## Usage + +```python +import webp +``` + +### Simple API + +```python +# Save an image +webp.save_image(img, 'image.webp', quality=80) + +# Load an image +img = webp.load_image('image.webp', 'RGBA') + +# Save an animation +webp.save_images(imgs, 'anim.webp', fps=10, lossless=True) + +# Load an animation +imgs = webp.load_images('anim.webp', 'RGB', fps=10) +``` + +If you prefer working with numpy arrays, use the functions `imwrite`, `imread`, `mimwrite`, +and `mimread` instead. + +### Advanced API + +```python +# Encode a PIL image to WebP in memory, with encoder hints +pic = webp.WebPPicture.from_pil(img) +config = WebPConfig.new(preset=webp.WebPPreset.PHOTO, quality=70) +buf = pic.encode(config).buffer() + +# Read a WebP file and decode to a BGR numpy array +with open('image.webp', 'rb') as f: + webp_data = webp.WebPData.from_buffer(f.read()) + arr = webp_data.decode(color_mode=WebPColorMode.BGR) + +# Save an animation +enc = webp.WebPAnimEncoder.new(width, height) +timestamp_ms = 0 +for img in imgs: + pic = webp.WebPPicture.from_pil(img) + enc.encode_frame(pic, timestamp_ms) + timestamp_ms += 250 +anim_data = enc.assemble(timestamp_ms) +with open('anim.webp', 'wb') as f: + f.write(anim_data.buffer()) + +# Load an animation +with open('anim.webp', 'rb') as f: + webp_data = webp.WebPData.from_buffer(f.read()) + dec = webp.WebPAnimDecoder.new(webp_data) + for arr, timestamp_ms in dec.frames(): + # `arr` contains decoded pixels for the frame + # `timestamp_ms` contains the _end_ time of the frame + pass +``` + +## Features + +* Picture encoding/decoding +* Animation encoding/decoding +* Automatic memory management +* Simple API for working with `PIL.Image` objects + +### Not implemented + +* Encoding/decoding still images in YUV color mode +* Advanced muxing/demuxing (color profiles, etc.) +* Expose all useful fields + +## Developer notes + +### Setting up + +1. Install `mamba` and `conda-lock`. The easiest way to do this is by installing + [Mambaforge](https://github.com/conda-forge/miniforge#mambaforge) and then + running `mamba install conda-lock`. +2. Create and activate the Conda environment: + ```console + $ conda-lock install -n webp + $ mamba activate webp + ``` +3. Install PyPI dependencies: + ```console + $ poetry install + ``` + +### Running tests + +```console +$ pytest tests/ +``` + +### Cutting a new release + +1. Ensure that tests are passing and everything is ready for release. +2. Create and push a Git tag: + ```console + $ git tag v0.1.6 + $ git push --tags + ``` +3. Download the artifacts from GitHub Actions, which will include the source distribution tarball and binary wheels. +4. Create a new release on GitHub from the tagged commit and upload the packages as attachments to the release. +5. Also upload the packages to PyPI using Twine: + ```console + $ twine upload webp-*.tar.gz webp-*.whl + ``` +6. Bump the version number in `pyproject.toml` and create a commit, signalling the start of development on the next version. + +These files should also be added to a GitHub release. + +## Known issues + +* An animation where all frames are identical will "collapse" in on itself, + resulting in a single frame. Unfortunately, WebP seems to discard timestamp + information in this case, which breaks `webp.load_images` when the FPS + is specified. +* There are currently no 32-bit binaries of libwebp uploaded to Conan Center. If you are running + 32-bit Python, libwebp will be built from source. + + + +%prep +%autosetup -n webp-0.1.6 + +%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-webp -f filelist.lst +%dir %{python3_sitearch}/* + +%files help -f doclist.lst +%{_docdir}/* + +%changelog +* Wed May 17 2023 Python_Bot <Python_Bot@openeuler.org> - 0.1.6-1 +- Package Spec generated |
