7 , bzip2Support ? true, bzip2
8 , zlibSupport ? true, zlib
9 , libX11Support ? !stdenv.hostPlatform.isMinGW, libX11
10 , libXtSupport ? !stdenv.hostPlatform.isMinGW, libXt
11 , fontconfigSupport ? true, fontconfig
12 , freetypeSupport ? true, freetype
13 , ghostscriptSupport ? false, ghostscript
14 , libjpegSupport ? true, libjpeg
15 , djvulibreSupport ? true, djvulibre
16 , lcms2Support ? true, lcms2
17 , openexrSupport ? !stdenv.hostPlatform.isMinGW, openexr
18 , libjxlSupport ? true, libjxl
19 , libpngSupport ? true, libpng
20 , liblqr1Support ? true, liblqr1
21 , librawSupport ? true, libraw
22 , librsvgSupport ? !stdenv.hostPlatform.isMinGW, librsvg, pango
23 , libtiffSupport ? true, libtiff
24 , libxml2Support ? true, libxml2
25 , openjpegSupport ? !stdenv.hostPlatform.isMinGW, openjpeg
26 , libwebpSupport ? !stdenv.hostPlatform.isMinGW, libwebp
27 , libheifSupport ? true, libheif
28 , fftwSupport ? true, fftw
40 assert libXtSupport -> libX11Support;
44 if stdenv.hostPlatform.system == "i686-linux" then "i686"
45 else if stdenv.hostPlatform.system == "x86_64-linux" || stdenv.hostPlatform.system == "x86_64-darwin" then "x86-64"
46 else if stdenv.hostPlatform.system == "armv7l-linux" then "armv7l"
47 else if stdenv.hostPlatform.system == "aarch64-linux" || stdenv.hostPlatform.system == "aarch64-darwin" then "aarch64"
48 else if stdenv.hostPlatform.system == "powerpc64le-linux" then "ppc64le"
52 stdenv.mkDerivation (finalAttrs: {
53 pname = "imagemagick";
56 src = fetchFromGitHub {
57 owner = "ImageMagick";
59 rev = finalAttrs.version;
60 hash = "sha256-NrTIx1OvwPIeVlA39hGkXZ2Atk4FCsU3/55SZeSc40E=";
65 url = "https://github.com/ImageMagick/ImageMagick/commit/bf5650f0dd41b500102a129d6867cb568f4edee4.patch";
66 hash = "sha256-nxvSTyNZ35DqjR41nM5uidWwRFWzd1e/LFE0n3fpbb8=";
70 outputs = [ "out" "dev" "doc" ]; # bin/ isn't really big
71 outputMan = "out"; # it's tiny
73 enableParallelBuilding = true;
76 # specify delegates explicitly otherwise `convert` will invoke the build
77 # coreutils for filetypes it doesn't natively support.
78 "MVDelegate=${lib.getExe' coreutils "mv"}"
79 "RMDelegate=${lib.getExe' coreutils "rm"}"
81 (lib.withFeatureAs (arch != null) "gcc-arch" arch)
82 (lib.withFeature librsvgSupport "rsvg")
83 (lib.withFeature librsvgSupport "pango")
84 (lib.withFeature liblqr1Support "lqr")
85 (lib.withFeature libjxlSupport "jxl")
86 (lib.withFeatureAs ghostscriptSupport "gs-font-dir" "${ghostscript.fonts}/share/fonts")
87 (lib.withFeature ghostscriptSupport "gslib")
88 (lib.withFeature fftwSupport "fftw")
89 ] ++ lib.optionals stdenv.hostPlatform.isMinGW [
90 # due to libxml2 being without DLLs ATM
91 "--enable-static" "--disable-shared"
94 nativeBuildInputs = [ pkg-config libtool ];
96 buildInputs = [ potrace ]
97 ++ lib.optional zlibSupport zlib
98 ++ lib.optional fontconfigSupport fontconfig
99 ++ lib.optional ghostscriptSupport ghostscript
100 ++ lib.optional liblqr1Support liblqr1
101 ++ lib.optional libpngSupport libpng
102 ++ lib.optional librawSupport libraw
103 ++ lib.optional libtiffSupport libtiff
104 ++ lib.optional libxml2Support libxml2
105 ++ lib.optional libheifSupport libheif
106 ++ lib.optional djvulibreSupport djvulibre
107 ++ lib.optional libjxlSupport libjxl
108 ++ lib.optional openexrSupport openexr
109 ++ lib.optionals librsvgSupport [
113 ++ lib.optional openjpegSupport openjpeg
114 ++ lib.optionals stdenv.hostPlatform.isDarwin [
119 propagatedBuildInputs = [ curl ]
120 ++ lib.optional bzip2Support bzip2
121 ++ lib.optional freetypeSupport freetype
122 ++ lib.optional libjpegSupport libjpeg
123 ++ lib.optional lcms2Support lcms2
124 ++ lib.optional libX11Support libX11
125 ++ lib.optional libXtSupport libXt
126 ++ lib.optional libwebpSupport libwebp
127 ++ lib.optional fftwSupport fftw;
130 (cd "$dev/include" && ln -s ImageMagick* ImageMagick)
131 moveToOutput "bin/*-config" "$dev"
132 moveToOutput "lib/ImageMagick-*/config-Q16HDRI" "$dev" # includes configure params
133 for file in "$dev"/bin/*-config; do
134 substituteInPlace "$file" --replace pkg-config \
135 "PKG_CONFIG_PATH='$dev/lib/pkgconfig' '$(command -v $PKG_CONFIG)'"
137 '' + lib.optionalString ghostscriptSupport ''
138 for la in $out/lib/*.la; do
139 sed 's|-lgs|-L${lib.getLib ghostscript}/lib -lgs|' -i $la
144 version = testers.testVersion { package = finalAttrs.finalPackage; };
146 inherit (perlPackages) ImageMagick;
147 inherit (python3.pkgs) img2pdf willow;
148 pkg-config = testers.hasPkgConfigModules {
149 package = finalAttrs.finalPackage;
150 version = lib.head (lib.splitString "-" finalAttrs.version);
155 homepage = "http://www.imagemagick.org/";
156 changelog = "https://github.com/ImageMagick/Website/blob/main/ChangeLog.md";
157 description = "Software suite to create, edit, compose, or convert bitmap images";
158 pkgConfigModules = [ "ImageMagick" "MagickWand" ];
159 platforms = platforms.linux ++ platforms.darwin;
160 maintainers = with maintainers; [ dotlambda rhendric bloxx12 ];
161 license = licenses.asl20;
162 mainProgram = "magick";