about summary refs log tree commit diff
path: root/pkgs/by-name/gr/graphicsmagick/package.nix
blob: fb6a9fbd29af0685aaaf22d70a19cb144caccfb8 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
{ lib
, bzip2
, callPackage
, coreutils
, fetchurl
, fixDarwinDylibNames
, freetype
, ghostscript
, graphviz
, libX11
, libjpeg
, libpng
, libtiff
, libtool
, libwebp
, libxml2
, nukeReferences
, quantumdepth ? 8
, runCommand
, stdenv
, xz
, zlib
}:

stdenv.mkDerivation (finalAttrs: {
  pname = "graphicsmagick";
  version = "1.3.43";

  src = fetchurl {
    url = "mirror://sourceforge/graphicsmagick/GraphicsMagick-${finalAttrs.version}.tar.xz";
    hash = "sha256-K4hYBzLNfkCdniLGEWI4vvSuBvzaEUUb8z0ln5y/OZ8=";
  };

  outputs = [ "out" "man" ];

  buildInputs = [
    bzip2
    freetype
    ghostscript
    graphviz
    libX11
    libjpeg
    libpng
    libtiff
    libtool
    libwebp
    libxml2
    zlib
  ];

  nativeBuildInputs = [
    nukeReferences
    xz
  ] ++ lib.optionals stdenv.hostPlatform.isDarwin [ fixDarwinDylibNames ];

  configureFlags = [
    # specify delegates explicitly otherwise `gm` will invoke the build
    # coreutils for filetypes it doesn't natively support.
    "MVDelegate=${lib.getExe' coreutils "mv"}"
    (lib.enableFeature true "shared")
    (lib.withFeature true "frozenpaths")
    (lib.withFeatureAs true "quantum-depth" (toString quantumdepth))
    (lib.withFeatureAs true "gslib" "yes")
  ];

  # Remove CFLAGS from the binaries to avoid closure bloat.
  # In the past we have had -dev packages in the closure of the binaries soley
  # due to the string references.
  postConfigure = ''
    nuke-refs -e $out ./magick/magick_config.h
  '';

  postInstall = ''
    sed -i 's/-ltiff.*'\'/\'/ $out/bin/*
  '';

  passthru = {
    imagemagick-compat = callPackage ./imagemagick-compat.nix {
      graphicsmagick = finalAttrs.finalPackage;
    };
    tests = {
      issue-157920 = runCommand "issue-157920-regression-test" {
        buildInputs = [ finalAttrs.finalPackage ];
      } ''
        gm convert ${graphviz}/share/doc/graphviz/neatoguide.pdf jpg:$out
      '';
    };
  };

  meta = {
    homepage = "http://www.graphicsmagick.org";
    description = "Swiss army knife of image processing";
    longDescription = ''
      GraphicsMagick is the swiss army knife of image processing, providing a
      robust and efficient collection of tools and libraries which support
      reading, writing, and manipulating an image in over 92 major formats
      including important formats like DPX, GIF, JPEG, JPEG-2000, JXL, PNG, PDF,
      PNM, TIFF, and WebP.
    '';
    license = with lib.licenses; [ mit ];
    maintainers = with lib.maintainers; [ AndersonTorres ];
    mainProgram = "gm";
    platforms = lib.platforms.all;
  };
})