What is FreeImage ?
FreeImage is an Open Source library project for developers who would like to support image formats including PNG, BMP, JPEG, TIFF, WebP, JPEG 2000, JPEG XR, OpenEXR, camera RAW, and optional HEIF/HEIC, AVIF and JPEG XL as needed by today's multimedia applications.
FreeImage is easy to use, fast, multithreading safe, and cross-platform (works with Windows, Linux and Mac OS X).
This GitHub fork
Security and bug fixes on top of upstream FreeImage, plus a CMake build that compiles FreeImage and every bundled library from one CMakeLists.txt. This repository is the source tree. GitHub releases provide source archives and Linux packages; see the packaging guide. Build a static library or a DLL with the commands in Building this fork.
This tree is FreeImage 3.19.31. FreeImage_GetVersion() prints FREEIMAGE_MAJOR_VERSION, FREEIMAGE_MINOR_VERSION, and FREEIMAGE_RELEASE_SERIAL from Source/FreeImage.h. CMake takes the version from the latest numeric git tag (git describe) and falls back to 3.19.31 when the archive has no .git history.
The ANSI C API is usable from C, C++, VB, C#, Delphi, Java, and from scripting languages such as Perl, Python, PHP, TCL, Lua, and Ruby.
Why use FreeImage instead of linking each format library yourself?
Loading a PNG, a GIF and a JPEG from scratch in C++ means three different APIs (libpng, giflib-or-hand-rolled-LZW, libjpeg), three different error-handling conventions, and three sets of build flags to get right across platforms. FreeImage wraps all of the libraries below behind one API - one FreeImage_Load()/FreeImage_Save() pair, one pixel format model (FIBITMAP), one metadata API (EXIF/IPTC/XMP) - so format-specific code doesn't leak into the rest of your application. Swapping a PNG for a WebP is a one-line change rather than a new dependency. Camera RAW uses the same FreeImage_Load() call. It is included unless the build passes -DBUILD_LIBRAWLITE=OFF.
This fork additionally builds the whole stack (FreeImage plus every bundled library) from one CMakeLists.txt, so find_package(FreeImage) is the only thing a consuming CMake project needs - see Using compiled binaries below.
Supported formats & bundled libraries
Formats implemented directly in FreeImage's own plugin code (no external library): BMP, ICO, TARGA/TGA, PCX, DDS, GIF, PSD, PICT, PFM, HDR/Radiance RGBE, RAS/Sun Raster, SGI, XBM, XPM, Amiga IFF/LBM, Kodak PCD, PNM/PBM/PGM/PPM, CUT, and WBMP.
Everything else is backed by a bundled copy of the format's reference library. Turn a format off with its BUILD_* option, or link a system copy with USE_SYSTEM_* (or FREEIMAGE_USE_SYSTEM_LIBS, which turns every USE_SYSTEM_* default on). See CMakeLists.txt.
The bundled libtiff is fully synced to 4.7.2, including its integer-overflow hardening and decompression-ratio checks. OpenEXR is included when CMAKE_CXX_STANDARD is unset or 17 or newer, and left out for an older standard.
| Formats |
Library |
Bundled version |
Default |
CMake option |
| PNG |
libpng (+ zlib) |
1.6.59 (zlib 1.3.2) |
on |
BUILD_LIBPNG |
| JPEG |
libjpeg (IJG) |
10 (25 Jan 2026) |
on |
BUILD_LIBJPEG |
| TIFF |
libtiff |
4.7.2 |
on |
BUILD_LIBTIFF |
| JPEG 2000 (J2K/JP2) |
OpenJPEG |
2.5.4 |
on |
BUILD_LIBOPENJPEG |
| OpenEXR (HDR) |
OpenEXR |
3.5.3 |
on for C++17+ |
BUILD_OPENEXR |
| WebP |
libwebp |
1.6.0 |
on |
BUILD_WEBP |
| Camera RAW (including CR3 and X3F) |
LibRaw |
0.22.3 |
on |
BUILD_LIBRAWLITE |
| JPEG XR (JXR/WDP/HDP) |
jxrlib |
unversioned snapshot |
on for Windows; optional elsewhere |
BUILD_JXR |
| HEIF/HEIC/HIF and AVIF |
libheif |
1.23.7 |
off |
BUILD_LIBHEIF |
| JPEG XL (JXL) |
libjxl |
0.12.0 |
off |
BUILD_LIBJXL |
The optional formats use bundled sources when enabled through CMake. HEIF/AVIF
and JPEG XL support reading and writing still images; see their sections below
for pixel types, metadata and encoder limitations.
Supporting libraries are bundled alongside the format libraries:
| Used by |
Bundled libraries |
| PNG, TIFF and other compressed formats |
zlib 1.3.2 |
| OpenEXR |
Imath 3.2.3, libdeflate 1.26, Zstandard 1.5.7, OpenJPH 0.33.0 |
| HEIF/HEIC/HIF |
libde265 1.1.3 (HEVC decoding), Kvazaar 2.3.2 (HEVC encoding) |
| AVIF |
libaom 3.15.3 (AV1 decoding/encoding; enabled by default with bundled HEIF) |
| JPEG XL |
Highway 1.4.0, Brotli 1.2.1, Little CMS 2.20 |
See third-party versions for version sources and
optional codec bundles for archive checksums,
licenses and build requirements.
Original Source Code Upstream
https://sourceforge.net/projects/freeimage
Original library can be found : https://freeimage.sourceforge.io
The upstream patch archive lists submitted patches,
what they fix, and fork changes needing submission review. See also the
SourceForge submission index.
Status
Building this fork
JPEG-XR is enabled by default only on Windows (BUILD_JXR defaults to WIN32); pass -DBUILD_JXR=ON to include it on other platforms. Camera RAW is included by default (-DBUILD_LIBRAWLITE=OFF leaves it out).
Simply build it
cmake . -B cmake-build
cmake --build cmake-build # On Linux, add -j$(nproc) for multicore build
For JP2/JXR format detection and display-conversion troubleshooting, see the
codec diagnostic example. Detect the
file signature before falling back to its extension: a raw J2K codestream can
have a .jp2 filename. JPEG 2000 and JPEG XR can decode to native 16-bit or
floating-point image types. Check FreeImage_GetImageType() before display
conversion; HDR previews require an explicit tone-mapping policy. The example
provides a 24-bit RGB preview without changing the native decoded pixels.
Platform-specific examples
Linux (gcc) / macOS (clang)
cmake -S . -B build -DBUILD_TESTS=ON -DCMAKE_BUILD_TYPE=Debug
cmake --build build -- -j$(nproc) # macOS: -j$(sysctl -n hw.ncpu)
Windows (MSVC, Visual Studio toolchain)
Install Visual Studio with Desktop development with C++, an x86/x64 MSVC
toolset and a Windows SDK. Add CMake to PATH: the presets require CMake
3.21 or newer for VS 2022, or 4.2 or newer for VS 2026. Run the commands below
in PowerShell from the FreeImage source directory. Build Tools supports
command-line builds; opening a solution requires the Visual Studio IDE.
For an x64 Debug build and tests:
cmake --preset vs2022 -A x64 -B build-vs2022-x64
cmake --build build-vs2022-x64 --config Debug
ctest --test-dir build-vs2022-x64 -C Debug --output-on-failure
See the Visual Studio and CMake build guide for tool
installation, Win32/ARM64 builds, a combined platform dropdown, DLLs and installation.
See Generate Visual Studio project files below for opening the solution directly in the IDE.
To select the MSVC C runtime, pass -DFREEIMAGE_MSVC_RUNTIME=MD for the
dynamic CRT (/MDd in Debug and /MD in Release), or
-DFREEIMAGE_MSVC_RUNTIME=MT for the static CRT (/MTd in Debug and /MT in
Release). The default Default leaves CMake's runtime selection unchanged;
CMake's default with this project's policy is /MDd in Debug and /MD
in Release.
This setting is forwarded to bundled HEIF and JPEG XL dependencies, including
AOM and Highway. Prebuilt system libraries are not changed by this option; use
libraries built with the same CRT setting. Static FreeImage consumers should
also use the same CRT.
For example, to build and test a DLL with the static CRT:
cmake --preset vs2022 -A x64 -B build-vs2022-dll -DFREEIMAGE_STATIC=OFF -DFREEIMAGE_MSVC_RUNTIME=MT
cmake --build build-vs2022-dll --config Release
ctest --test-dir build-vs2022-dll -C Release --output-on-failure
MSVC Debug installs include available PDB symbols. Static builds install the
compiler-generated FreeImage.pdb beside the .lib in lib/ (the
Development component). DLL builds install the linker-generated PDB beside
the DLL in bin/ (the Runtime component). Toolchains or debug formats that
embed symbols in object files do not produce a separate compiler PDB; its
absence does not prevent installation. Release installs omit these PDB files.
Windows (MinGW, e.g. a toolchain already on PATH)
cmake -S . -B build -DBUILD_TESTS=ON -DCMAKE_BUILD_TYPE=Debug -G "MinGW Makefiles"
cmake --build build
Windows (MinGW-w64 via MSYS2, see #30)
From an MSYS2 MINGW64 shell:
pacman -S mingw-w64-x86_64-toolchain mingw-w64-x86_64-cmake mingw-w64-x86_64-ninja
cmake -S . -B build -G Ninja -DBUILD_TESTS=ON -DCMAKE_BUILD_TYPE=Debug
cmake --build build
Plain make (Linux, no CMake)
make -j$(nproc)
Generate Visual Studio project files
The complete Visual Studio build guide covers setup,
IDE and command-line builds, output paths, testing and installation.
Choose a preset for your Visual Studio version and how you want to build:
| Build mode |
VS 2022 preset |
VS 2026 preset |
Solution path |
| Portable solution with a platform dropdown |
vs2022-all |
vs2026-all |
build-vs<year>-all/visualstudio/FreeImage.sln |
| Single architecture in a fixed build directory |
vs2022 |
vs2026 |
<build-directory>/FreeImage.sln |
All four presets run on Windows and enable BUILD_TESTS. VS 2026 needs CMake
4.2 or newer. Use --config Debug or --config Release when building;
CMAKE_BUILD_TYPE does not select the configuration for a Visual Studio generator.
Portable solution with Win32, x64, ARM64 and ARM64EC
cmake --preset vs2026-all # For VS 2022: cmake --preset vs2022-all
Open build-vs2026-all/visualstudio/FreeImage.sln (or
build-vs2022-all/visualstudio/FreeImage.sln). Choose Win32, x64,
ARM64, ARM64EC, or All Platforms in the platform dropdown, select
Debug or Release, then choose Build > Build Solution. All Platforms builds
all four architectures. Install the matching ARM64/ARM64EC C++ toolsets before
building those platforms; ARM64EC requires VS 2022 17.3 or newer.
To build all four architectures from the command line:
cmake --build build-vs2026-all --config Release --target FreeImageAllPlatforms
The projects invoke CMake for the selected architecture, so keep CMake on
PATH when building from the IDE. Libraries and DLLs are placed under
build-vs2026-all/visualstudio/artifacts/<architecture>/<configuration>/.
The combined frontend supports Visual Studio 2022 and 2026 with bundled
dependencies and native MSVC toolchains.
Choose static libraries, DLLs and optional codecs at configure time. The same
settings apply to every architecture; for example, to generate a DLL solution
with bundled HEIF/AVIF and JPEG XL: