FreeImageRe - FreeImage Re(surrected) Fork
FreeImageRe is a maintained fork of the FreeImage project. It updates the original FreeImage 3.18 library for modern compilers and dependency versions while preserving binary compatibility with the FreeImage 3.18 dynamic library. This fork also includes vulnerability fixes and small API extensions.
About
FreeImageRe is a C/C++ image codec library, bitmap library, image loading library, image conversion library and FreeImage-compatible replacement. It hides a wide range of image-codec backends and platform-specific dependencies behind one stable, universal C API. Applications use the same API for loading, saving and converting images while FreeImageRe handles the underlying codec libraries and their versions.
Licensing
FreeImageRe uses the original FreeImage dual license: the FreeImage Public License (FIPL) or GNU GPL v2. Third-party dependencies have their own licenses.
Supported platforms
The following configurations are built by the GitHub Actions workflow:
| Platform | Architecture | Toolchain | CI status | Configure preset or method |
|---|
| Windows | x64 | MSVC | Tested in CI | msvc-release or msvc-debug |
| Windows | ARM64 | MSVC | Tested in CI | CMake with -A ARM64 |
| Ubuntu | x64 | GCC/G++ | Tested in CI | linux-release |
| Android | arm64-v8a | Android NDK | Tested in CI | android-release-unix |
| macOS | Native architecture | CMake and a C++20 compiler | N/A | linux-release or equivalent Unix generator |
The presets are defined in CMakePresets.json. The Android preset requires ANDROID_NDK_HOME and targets Android platform 28.
Windows
cmake --preset msvc-release
cmake --build build-vs18-release --config Release
To build the Python wheel with a selected CMake preset:
$env:FREEIMAGE_CMAKE_PRESET = "msvc-release"
python -m build --wheel --no-isolation
$env:FREEIMAGE_CMAKE_PRESET = "msvc-debug"
python -m build --wheel --no-isolation
Alternatively, use python setup.py bdist_wheel --cmake-preset=msvc-release.
Linux
cmake --preset linux-release
cmake --build build-linux-release
FREEIMAGE_CMAKE_PRESET=linux-release python -m build --wheel --no-isolation
Android
export ANDROID_NDK_HOME=/path/to/android-ndk
cmake --preset android-release-unix
cmake --build build-android-release
Supported formats
Formats supported in FreeImageRe:
| Format | FREE_IMAGE_FORMAT | Library | Extensions |
|---|
| Windows Bitmap | FIF_BMP | Built-in plugin | .bmp, .dib |
| Icon / Cursor | FIF_ICO | Built-in plugin | .ico, .cur |
| JPEG | FIF_JPEG | libjpeg-turbo or libjpeg | .jpg, .jpeg, .jpe, .jif, .jfif |
| JPEG Network Graphics | FIF_JNG | Not supported | .jng |
| C64 Koala | FIF_KOALA | Built-in plugin | .koa |
| Amiga IFF / LBM | FIF_LBM, FIF_IFF | Built-in plugin | .iff, .lbm |
| Multiple-image Network Graphics | FIF_MNG | Built-in plugin | .mng |
| Portable Bitmap | FIF_PBM | Built-in plugin | .pbm |
| Portable Bitmap, raw | FIF_PBMRAW | Built-in plugin | .pbm |
| Kodak PhotoCD | FIF_PCD | Built-in plugin | .pcd |
| PCX | FIF_PCX | Built-in plugin | .pcx |
| Portable Graymap | FIF_PGM | Built-in plugin | .pgm |
| Portable Graymap, raw | FIF_PGMRAW | Built-in plugin | .pgm |
| PNG | FIF_PNG |
Runtime dependency: libheif is linked as a shared library. Applications using HEIF or AVIF must make heif.dll available on Windows or libheif.so available on Linux.
Python bindings
To build the Python bindings, configure CMake with -DFREEIMAGE_WITH_PYTHON_BINDINGS=ON. Python development files and Numpy are required.
After installation:
- On Windows, make a link from
FreeImage.pyd to FreeImage.dll (a hard link is generated automatically when built from sources).
- On Linux, make a link from
FreeImage.so to libFreeImage.so (a symbolic link is generated automatically when built from sources).
- Make sure the link and library are available on
PYTHONPATH (Python documentation).
import numpy as np
import FreeImage as fi
image = fi.load("input.jpg", fi.JPEG_EXIFROTATE)
image, image_format = fi.loadf("input.jpg")
pixels = np.zeros((128, 128), dtype=np.float32)
fi.save(fi.FIF_EXR, pixels, "output.exr")
load() returns an image as a NumPy array. loadf() returns an image and the detected format enum. save() accepts 2D or 3D NumPy arrays.
Changes
All changes relative to FreeImage 3.18 are documented in Changelog.md.
Security
The state of the public CVEs reported against FreeImage and FreeImageRe, with links to the fixes and to the sample files, is listed in SECURITY-CVE.md. The samples can be downloaded and run with the script in TestSamples.