No project description provided
Project description
Python libimagequant Integrations
This library provides helper functions for converting between objects in the unofficial Python libimagequant bindings library and "image" objects in various popular Python libraries.
If you'd like to add support for integration with more libraries, pull requests are welcome!
Install with pip:
python3 -m pip install libimagequant_integrations
API Documentation
This package contains the following submodules, for converting to/from the indicated classes:
libimagequant_integrations.PIL
(for Pillow'sPIL.Image.Image
*)libimagequant_integrations.PySide2
(forPySide2.QtGui.QImage
)libimagequant_integrations.PySide6
(forPySide6.QtGui.QImage
)libimagequant_integrations.PyQt5
(forPyQt5.QtGui.QImage
)libimagequant_integrations.PyQt6
(forPyQt6.QtGui.QImage
)libimagequant_integrations.skimage
(for scikit-image numpy arrays†)libimagequant_integrations.png
(for PyPNGpng.Reader
andpng.Writer
‡)
I suggest you import using (for example)
import libimagequant_integrations.PyQt5 as liq_PyQt5
, to avoid typing an
excessive amount. :)
Each submodule contains two functions, used to convert to and from the
libimagequant.Image
class:
to_liq(image: OtherImageClass, attr: libimagequant.Attr) -> libimagequant.Image
from_liq(result: libimagequant.Result, image: libimagequant.Image) -> OtherImageClass
(Replace OtherImageClass
with the appropriate other image class.)
You can check libimagequant_integration
's version number using
libimagequant_integrations.VERSION
and
libimagequant_integrations.VERSION_STR
, which are in the same format as the
version number constants in the libimagequant
bindings library itself. The
version numbers follow semantic versioning. They begin with 1.0.0, and do not
track libimagequant's version numbers at all.
*
While Pillow claims to support images with RGBA palettes, this feature seems
extremely buggy, almost to the point of being completely unusable. Therefore,
the from_liq()
function discards the alpha channel and returns an image with
a RGB palette. If you do need the alpha channel information, you can obtain it
manually from the libimagequant.Image
object.
†
Give to_liq()
an RGBA image (numpy array of shape (y, x, 4)
, with
uint8-type elements) as its "image" argument. from_liq()
returns two numpy
arrays: one with pixel data (shape (y, x, 1)
, uint8-type elements), and one
with the RGBA color palette (shape (n, 4)
, uint8-type elements).
‡
Give to_liq()
a png.Reader
as its "image" argument. from_liq()
returns a
png.Writer
and a bytes
object; you can save the image using the Writer's
write_array()
method with the bytes
data provided.
License
Licensed under the GNU GPL v3. See the LICENSE
file for the full license
text.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file libimagequant_integrations-1.1.1.tar.gz
.
File metadata
- Download URL: libimagequant_integrations-1.1.1.tar.gz
- Upload date:
- Size: 4.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.50.0 CPython/3.8.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e25f99dd902b38f18616bec897289378d4dbc3a6b69dc855a28513f14d6d5dfa |
|
MD5 | 57de4d484ce4c0c8bf8ed7e66eb2abfb |
|
BLAKE2b-256 | 913c321d4cbe44c188fd23c50a9eacc6a8a17f4427f6222263a14d680323fc58 |
File details
Details for the file libimagequant_integrations-1.1.1-py3-none-any.whl
.
File metadata
- Download URL: libimagequant_integrations-1.1.1-py3-none-any.whl
- Upload date:
- Size: 19.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.50.0 CPython/3.8.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8234d667b189c5515fcdb69e26e75e45d54bca44b04c12dfd86233a9810b027c |
|
MD5 | a3cf89a0c9d4b21c8431cc4193a331d2 |
|
BLAKE2b-256 | 358be8fe869d158d229d4d0acf79ef8b8b245d53affe8a7b27d52e8738684e5a |