Add new port: imagemagick image manipulation library#51731
Conversation
|
We have GraphicsMagick port. Note for maintainers to check that. |
|
Are these PRs assisted by AI? Too many at once may discourage good reviews. |
For this one, yes, heavily. Some context on the timing: I've been maintaining a private overlay of these dependencies for over a month to get my project's full dependency chain building cleanly on both Windows and Linux. I've already submitted all the PRs, except the FFmpeg one, with change to enable the |
Good question. Library file names
ImageMagick versions its libraries ( GraphicsMagick is a fork of ImageMagick (based on ImageMagick 5.5.2), the two diverged in 2002.
Why add ImageMagick when GraphicsMagick already exists?In short: ImageMagick supports many more formats, and ships configurable runtime policies to reduce attack surface (e.g. disabling scripted/risky coders). I asked Copilot to put together a detailed argument and side-by-side comparison so the rationale and trade-offs are spelled out clearly.
Security postureImageMagick has been one of the most heavily audited C image libraries since the "ImageTragick" disclosures of 2016 (CVE-2016-3714 and follow-ups).
The result is a steady downward trend in published CVEs: from ~80 in 2016 down to fewer than 10/year over the last couple of years, despite the codebase growing and supporting more formats than ever. This sustained hardening effort is one of the main reasons ImageMagick remains the de-facto choice for server-side image processing. Personal contextI originally based my project on the existing The migration of my application code was painless - almost everything compiled unchanged once I switched the include paths and link targets, because the high-level So users currently on In short: the two ports serve overlapping but distinct audiences, and they install cleanly side-by-side. |
|
It is not enough to have different library names. vcpkg also demands different symbol names due to msbuild "autolinking". |
Thanks for context. |
I must say that I don't understand this point. |
|
Detailed explanations left to Microsoft, but: there is autolinking (everything), and there is conflicting libs being pulled in as transitive usage requirements in a top-level project. (Note that in vcpkg CI, dynamic library linkage only exists for Windows 🙈) |
|
@dg0yt Thanks for pointing this out. I ran a full symbol comparison on macOS arm64 (all libs from both packages):
This confirms a real symbol-level conflict - the two ports cannot coexist in the same link domain. I'd like to raise the question of whether the "successor project" exception could apply here. Key capabilities exclusive to ImageMagick 7:
I want to be clear: I'm not arguing that GraphicsMagick is unmaintained! I acknowledge the policy issue is real.
Happy to go with whatever the maintainers prefer. If the answer is (2), I'll just continue working with my local overlay. I just wanted to surface the discussion since ImageMagick is arguably the most complete and widely-used image processing library in the C/C++ ecosystem. |
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
image2demuxer/muxer and theoverlayfilter fallback), Ghostscript interop, and countless image-processing pipelines.Why this new vcpkg port?
There is currently no official
imagemagickport 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:
IMPORTEDtargets (ImageMagick::Magick++,ImageMagick::MagickWand,ImageMagick::MagickCore) with compile-definitions automatically propagated to consumers#warning→#pragma messagefix for MSVC (cl.exe does not accept#warning)cl_wrapper.sh/lib_wrapper.shpair that translates GCC-style libtool invocations to MSVC-compatible flags so the standard autotools+libtool flow works with cl.exePort 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):
q8--with-quantum-depth=8q16--with-quantum-depth=16q32--with-quantum-depth=32Quantum depth is ABI-breaking:
q8,q16, andq32builds produce incompatible library variants (suffixQ8,Q16HDRI,Q32HDRI, …).Consumers must be compiled with the same depth.
Pixel processing:
hdrizero-configurationopenmpDelegate / format libraries:
bzip2lzmazstdjpegpngtiffwebplcmsxml2freetypefontconfigopenexropenjp2heifjxlrawjbigfftwpangoraqmrsvggvczipx11uhdrMeta-features (convenience bundles):
modern-formatsheif,jxl,webpprofessional-formatsopenexr,openjp2,rawPatches
0001-fix-zstd-pkgconfig-prefix.patch0002-fix-fallthrough-msvc-c-mode.patch[[fallthrough]])0003-fix-cppflags-crt-conflict.patchCPPFLAGSon MSVC0004-fix-uhdr-cpp-compat.patch0005-fix-warning-directive-msvc.patch#warningwith#pragma message(cl.exe requirement)0006-fix-winpathscript-init-order.patchCMake integration
The port installs a hand-crafted
imagemagick-config.cmakethat exposes:Available targets:
ImageMagick::MagickCore,ImageMagick::MagickWand,ImageMagick::Magick++.Platform support
I rely on the CIs of vcpkg to test the others…
Owner-Projectform.vcpkg.json, or explicitly disabled through patches or build system arguments such as CMAKE_DISABLE_FIND_PACKAGE_Xxx or VCPKG_LOCK_FIND_PACKAGEvcpkg.jsonmatches what upstream says.vcpkg.jsonmatches what upstream says../vcpkg x-add-version --alland committing the result.