6 , bzip2Support ? true, bzip2
7 , zlibSupport ? true, zlib
8 , libX11Support ? !stdenv.hostPlatform.isMinGW, libX11
9 , libXtSupport ? !stdenv.hostPlatform.isMinGW, libXt
10 , fontconfigSupport ? true, fontconfig
11 , freetypeSupport ? true, freetype
12 , ghostscriptSupport ? false, ghostscript
13 , libjpegSupport ? true, libjpeg
14 , djvulibreSupport ? true, djvulibre
15 , lcms2Support ? true, lcms2
16 , openexrSupport ? !stdenv.hostPlatform.isMinGW, openexr
17 , libjxlSupport ? true, libjxl
18 , libpngSupport ? true, libpng
19 , liblqr1Support ? true, liblqr1
20 , librawSupport ? true, libraw
21 , librsvgSupport ? !stdenv.hostPlatform.isMinGW, librsvg, pango
22 , libtiffSupport ? true, libtiff
23 , libxml2Support ? true, libxml2
24 , openjpegSupport ? !stdenv.hostPlatform.isMinGW, openjpeg
25 , libwebpSupport ? !stdenv.hostPlatform.isMinGW, libwebp
26 , libheifSupport ? true, libheif
38 assert libXtSupport -> libX11Support;
42 if stdenv.hostPlatform.system == "i686-linux" then "i686"
43 else if stdenv.hostPlatform.system == "x86_64-linux" || stdenv.hostPlatform.system == "x86_64-darwin" then "x86-64"
44 else if stdenv.hostPlatform.system == "armv7l-linux" then "armv7l"
45 else if stdenv.hostPlatform.system == "aarch64-linux" || stdenv.hostPlatform.system == "aarch64-darwin" then "aarch64"
46 else if stdenv.hostPlatform.system == "powerpc64le-linux" then "ppc64le"
50 stdenv.mkDerivation (finalAttrs: {
51 pname = "imagemagick";
54 src = fetchFromGitHub {
55 owner = "ImageMagick";
57 rev = finalAttrs.version;
58 hash = "sha256-3NUl0q/j3dBdNBtLH+69vh0elobBnTOvqQpC/2KwGBU=";
61 outputs = [ "out" "dev" "doc" ]; # bin/ isn't really big
62 outputMan = "out"; # it's tiny
64 enableParallelBuilding = true;
67 # specify delegates explicitly otherwise `convert` will invoke the build
68 # coreutils for filetypes it doesn't natively support.
69 "MVDelegate=${lib.getExe' coreutils "mv"}"
70 "RMDelegate=${lib.getExe' coreutils "rm"}"
72 (lib.withFeatureAs (arch != null) "gcc-arch" arch)
73 (lib.withFeature librsvgSupport "rsvg")
74 (lib.withFeature librsvgSupport "pango")
75 (lib.withFeature liblqr1Support "lqr")
76 (lib.withFeature libjxlSupport "jxl")
77 (lib.withFeatureAs ghostscriptSupport "gs-font-dir" "${ghostscript.fonts}/share/fonts")
78 (lib.withFeature ghostscriptSupport "gslib")
79 ] ++ lib.optionals stdenv.hostPlatform.isMinGW [
80 # due to libxml2 being without DLLs ATM
81 "--enable-static" "--disable-shared"
84 nativeBuildInputs = [ pkg-config libtool ];
86 buildInputs = [ potrace ]
87 ++ lib.optional zlibSupport zlib
88 ++ lib.optional fontconfigSupport fontconfig
89 ++ lib.optional ghostscriptSupport ghostscript
90 ++ lib.optional liblqr1Support liblqr1
91 ++ lib.optional libpngSupport libpng
92 ++ lib.optional librawSupport libraw
93 ++ lib.optional libtiffSupport libtiff
94 ++ lib.optional libxml2Support libxml2
95 ++ lib.optional libheifSupport libheif
96 ++ lib.optional djvulibreSupport djvulibre
97 ++ lib.optional libjxlSupport libjxl
98 ++ lib.optional openexrSupport openexr
99 ++ lib.optionals librsvgSupport [
103 ++ lib.optional openjpegSupport openjpeg
104 ++ lib.optionals stdenv.hostPlatform.isDarwin [
109 propagatedBuildInputs = [ curl ]
110 ++ lib.optional bzip2Support bzip2
111 ++ lib.optional freetypeSupport freetype
112 ++ lib.optional libjpegSupport libjpeg
113 ++ lib.optional lcms2Support lcms2
114 ++ lib.optional libX11Support libX11
115 ++ lib.optional libXtSupport libXt
116 ++ lib.optional libwebpSupport libwebp;
119 (cd "$dev/include" && ln -s ImageMagick* ImageMagick)
120 moveToOutput "bin/*-config" "$dev"
121 moveToOutput "lib/ImageMagick-*/config-Q16HDRI" "$dev" # includes configure params
122 for file in "$dev"/bin/*-config; do
123 substituteInPlace "$file" --replace pkg-config \
124 "PKG_CONFIG_PATH='$dev/lib/pkgconfig' '$(command -v $PKG_CONFIG)'"
126 '' + lib.optionalString ghostscriptSupport ''
127 for la in $out/lib/*.la; do
128 sed 's|-lgs|-L${lib.getLib ghostscript}/lib -lgs|' -i $la
133 version = testers.testVersion { package = finalAttrs.finalPackage; };
135 inherit (perlPackages) ImageMagick;
136 inherit (python3.pkgs) img2pdf willow;
137 pkg-config = testers.hasPkgConfigModules {
138 package = finalAttrs.finalPackage;
139 version = lib.head (lib.splitString "-" finalAttrs.version);
144 homepage = "http://www.imagemagick.org/";
145 changelog = "https://github.com/ImageMagick/Website/blob/main/ChangeLog.md";
146 description = "Software suite to create, edit, compose, or convert bitmap images";
147 pkgConfigModules = [ "ImageMagick" "MagickWand" ];
148 platforms = platforms.linux ++ platforms.darwin;
149 maintainers = with maintainers; [ erictapen dotlambda rhendric ];
150 license = licenses.asl20;
151 mainProgram = "magick";