Installation¶
Basic Installation¶
Note
This is a recommended way of installation for use.
Install Pillow-Heif with pip:
python3 -m pip install --upgrade pip
python3 -m pip install --upgrade pillow-heif
Wheels are present for most popular systems with help of cibuildwheel
Building From Source¶
Linux¶
Note
- There is many different ways how to build it from source. Main requirements are:
libheif
should be version >=1.17.0
version(recommended version is1.17.3
or higher).x265
should support 10 - 12 bit encoding(if you want to save in that bitness)aom
should be >=3.3.0
versionlibde265
should be >=1.0.8
version
On Ubuntu:
sudo add-apt-repository ppa:strukturag/libheif
sudo apt update
sudo apt -y install libheif-dev
On Alpine 19:
sudo apk add --no-cache libheif-dev
Now install Pillow-Heif with:
python3 -m pip install --upgrade pillow-heif --no-binary :all:
or from within the uncompressed source directory:
python3 -m pip install .
Note
Refer to libheif repo for additional information of how to build it with what features you want.
If you have questions about build from sources you can ask them in discussions or create an issue.
FreeBSD¶
Action to test build on FreeBSD from source
Since Python itself does not support binary wheels for BSD systems, you should install libheif and then simply install Pillow-Heif from source.
Install gcc, cmake, aom and x265:
- pkg install -y gcc cmake aom x265
- pkg install -y py39-pip
- pkg install -y py39-pillow py39-numpy
- python3 libheif/linux_build_libs.py
Install Python and Pillow:
pkg install -y py39-pip
pkg install -y py39-pillow
Install Pillow-Heif:
python3 -m pip install .
macOS¶
GA Action to test build on macOS from source
First install Homebrew, if it is not installed and run:
brew install x265 libjpeg libde265 libheif
python3 -m pip install --upgrade pip
Now install Pillow-Heif with:
python3 -m pip install --upgrade pillow-heif --no-binary :all:
or from within the uncompressed source directory:
python3 -m pip install .
Windows¶
GA Action to test build on Windows from source
Note
C:/msys64/mingw64
setx MSYS2_PREFIX "D:/msys64/mingw64"
Using msys2 terminal change working directory and install libheif:
cd .../pillow_heif/libheif/windows/mingw-w64-libheif
makepkg-mingw --syncdeps
pacman -U mingw-w64-x86_64-libheif-*-any.pkg.tar.zst
Note
This is needed, so we dont want to dav1d, rav1e or libSvtAv1Enc to be installed as the dependencies.
Now inside Pillow-Heif directory install it with pip from source:
python -m pip install .