Skip to content

Add new port: imagemagick image manipulation library#51731

Draft
Greisby wants to merge 1 commit into
microsoft:masterfrom
Greisby:new-imagemagick
Draft

Add new port: imagemagick image manipulation library#51731
Greisby wants to merge 1 commit into
microsoft:masterfrom
Greisby:new-imagemagick

Conversation

@Greisby
Copy link
Copy Markdown
Contributor

@Greisby Greisby commented May 13, 2026

ImageMagick is a widely-used, battle-tested C/C++ library and tool suite for creating, editing, composing, and converting digital images.
It supports hundreds of image formats (JPEG, PNG, TIFF, WebP, HEIC, AVIF, OpenEXR, JPEG XL, …), color management, drawing, compositing, and transforms.

It may be used directly by FFmpeg (via the image2 demuxer/muxer and the overlay filter fallback), Ghostscript interop, and countless image-processing pipelines.


Draft notice: this PR depends on PR #51725 - it will stay in Draft until that PR is merged.


Why this new vcpkg port?

There is currently no official imagemagick port in vcpkg.
This PR adds one from scratch, with full autotools support on Linux/macOS/Windows and specific fixes to make the MSVC/cl.exe toolchain work correctly under MSYS2.

Key additions vs. a naive autotools port:

  • CMake IMPORTED targets (ImageMagick::Magick++, ImageMagick::MagickWand, ImageMagick::MagickCore) with compile-definitions automatically propagated to consumers
  • #warning#pragma message fix for MSVC (cl.exe does not accept #warning)
  • Quantum depth (q8 / q16 / q32) and HDRI as first-class vcpkg features
  • Proper delegate library wiring: every optional format dependency is either an unconditional vcpkg dependency or explicitly disabled - no silent system-library probing
  • A cl_wrapper.sh / lib_wrapper.sh pair that translates GCC-style libtool invocations to MSVC-compatible flags so the standard autotools+libtool flow works with cl.exe

Port contents

Features

The port exposes a rich set of vcpkg features, all wired to explicit --with-* / --without-* configure flags so no uncontrolled system-library discovery can occur.
I think that I didn't forgot any of the dependencies already available in vcpkg.

Quantum depth (mutually exclusive, exactly one must be selected):

Feature Configure flag Default
q8 --with-quantum-depth=8 -
q16 --with-quantum-depth=16 Yes
q32 --with-quantum-depth=32 -

Quantum depth is ABI-breaking: q8, q16, and q32 builds produce incompatible library variants (suffix Q8, Q16HDRI, Q32HDRI, …).
Consumers must be compiled with the same depth.

Pixel processing:

Feature Description Default
hdri High Dynamic Range Imaging (floating-point pixels) Yes
zero-configuration Embed XML config in binary; no runtime XML files -
openmp OpenMP parallel processing (MSVC, GCC; not clang) -

Delegate / format libraries:

Feature Description Default
bzip2 BZip2 compression Yes
lzma LZMA compression Yes
zstd Zstandard compression Yes
jpeg JPEG format (libjpeg-turbo) Yes
png PNG format (libpng) Yes
tiff TIFF format Yes
webp WebP format Yes
lcms Little CMS color management Yes
xml2 XML/SVG support Yes
freetype FreeType font rendering -
fontconfig Font discovery -
openexr OpenEXR HDR format -
openjp2 JPEG 2000 format (openjpeg) -
heif HEIF/HEIC/AVIF format -
jxl JPEG XL format -
raw RAW photo format (libraw) -
jbig JBIG lossless compression -
fftw Discrete Fourier Transform (fftw3) -
pango Complex text layout via Pango -
raqm Complex text layout via libraqm -
rsvg SVG rendering via librsvg -
gvc Graphviz support -
zip Zip archive support -
x11 X Window System (Linux/macOS only) -
uhdr Ultra HDR (libultrahdr, not yet in vcpkg) -

Meta-features (convenience bundles):

Feature Pulls in
modern-formats heif, jxl, webp
professional-formats openexr, openjp2, raw

Patches

Patch Purpose
0001-fix-zstd-pkgconfig-prefix.patch Fix zstd pkg-config prefix so autoconf finds it correctly
0002-fix-fallthrough-msvc-c-mode.patch Force C++ compilation for EMF coder (uses [[fallthrough]])
0003-fix-cppflags-crt-conflict.patch Prevent CRT flags from leaking into CPPFLAGS on MSVC
0004-fix-uhdr-cpp-compat.patch C++ compatibility fix for Ultra HDR delegate
0005-fix-warning-directive-msvc.patch Replace #warning with #pragma message (cl.exe requirement)
0006-fix-winpathscript-init-order.patch Fix Windows path-script initialization order in autotools

CMake integration

The port installs a hand-crafted imagemagick-config.cmake that exposes:

find_package(imagemagick CONFIG REQUIRED)
target_link_libraries(my_app PRIVATE ImageMagick::Magick++)
# Automatically propagates:
#   MAGICKCORE_QUANTUM_DEPTH=16  (or 8/32 from selected feature)
#   MAGICKCORE_HDRI_ENABLE=1     (when hdri feature is on)

Available targets: ImageMagick::MagickCore, ImageMagick::MagickWand, ImageMagick::Magick++.

Platform support

Platform Status Notes
Windows x64 MSVC v143 ✅ tested cl_wrapper.sh + lib_wrapper.sh bridge libtool ↔ cl.exe/lib.exe
Windows x64 clang-cl ✅ tested cl_wrapper.sh + lib_wrapper.sh bridge libtool ↔ cl.exe/lib.exe
Linux x64 gcc. ✅ tested Standard autotools flow
Linux x64 clang. ✅ tested Standard autotools flow
macOS arm64 ✅ tested Standard autotools flow

I rely on the CIs of vcpkg to test the others…


  • Changes comply with the maintainer guide.
  • The packaged project shows strong association with the chosen port name. Check this box if at least one of the following criteria is met:
    • The project is in Repology: https://repology.org/project//versions
    • The project is amongst the first web search results for "" or " C++". Include a screenshot of the search engine results in the PR.
    • The port name follows the 'GitHubOrg-GitHubRepo' form or equivalent Owner-Project form.
  • Optional dependencies of the build are all controlled by the port. A dependency is controlled if it is declared an unconditional dependency in vcpkg.json, or explicitly disabled through patches or build system arguments such as CMAKE_DISABLE_FIND_PACKAGE_Xxx or VCPKG_LOCK_FIND_PACKAGE
  • The versioning scheme in vcpkg.json matches what upstream says.
  • The license declaration in vcpkg.json matches what upstream says.
  • The installed as the "copyright" file matches what upstream says.
  • The source code of the component installed comes from an authoritative source.
  • The generated "usage text" is brief and accurate. See adding-usage for context. Don't add a usage file if the automatically generated usage is correct.
  • The version database is fixed by rerunning ./vcpkg x-add-version --all and committing the result.
  • Exactly one version is added in each modified versions file.

@talregev
Copy link
Copy Markdown
Contributor

talregev commented May 13, 2026

We have GraphicsMagick port.
These ports can coexist? Are they both have the same libraries files names?

Note for maintainers to check that.

@dg0yt
Copy link
Copy Markdown
Contributor

dg0yt commented May 13, 2026

Are these PRs assisted by AI? Too many at once may discourage good reviews.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants