about summary refs log tree commit diff
path: root/nixpkgs/pkgs/tools/graphics
diff options
context:
space:
mode:
Diffstat (limited to 'nixpkgs/pkgs/tools/graphics')
-rw-r--r--nixpkgs/pkgs/tools/graphics/appleseed/default.nix72
-rw-r--r--nixpkgs/pkgs/tools/graphics/argyllcms/default.nix121
-rw-r--r--nixpkgs/pkgs/tools/graphics/argyllcms/gcc5.patch20
-rw-r--r--nixpkgs/pkgs/tools/graphics/asymptote/default.nix78
-rw-r--r--nixpkgs/pkgs/tools/graphics/asymptote/default.upstream4
-rw-r--r--nixpkgs/pkgs/tools/graphics/barcode/default.nix23
-rw-r--r--nixpkgs/pkgs/tools/graphics/blockhash/default.nix28
-rw-r--r--nixpkgs/pkgs/tools/graphics/briss/default.nix32
-rw-r--r--nixpkgs/pkgs/tools/graphics/cfdg/default.nix33
-rw-r--r--nixpkgs/pkgs/tools/graphics/cfdg/src-for-default.nix9
-rw-r--r--nixpkgs/pkgs/tools/graphics/cfdg/src-info-for-default.nix6
-rw-r--r--nixpkgs/pkgs/tools/graphics/convchain/default.nix40
-rw-r--r--nixpkgs/pkgs/tools/graphics/cuneiform/default.nix34
-rw-r--r--nixpkgs/pkgs/tools/graphics/cuneiform/default.upstream8
-rw-r--r--nixpkgs/pkgs/tools/graphics/dcraw/default.nix32
-rw-r--r--nixpkgs/pkgs/tools/graphics/diagrams-builder/default.nix44
-rw-r--r--nixpkgs/pkgs/tools/graphics/ditaa/default.nix34
-rw-r--r--nixpkgs/pkgs/tools/graphics/dmtx-utils/default.nix30
-rw-r--r--nixpkgs/pkgs/tools/graphics/dmtx-utils/default.upstream4
-rw-r--r--nixpkgs/pkgs/tools/graphics/dpic/default.nix29
-rw-r--r--nixpkgs/pkgs/tools/graphics/editres/default.nix24
-rw-r--r--nixpkgs/pkgs/tools/graphics/enblend-enfuse/default.nix30
-rw-r--r--nixpkgs/pkgs/tools/graphics/eplot/default.nix47
-rw-r--r--nixpkgs/pkgs/tools/graphics/epstool/default.nix25
-rw-r--r--nixpkgs/pkgs/tools/graphics/epstool/gcc43.patch20
-rw-r--r--nixpkgs/pkgs/tools/graphics/escrotum/default.nix25
-rw-r--r--nixpkgs/pkgs/tools/graphics/exif/default.nix20
-rw-r--r--nixpkgs/pkgs/tools/graphics/exiftags/default.nix26
-rw-r--r--nixpkgs/pkgs/tools/graphics/facedetect/default.nix37
-rw-r--r--nixpkgs/pkgs/tools/graphics/fast-neural-doodle/default.nix63
-rw-r--r--nixpkgs/pkgs/tools/graphics/fast-neural-doodle/fast-neural-doodle.sh28
-rw-r--r--nixpkgs/pkgs/tools/graphics/fast-neural-doodle/get-mask-hdf5.sh5
-rw-r--r--nixpkgs/pkgs/tools/graphics/fbv/default.nix25
-rw-r--r--nixpkgs/pkgs/tools/graphics/feedgnuplot/default.nix56
-rw-r--r--nixpkgs/pkgs/tools/graphics/fgallery/default.nix46
-rw-r--r--nixpkgs/pkgs/tools/graphics/fim/default.nix52
-rw-r--r--nixpkgs/pkgs/tools/graphics/flam3/default.nix25
-rw-r--r--nixpkgs/pkgs/tools/graphics/ggobi/default.nix26
-rw-r--r--nixpkgs/pkgs/tools/graphics/gifsicle/default.nix33
-rw-r--r--nixpkgs/pkgs/tools/graphics/glee/default.nix34
-rw-r--r--nixpkgs/pkgs/tools/graphics/glmark2/default.nix33
-rw-r--r--nixpkgs/pkgs/tools/graphics/glxinfo/default.nix34
-rw-r--r--nixpkgs/pkgs/tools/graphics/gmic/default.nix47
-rw-r--r--nixpkgs/pkgs/tools/graphics/gmic_krita_qt/default.nix82
-rw-r--r--nixpkgs/pkgs/tools/graphics/gnuplot/default.nix75
-rw-r--r--nixpkgs/pkgs/tools/graphics/gnuplot/set-gdfontpath-from-fontconfig.sh4
-rw-r--r--nixpkgs/pkgs/tools/graphics/graph-easy/default.nix17
-rw-r--r--nixpkgs/pkgs/tools/graphics/graphviz/2.32.nix5
-rw-r--r--nixpkgs/pkgs/tools/graphics/graphviz/base.nix70
-rw-r--r--nixpkgs/pkgs/tools/graphics/graphviz/default.nix5
-rw-r--r--nixpkgs/pkgs/tools/graphics/gromit-mpx/default.nix38
-rw-r--r--nixpkgs/pkgs/tools/graphics/guff/default.nix25
-rw-r--r--nixpkgs/pkgs/tools/graphics/ibniz/default.nix26
-rw-r--r--nixpkgs/pkgs/tools/graphics/icoutils/default.nix32
-rw-r--r--nixpkgs/pkgs/tools/graphics/imgur-screenshot/default.nix29
-rw-r--r--nixpkgs/pkgs/tools/graphics/imgurbash2/default.nix31
-rw-r--r--nixpkgs/pkgs/tools/graphics/jbig2enc/53ce5fe7e73d7ed95c9e12b52dd4984723f865fa.patch47
-rw-r--r--nixpkgs/pkgs/tools/graphics/jbig2enc/default.nix32
-rw-r--r--nixpkgs/pkgs/tools/graphics/jhead/default.nix41
-rw-r--r--nixpkgs/pkgs/tools/graphics/kst/default.nix32
-rw-r--r--nixpkgs/pkgs/tools/graphics/leela/default.nix25
-rw-r--r--nixpkgs/pkgs/tools/graphics/logstalgia/default.nix44
-rw-r--r--nixpkgs/pkgs/tools/graphics/lprof/default.nix37
-rw-r--r--nixpkgs/pkgs/tools/graphics/lprof/keep-environment.patch16
-rw-r--r--nixpkgs/pkgs/tools/graphics/lprof/lcms-1.17.patch13
-rw-r--r--nixpkgs/pkgs/tools/graphics/luxcorerender/default.nix88
-rw-r--r--nixpkgs/pkgs/tools/graphics/maim/default.nix36
-rw-r--r--nixpkgs/pkgs/tools/graphics/mscgen/default.nix42
-rw-r--r--nixpkgs/pkgs/tools/graphics/netpbm/default.nix70
-rw-r--r--nixpkgs/pkgs/tools/graphics/neural-style/default.nix58
-rw-r--r--nixpkgs/pkgs/tools/graphics/neural-style/neural-style.sh25
-rw-r--r--nixpkgs/pkgs/tools/graphics/nifskope/default.nix68
-rw-r--r--nixpkgs/pkgs/tools/graphics/nifskope/external-lib-paths.patch33
-rw-r--r--nixpkgs/pkgs/tools/graphics/nifskope/qttools-bins.patch22
-rw-r--r--nixpkgs/pkgs/tools/graphics/nip2/default.nix24
-rw-r--r--nixpkgs/pkgs/tools/graphics/optar/default.nix35
-rw-r--r--nixpkgs/pkgs/tools/graphics/optipng/default.nix42
-rw-r--r--nixpkgs/pkgs/tools/graphics/oxipng/default.nix26
-rw-r--r--nixpkgs/pkgs/tools/graphics/pdf2svg/default.nix25
-rw-r--r--nixpkgs/pkgs/tools/graphics/pdfread/default.nix50
-rw-r--r--nixpkgs/pkgs/tools/graphics/pdfredacttools/default.nix38
-rw-r--r--nixpkgs/pkgs/tools/graphics/pdftag/default.nix25
-rw-r--r--nixpkgs/pkgs/tools/graphics/perceptualdiff/default.nix25
-rw-r--r--nixpkgs/pkgs/tools/graphics/pfstools/default.nix37
-rw-r--r--nixpkgs/pkgs/tools/graphics/pfstools/pfstools.patch21
-rw-r--r--nixpkgs/pkgs/tools/graphics/pfstools/threads.patch20
-rw-r--r--nixpkgs/pkgs/tools/graphics/pgf/default.nix33
-rw-r--r--nixpkgs/pkgs/tools/graphics/ploticus/builder.sh33
-rw-r--r--nixpkgs/pkgs/tools/graphics/ploticus/default.nix37
-rw-r--r--nixpkgs/pkgs/tools/graphics/ploticus/ploticus-install.patch12
-rw-r--r--nixpkgs/pkgs/tools/graphics/plotutils/debian-patches.nix42
-rw-r--r--nixpkgs/pkgs/tools/graphics/plotutils/debian-patches.txt10
-rw-r--r--nixpkgs/pkgs/tools/graphics/plotutils/default.nix58
-rw-r--r--nixpkgs/pkgs/tools/graphics/pngcheck/default.nix30
-rw-r--r--nixpkgs/pkgs/tools/graphics/pngcrush/default.nix26
-rw-r--r--nixpkgs/pkgs/tools/graphics/pngnq/default.nix25
-rw-r--r--nixpkgs/pkgs/tools/graphics/pngout/default.nix33
-rw-r--r--nixpkgs/pkgs/tools/graphics/pngquant/default.nix27
-rw-r--r--nixpkgs/pkgs/tools/graphics/pngtoico/default.nix23
-rw-r--r--nixpkgs/pkgs/tools/graphics/povray/default.nix49
-rw-r--r--nixpkgs/pkgs/tools/graphics/pstoedit/default.nix39
-rw-r--r--nixpkgs/pkgs/tools/graphics/pstoedit/pstoedit-gs-9.22-compat.patch13
-rw-r--r--nixpkgs/pkgs/tools/graphics/qrcode/default.nix28
-rw-r--r--nixpkgs/pkgs/tools/graphics/qrencode/default.nix21
-rw-r--r--nixpkgs/pkgs/tools/graphics/quirc/default.nix39
-rw-r--r--nixpkgs/pkgs/tools/graphics/rocket/default.nix31
-rw-r--r--nixpkgs/pkgs/tools/graphics/s2png/default.nix24
-rw-r--r--nixpkgs/pkgs/tools/graphics/scanbd/default.nix56
-rw-r--r--nixpkgs/pkgs/tools/graphics/scrot/default.nix32
-rw-r--r--nixpkgs/pkgs/tools/graphics/sng/default.nix25
-rw-r--r--nixpkgs/pkgs/tools/graphics/structure-synth/default.nix47
-rw-r--r--nixpkgs/pkgs/tools/graphics/structure-synth/gcc47.patch50
-rw-r--r--nixpkgs/pkgs/tools/graphics/svgcleaner/default.nix23
-rw-r--r--nixpkgs/pkgs/tools/graphics/swfdec/default.nix38
-rw-r--r--nixpkgs/pkgs/tools/graphics/syntex/default.nix34
-rw-r--r--nixpkgs/pkgs/tools/graphics/transfig/default.nix61
-rw-r--r--nixpkgs/pkgs/tools/graphics/transfig/patch-fig2dev-Imakefile75
-rw-r--r--nixpkgs/pkgs/tools/graphics/transfig/patch-fig2dev-dev-Imakefile15
-rw-r--r--nixpkgs/pkgs/tools/graphics/transfig/patch-fig2dev-dev-gensvg.c21
-rw-r--r--nixpkgs/pkgs/tools/graphics/transfig/patch-fig2dev-fig2dev.h19
-rw-r--r--nixpkgs/pkgs/tools/graphics/transfig/patch-transfig-Imakefile22
-rw-r--r--nixpkgs/pkgs/tools/graphics/twilight/default.nix29
-rw-r--r--nixpkgs/pkgs/tools/graphics/unpaper/default.nix22
-rw-r--r--nixpkgs/pkgs/tools/graphics/vips/default.nix39
-rw-r--r--nixpkgs/pkgs/tools/graphics/vulkan-tools/default.nix28
-rw-r--r--nixpkgs/pkgs/tools/graphics/wavefunctioncollapse/default.nix34
-rw-r--r--nixpkgs/pkgs/tools/graphics/welkin/default.nix36
-rw-r--r--nixpkgs/pkgs/tools/graphics/wkhtmltopdf/default.nix46
-rw-r--r--nixpkgs/pkgs/tools/graphics/xcftools/default.nix40
-rw-r--r--nixpkgs/pkgs/tools/graphics/yafaray-core/default.nix38
-rw-r--r--nixpkgs/pkgs/tools/graphics/yaxg/default.nix38
-rw-r--r--nixpkgs/pkgs/tools/graphics/zbar/default.nix71
-rw-r--r--nixpkgs/pkgs/tools/graphics/zxing/default.nix34
-rw-r--r--nixpkgs/pkgs/tools/graphics/zxing/java-zxing.sh3
-rw-r--r--nixpkgs/pkgs/tools/graphics/zxing/zxing-cmdline-encoder.sh3
-rw-r--r--nixpkgs/pkgs/tools/graphics/zxing/zxing-cmdline-runner.sh3
-rw-r--r--nixpkgs/pkgs/tools/graphics/zxing/zxing.sh18
137 files changed, 4611 insertions, 0 deletions
diff --git a/nixpkgs/pkgs/tools/graphics/appleseed/default.nix b/nixpkgs/pkgs/tools/graphics/appleseed/default.nix
new file mode 100644
index 000000000000..7ac9a2016611
--- /dev/null
+++ b/nixpkgs/pkgs/tools/graphics/appleseed/default.nix
@@ -0,0 +1,72 @@
+{ stdenv, fetchFromGitHub, cmake, boost165, pkgconfig, guile,
+eigen, libpng, python, libGLU, qt4, openexr, openimageio,
+opencolorio, xercesc, ilmbase, osl, seexpr
+}:
+
+let boost_static = boost165.override {
+  enableStatic = true;
+  enablePython = true;
+};
+in stdenv.mkDerivation rec {
+
+  name = "appleseed-${version}";
+  version = "1.9.0-beta";
+
+  src = fetchFromGitHub {
+    owner  = "appleseedhq";
+    repo   = "appleseed";
+    rev    = "1.9.0-beta";
+    sha256 = "0m7zvfkdjfn48zzaxh2wa1bsaj4l876a05bzgmjlfq5dz3202anr";
+  };
+  buildInputs = [
+    cmake pkgconfig boost_static guile eigen libpng python
+    libGLU qt4 openexr openimageio opencolorio xercesc
+    osl seexpr
+  ];
+
+  NIX_CFLAGS_COMPILE = "-I${openexr.dev}/include/OpenEXR -I${ilmbase.dev}/include/OpenEXR -I${openimageio.dev}/include/OpenImageIO";
+
+  cmakeFlags = [
+      "-DUSE_EXTERNAL_XERCES=ON" "-DUSE_EXTERNAL_OCIO=ON" "-DUSE_EXTERNAL_OIIO=ON"
+      "-DUSE_EXTERNAL_OSL=ON" "-DWITH_CLI=ON" "-DWITH_STUDIO=ON" "-DWITH_TOOLS=ON"
+      "-DUSE_EXTERNAL_PNG=ON" "-DUSE_EXTERNAL_ZLIB=ON"
+      "-DUSE_EXTERNAL_EXR=ON" "-DUSE_EXTERNAL_SEEXPR=ON"
+      "-DWITH_PYTHON=ON"
+      "-DWITH_DISNEY_MATERIAL=ON"
+      "-DUSE_SSE=ON"
+      "-DUSE_SSE42=ON"
+  ];
+  enableParallelBuilding = true;
+
+  meta = with stdenv.lib; {
+    description = "Open source, physically-based global illumination rendering engine";
+    homepage = https://appleseedhq.net/;
+    maintainers = with maintainers; [ hodapp ];
+    license = licenses.mit;
+    platforms = platforms.linux;
+  };
+
+  # Work around a bug in the CMake build:
+  postInstall = ''
+    chmod a+x $out/bin/*
+  '';
+}
+
+# TODO: Is the below problematic?
+
+# CMake Warning (dev) at /nix/store/dsyw2zla2h3ld2p0jj4cv0j3wal1bp3h-cmake-3.11.2/share/cmake-3.11/Modules/FindOpenGL.cmake:270 (message):
+#  Policy CMP0072 is not set: FindOpenGL prefers GLVND by default when
+#  available.  Run "cmake --help-policy CMP0072" for policy details.  Use the
+#  cmake_policy command to set the policy and suppress this warning.
+#
+#  FindOpenGL found both a legacy GL library:
+#
+#    OPENGL_gl_LIBRARY: /nix/store/yxrgmcz2xlgn113wz978a91qbsy4rc8g-libGL-1.0.0/lib/libGL.so
+#
+#  and GLVND libraries for OpenGL and GLX:
+#
+#    OPENGL_opengl_LIBRARY: /nix/store/yxrgmcz2xlgn113wz978a91qbsy4rc8g-libGL-1.0.0/lib/libOpenGL.so
+#    OPENGL_glx_LIBRARY: /nix/store/yxrgmcz2xlgn113wz978a91qbsy4rc8g-libGL-1.0.0/lib/libGLX.so
+#
+#  OpenGL_GL_PREFERENCE has not been set to "GLVND" or "LEGACY", so for
+#  compatibility with CMake 3.10 and below the legacy GL library will be used.
diff --git a/nixpkgs/pkgs/tools/graphics/argyllcms/default.nix b/nixpkgs/pkgs/tools/graphics/argyllcms/default.nix
new file mode 100644
index 000000000000..aa1137eeeff1
--- /dev/null
+++ b/nixpkgs/pkgs/tools/graphics/argyllcms/default.nix
@@ -0,0 +1,121 @@
+{ stdenv, fetchzip, jam, unzip, libX11, libXxf86vm, libXrandr, libXinerama
+, libXrender, libXext, libtiff, libjpeg, libpng, libXScrnSaver, writeText
+, libXdmcp, libXau, lib, openssl }:
+let
+  version = "2.0.1";
+ in
+stdenv.mkDerivation rec {
+  name = "argyllcms-${version}";
+
+  src = fetchzip {
+    # Kind of flacky URL, it was reaturning 406 and inconsistent binaries for a
+    # while on me. It might be good to find a mirror
+    url = "https://www.argyllcms.com/Argyll_V${version}_src.zip";
+    sha256 = "0a7m5mwvy74db34hvqsgy296469x3139qj5gfj4zqpnz0iyxhkny";
+
+    # The argyllcms web server doesn't like curl ...
+    curlOpts = "--user-agent 'Mozilla/5.0'";
+  };
+
+  patches = [ ./gcc5.patch ];
+
+  # The contents of this file comes from the Jamtop file from the
+  # root of the ArgyllCMS distribution, rewritten to pick up Nixpkgs
+  # library paths. When ArgyllCMS is updated, make sure that changes
+  # in that file is reflected here.
+  jamTop = writeText "argyllcms_jamtop" ''
+    DESTDIR = "/" ;
+    REFSUBDIR = "ref" ;
+
+    # Keep this DESTDIR anchored to Jamtop. PREFIX is used literally
+    ANCHORED_PATH_VARS = DESTDIR ;
+
+    # Tell standalone libraries that they are part of Argyll:
+    DEFINES += ARGYLLCMS ;
+
+    # enable serial instruments & support
+    USE_SERIAL = true ;
+
+    # enable fast serial instruments & support
+    USE_FAST_SERIAL = true ;                # (Implicit in USE_SERIAL too)
+
+    # enable USB instruments & support
+    USE_USB = true ;
+
+    # enable dummy Demo Instrument (only if code is available)
+    USE_DEMOINST = true ;
+
+    # Use ArgyllCMS version of libusb (deprecated - don't use)
+    USE_LIBUSB = false ;
+
+    # For testing CCast
+    DEFINES += CCTEST_PATTERN ;
+
+    JPEGLIB = ;
+    JPEGINC = ;
+    HAVE_JPEG = true ;
+
+    TIFFLIB = ;
+    TIFFINC = ;
+    HAVE_TIFF = true ;
+
+    PNGLIB = ;
+    PNGINC = ;
+    HAVE_PNG = true ;
+
+    ZLIB = ;
+    ZINC = ;
+    HAVE_Z = true ;
+
+    SSLLIB = ;
+    SSLINC = ;
+    HAVE_SSL = true ;
+
+    LINKFLAGS +=
+      ${lib.concatStringsSep " " (map (x: "-L${x}/lib") buildInputs)}
+      -ldl -lrt -lX11 -lXext -lXxf86vm -lXinerama -lXrandr -lXau -lXdmcp -lXss
+      -ljpeg -ltiff -lpng -lssl ;
+  '';
+
+  nativeBuildInputs = [ jam unzip ];
+
+  preConfigure = ''
+    cp ${jamTop} Jamtop
+    substituteInPlace Makefile --replace "-j 3" "-j $NIX_BUILD_CORES"
+    # Remove tiff, jpg and png to be sure the nixpkgs-provided ones are used
+    rm -rf tiff jpg png
+
+    unset AR
+  '';
+
+  buildInputs = [
+    libtiff libjpeg libpng libX11 libXxf86vm libXrandr libXinerama libXext
+    libXrender libXScrnSaver libXdmcp libXau openssl
+  ];
+
+  buildFlags = "PREFIX=$(out) all";
+
+  installFlags = "PREFIX=$(out)";
+
+  # Install udev rules, but remove lines that set up the udev-acl
+  # stuff, since that is handled by udev's own rules (70-udev-acl.rules)
+  #
+  # Move ref to a better place (there must be a way to make the install target
+  # do that for us)
+  postInstall = ''
+    rm -v $out/bin/License.txt
+    mkdir -p $out/etc/udev/rules.d
+    sed -i '/udev-acl/d' usb/55-Argyll.rules
+    cp -v usb/55-Argyll.rules $out/etc/udev/rules.d/
+    mkdir -p $out/share/
+    mv $out/ref $out/share/argyllcms
+  '';
+
+  meta = with stdenv.lib; {
+    homepage = http://www.argyllcms.com;
+    description = "Color management system (compatible with ICC)";
+    license = licenses.gpl3;
+    maintainers = [ maintainers.rickynils ];
+    platforms = platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/tools/graphics/argyllcms/gcc5.patch b/nixpkgs/pkgs/tools/graphics/argyllcms/gcc5.patch
new file mode 100644
index 000000000000..28067455c33e
--- /dev/null
+++ b/nixpkgs/pkgs/tools/graphics/argyllcms/gcc5.patch
@@ -0,0 +1,20 @@
+Description: Fix FTBFS with GCC 5
+Author: James Cowgill <james410@cowgill.org.uk>
+Bug-Debian: https://bugs.debian.org/777779
+Forwarded: no
+---
+This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
+--- a/icc/icc.h
++++ b/icc/icc.h
+@@ -100,7 +100,11 @@
+ #define CF64PREC "LL"		/* Constant precision specifier */
+ 
+ #ifndef ATTRIBUTE_NORETURN
++#ifdef _MSC_VER
+ # define ATTRIBUTE_NORETURN __declspec(noreturn)
++#else
++# define ATTRIBUTE_NORETURN __attribute__((noreturn))
++#endif
+ #endif
+ 
+ #else  /* !__STDC_VERSION__ */
diff --git a/nixpkgs/pkgs/tools/graphics/asymptote/default.nix b/nixpkgs/pkgs/tools/graphics/asymptote/default.nix
new file mode 100644
index 000000000000..102ffae5f9d0
--- /dev/null
+++ b/nixpkgs/pkgs/tools/graphics/asymptote/default.nix
@@ -0,0 +1,78 @@
+{stdenv, fetchurl, fetchpatch
+  , freeglut, ghostscriptX, imagemagick, fftw
+  , boehmgc, libGLU, libGL, mesa_noglu, ncurses, readline, gsl, libsigsegv
+  , python, zlib, perl, texLive, texinfo, xz
+, darwin
+}:
+
+let
+  s = # Generated upstream information
+  rec {
+    baseName="asymptote";
+    version="2.47";
+    name="${baseName}-${version}";
+    hash="0zc24n2vwzxdfmcppqfk3fkqlb4jmvswzi3bz232kxl7dyiyb971";
+    url="https://freefr.dl.sourceforge.net/project/asymptote/2.47/asymptote-2.47.src.tgz";
+    sha256="0zc24n2vwzxdfmcppqfk3fkqlb4jmvswzi3bz232kxl7dyiyb971";
+  };
+  buildInputs = [
+   ghostscriptX imagemagick fftw
+   boehmgc ncurses readline gsl libsigsegv
+   python zlib perl texLive texinfo xz ]
+   ++ stdenv.lib.optionals stdenv.isLinux
+     [ freeglut libGLU libGL mesa_noglu.osmesa ]
+   ++ stdenv.lib.optionals stdenv.isDarwin
+     (with darwin.apple_sdk.frameworks; [ OpenGL GLUT Cocoa ])
+   ;
+in
+stdenv.mkDerivation {
+  inherit (s) name version;
+  inherit buildInputs;
+
+  src = fetchurl {
+    inherit (s) url sha256;
+  };
+
+  patches = [
+    # Remove when updating from 2.47 to 2.48
+    # Compatibility with BoehmGC 7.6.8
+    (fetchpatch {
+      url = "https://github.com/vectorgraphics/asymptote/commit/38a59370dc5ac720c29e1424614a10f7384b943f.patch";
+      sha256 = "0c3d11hzxxaqh24kfw9y8zvlid54kk40rx2zajx7jwl12gga05s1";
+    })
+  ];
+
+  preConfigure = ''
+    export HOME="$PWD"
+    patchShebangs .
+    sed -e 's@epswrite@eps2write@g' -i runlabel.in
+    xz -d < ${texinfo.src} | tar --wildcards -x texinfo-'*'/doc/texinfo.tex
+    cp texinfo-*/doc/texinfo.tex doc/
+    rm *.tar.gz
+    configureFlags="$configureFlags --with-latex=$out/share/texmf/tex/latex --with-context=$out/share/texmf/tex/context/third"
+  '';
+
+  NIX_CFLAGS_COMPILE = [ "-I${boehmgc.dev}/include/gc" ];
+
+  postInstall = ''
+    mv -v "$out/share/info/asymptote/"*.info $out/share/info/
+    sed -i -e 's|(asymptote/asymptote)|(asymptote)|' $out/share/info/asymptote.info
+    rmdir $out/share/info/asymptote
+    rm $out/share/info/dir
+
+    rm -rfv "$out"/share/texmf
+    mkdir -pv "$out"/share/emacs/site-lisp/${s.name}
+    mv -v "$out"/share/asymptote/*.el "$out"/share/emacs/site-lisp/${s.name}
+  '';
+
+  enableParallelBuilding = true;
+
+  meta = with stdenv.lib; {
+    inherit (s) version;
+    description =  "A tool for programming graphics intended to replace Metapost";
+    license = licenses.gpl3Plus;
+    maintainers = [ maintainers.raskin maintainers.peti ];
+    broken = stdenv.isDarwin;  # https://github.com/vectorgraphics/asymptote/issues/69
+    platforms = platforms.linux ++ platforms.darwin;
+  };
+}
diff --git a/nixpkgs/pkgs/tools/graphics/asymptote/default.upstream b/nixpkgs/pkgs/tools/graphics/asymptote/default.upstream
new file mode 100644
index 000000000000..e86d81ba4435
--- /dev/null
+++ b/nixpkgs/pkgs/tools/graphics/asymptote/default.upstream
@@ -0,0 +1,4 @@
+url https://sourceforge.net/projects/asymptote/files/
+SF_version_dir
+version_link 'src[.]tgz/download$'
+SF_redirect
diff --git a/nixpkgs/pkgs/tools/graphics/barcode/default.nix b/nixpkgs/pkgs/tools/graphics/barcode/default.nix
new file mode 100644
index 000000000000..de09c2b27804
--- /dev/null
+++ b/nixpkgs/pkgs/tools/graphics/barcode/default.nix
@@ -0,0 +1,23 @@
+{ stdenv, fetchurl }:
+
+stdenv.mkDerivation rec {
+  name = "${pname}-${version}";
+  version = "0.99";
+  pname = "barcode";
+  src = fetchurl {
+    url = "mirror://gnu/${pname}/${name}.tar.xz";
+    sha256 = "1indapql5fjz0bysyc88cmc54y8phqrbi7c76p71fgjp45jcyzp8";
+  };
+
+  hardeningDisable = [ "format" ];
+
+  meta = with stdenv.lib; {
+    description = "GNU barcode generator";
+    maintainers = with maintainers; [ raskin ];
+    platforms = platforms.linux; # Maybe other non-darwin Unix
+    downloadPage = "https://ftp.gnu.org/gnu/barcode/";
+    updateWalker = true;
+    homepage = https://www.gnu.org/software/barcode/;
+    license = licenses.gpl3;
+  };
+}
diff --git a/nixpkgs/pkgs/tools/graphics/blockhash/default.nix b/nixpkgs/pkgs/tools/graphics/blockhash/default.nix
new file mode 100644
index 000000000000..ad72933cc771
--- /dev/null
+++ b/nixpkgs/pkgs/tools/graphics/blockhash/default.nix
@@ -0,0 +1,28 @@
+{ stdenv, fetchFromGitHub, python, pkgconfig, imagemagick, wafHook }:
+
+stdenv.mkDerivation rec {
+  name = "blockhash-${version}";
+  version = "0.3.1";
+
+  src = fetchFromGitHub {
+    owner = "commonsmachinery";
+    repo = "blockhash";
+    rev = "v${version}";
+    sha256 = "0m7ikppl42iicgmwsb7baajmag7v0p1ab06xckifvrr0zm21bq9p";
+  };
+
+  nativeBuildInputs = [ python pkgconfig wafHook ];
+  buildInputs = [ imagemagick ];
+
+  meta = with stdenv.lib; {
+    homepage = "http://blockhash.io/";
+    description = ''
+      This is a perceptual image hash calculation tool based on algorithm
+      descibed in Block Mean Value Based Image Perceptual Hashing by Bian Yang,
+      Fan Gu and Xiamu Niu.
+    '';
+    license = licenses.mit;
+    maintainers = [ maintainers.infinisil ];
+    platforms = platforms.unix;
+  };
+}
diff --git a/nixpkgs/pkgs/tools/graphics/briss/default.nix b/nixpkgs/pkgs/tools/graphics/briss/default.nix
new file mode 100644
index 000000000000..a5045f97b45d
--- /dev/null
+++ b/nixpkgs/pkgs/tools/graphics/briss/default.nix
@@ -0,0 +1,32 @@
+# The releases of this project are apparently precompiled to .jar files.
+
+{ stdenv, fetchurl, jre }:
+
+let
+
+  version = "0.9";
+  sha256 = "45dd668a9ceb9cd59529a9fefe422a002ee1554a61be07e6fc8b3baf33d733d9";
+
+in stdenv.mkDerivation {
+  name = "briss-${version}";
+  src = fetchurl {
+    url = "mirror://sourceforge/briss/briss-${version}.tar.gz";
+    inherit sha256;
+  };
+
+  installPhase = ''
+    mkdir -p "$out/bin";
+    mkdir -p "$out/share";
+    install -D -m444 -t "$out/share" *.jar
+    echo "#!/bin/sh" > "$out/bin/briss"
+    echo "${jre}/bin/java -Xms128m -Xmx1024m -cp \"$out/share/\" -jar \"$out/share/briss-${version}.jar\"" >> "$out/bin/briss"
+    chmod +x "$out/bin/briss"
+  '';
+
+  meta = {
+    homepage = https://sourceforge.net/projects/briss/;
+    description = "Java application for cropping PDF files";
+    license = stdenv.lib.licenses.gpl3;
+    platforms = stdenv.lib.platforms.unix;
+  };
+}
diff --git a/nixpkgs/pkgs/tools/graphics/cfdg/default.nix b/nixpkgs/pkgs/tools/graphics/cfdg/default.nix
new file mode 100644
index 000000000000..c65d1302dcaf
--- /dev/null
+++ b/nixpkgs/pkgs/tools/graphics/cfdg/default.nix
@@ -0,0 +1,33 @@
+{ stdenv, fetchurl, libpng, bison, flex, ffmpeg }:
+
+stdenv.mkDerivation rec {
+  name = "cfdg-${version}";
+  version = "3.0.9";
+  src = fetchurl {
+    sha256 = "1jqpinz6ri4a2l04mf2z1ljalkdk1m07hj47lqkh8gbf2slfs0jl";
+    url = "http://www.contextfreeart.org/download/ContextFreeSource${version}.tgz";
+  };
+
+  buildInputs = [ libpng bison flex ffmpeg ];
+
+  postPatch = ''
+    sed -e "/YY_NO_UNISTD/a#include <stdio.h>" -i src-common/cfdg.l
+  '';
+
+  installPhase = ''
+    mkdir -p $out/bin
+    cp cfdg $out/bin/
+
+    mkdir -p $out/share/doc/${name}
+    cp *.txt $out/share/doc/${name}
+  '';
+
+  meta = with stdenv.lib; {
+    description = "Context-free design grammar - a tool for graphics generation";
+    maintainers = with maintainers; [ raskin ];
+    platforms = platforms.linux;
+    homepage = https://contextfreeart.org/;
+    license = licenses.gpl2;
+    downloadPage = "https://contextfreeart.org/mediawiki/index.php/Download_page";
+  };
+}
diff --git a/nixpkgs/pkgs/tools/graphics/cfdg/src-for-default.nix b/nixpkgs/pkgs/tools/graphics/cfdg/src-for-default.nix
new file mode 100644
index 000000000000..179f0432dd10
--- /dev/null
+++ b/nixpkgs/pkgs/tools/graphics/cfdg/src-for-default.nix
@@ -0,0 +1,9 @@
+rec {
+   version="3.0.2";
+   name="cfdg-3.0.2";
+   hash="1pd1hjippbhad8l4s4lsglykh22i24qfrgmnxrsx71bvcqbr356p";
+   url="http://www.contextfreeart.org/download/ContextFreeSource3.0.2.tgz";
+   advertisedUrl="http://www.contextfreeart.org/download/ContextFreeSource3.0.2.tgz";
+  
+  
+}
diff --git a/nixpkgs/pkgs/tools/graphics/cfdg/src-info-for-default.nix b/nixpkgs/pkgs/tools/graphics/cfdg/src-info-for-default.nix
new file mode 100644
index 000000000000..0e2018b6bfdd
--- /dev/null
+++ b/nixpkgs/pkgs/tools/graphics/cfdg/src-info-for-default.nix
@@ -0,0 +1,6 @@
+{
+  downloadPage = "https://contextfreeart.org/mediawiki/index.php/Download_page";
+  baseName = "cfdg";
+  sourceRegexp = ''.*[.]tgz'';
+  versionExtractorSedScript = ''s/[^0-9]*([0-9.]*)[.]tgz/\1/'';
+}
diff --git a/nixpkgs/pkgs/tools/graphics/convchain/default.nix b/nixpkgs/pkgs/tools/graphics/convchain/default.nix
new file mode 100644
index 000000000000..12fc6934531a
--- /dev/null
+++ b/nixpkgs/pkgs/tools/graphics/convchain/default.nix
@@ -0,0 +1,40 @@
+{stdenv, fetchFromGitHub, mono}:
+stdenv.mkDerivation rec {
+  name = "convchain-${version}";
+  version = "0.0pre20160901";
+  src = fetchFromGitHub {
+    owner = "mxgmn";
+    repo = "ConvChain";
+    rev = "8abb1e88a496fcae4c0ae31acd4eea55957dab68";
+    sha256 = "0lnscljgbw0s90sfcahwvnxakml0f4d8jxi5ikm4ak8qgnvw6rql";
+  };
+  buildPhase = ''
+    mcs ConvChain.cs -out:convchain.exe -r:System.Drawing
+    mcs ConvChainFast.cs -out:convchainfast.exe -r:System.Drawing
+    grep -m1 -B999 '^[*][/]' ConvChainFast.cs > COPYING.MIT
+  '';
+  installPhase = ''
+    mkdir -p "$out"/{bin,share/doc/convchain,share/convchain}
+    cp README.md COPYING.MIT "$out"/share/doc/convchain
+    cp convchain*.exe "$out"/bin
+    cp -r [Ss]amples samples.xml "$out/share/convchain"
+
+    echo "#! ${stdenv.shell}" >> "$out/bin/convchain"
+    echo "chmod u+w ." >> "$out/bin/convchain"
+    echo "'${mono}/bin/mono' '$out/bin/convchain.exe' \"\$@\"" >>  "$out/bin/convchain"
+    chmod a+x "$out/bin/convchain"
+
+    echo "#! ${stdenv.shell}" >> "$out/bin/convchainfast"
+    echo "chmod u+w ." >> "$out/bin/convchainfast"
+    echo "'${mono}/bin/mono' '$out/bin/convchainfast.exe' \"\$@\"" >>  "$out/bin/convchainfast"
+    chmod a+x "$out/bin/convchainfast"
+  '';
+  buildInputs = [mono];
+  meta = {
+    inherit version;
+    description = ''Bitmap generation from a single example with convolutions and MCMC'';
+    license = stdenv.lib.licenses.mit;
+    maintainers = [stdenv.lib.maintainers.raskin];
+    platforms = stdenv.lib.platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/tools/graphics/cuneiform/default.nix b/nixpkgs/pkgs/tools/graphics/cuneiform/default.nix
new file mode 100644
index 000000000000..9fcb7ba404d0
--- /dev/null
+++ b/nixpkgs/pkgs/tools/graphics/cuneiform/default.nix
@@ -0,0 +1,34 @@
+{ stdenv, fetchurl, cmake, imagemagick }:
+
+stdenv.mkDerivation rec {
+  name = "cuneiform-${version}";
+  version = "1.1.0";
+
+  src = fetchurl {
+    url = "https://launchpad.net/cuneiform-linux/1.1/1.1/+download/cuneiform-linux-1.1.0.tar.bz2";
+    sha256 = "1bdvppyfx2184zmzcylskd87cxv56d8f32jf7g1qc8779l2hszjp";
+  };
+
+  patches = [
+  (fetchurl {
+    url = "https://git.archlinux.org/svntogit/community.git/plain/cuneiform/trunk/build-fix.patch?id=a2ec92f05de006b56d16ac6a6c370d54a554861a";
+    sha256 = "19cmrlx4khn30qqrpyayn7bicg8yi0wpz1x1bvqqrbvr3kwldxyj";
+  })
+  ];
+
+  postPatch = ''
+    rm cuneiform_src/Kern/hhh/tigerh/h/strings.h
+  '';
+
+  buildInputs = [ imagemagick ];
+
+  nativeBuildInputs = [ cmake ];
+
+  meta = with stdenv.lib; {
+    description = "Multi-language OCR system";
+    homepage = https://launchpad.net/cuneiform-linux;
+    license = licenses.bsd3;
+    platforms = platforms.linux;
+    maintainers = [ maintainers.raskin ];
+  };
+}
diff --git a/nixpkgs/pkgs/tools/graphics/cuneiform/default.upstream b/nixpkgs/pkgs/tools/graphics/cuneiform/default.upstream
new file mode 100644
index 000000000000..4fb85a2a1e89
--- /dev/null
+++ b/nixpkgs/pkgs/tools/graphics/cuneiform/default.upstream
@@ -0,0 +1,8 @@
+url https://launchpad.net/cuneiform-linux/+download
+
+do_overwrite () {
+  ensure_hash
+  set_var_value version "$CURRENT_VERSION"
+  set_var_value sha256 "$CURRENT_HASH"
+  set_var_value ' url' "$CURRENT_URL"
+}
diff --git a/nixpkgs/pkgs/tools/graphics/dcraw/default.nix b/nixpkgs/pkgs/tools/graphics/dcraw/default.nix
new file mode 100644
index 000000000000..e4ceff36f92a
--- /dev/null
+++ b/nixpkgs/pkgs/tools/graphics/dcraw/default.nix
@@ -0,0 +1,32 @@
+{stdenv, fetchurl, libjpeg, lcms2, gettext, jasper, libiconv }:
+
+stdenv.mkDerivation rec {
+  name = "dcraw-9.28.0";
+
+  src = fetchurl {
+    url = "https://www.cybercom.net/~dcoffin/dcraw/archive/${name}.tar.gz";
+    sha256 = "1fdl3xa1fbm71xzc3760rsjkvf0x5jdjrvdzyg2l9ka24vdc7418";
+  };
+
+  nativeBuildInputs = stdenv.lib.optional stdenv.isDarwin libiconv;
+  buildInputs = [ libjpeg lcms2 gettext jasper ];
+
+  patchPhase = ''
+    substituteInPlace install \
+      --replace 'prefix=/usr/local' 'prefix=$out' \
+      --replace gcc '$CC'
+  '';
+
+  buildPhase = ''
+    mkdir -p $out/bin
+    sh -e install
+  '';
+
+  meta = {
+    homepage = http://www.cybercom.net/~dcoffin/dcraw/;
+    description = "Decoder for many camera raw picture formats";
+    license = stdenv.lib.licenses.free;
+    platforms = stdenv.lib.platforms.unix; # Once had cygwin problems
+    maintainers = [ ];
+  };
+}
diff --git a/nixpkgs/pkgs/tools/graphics/diagrams-builder/default.nix b/nixpkgs/pkgs/tools/graphics/diagrams-builder/default.nix
new file mode 100644
index 000000000000..a12e5dbb8bb3
--- /dev/null
+++ b/nixpkgs/pkgs/tools/graphics/diagrams-builder/default.nix
@@ -0,0 +1,44 @@
+/*
+  If user need access to more haskell package for building his
+  diagrams, he simply has to pass these package through the
+  extra packages function as follow in `config.nix`:
+  
+  ~~~
+  diagrams-builder.override {
+    extraPackages = self : [myHaskellPackage];
+  }
+  ­~~~
+*/
+
+{ stdenv, ghcWithPackages, makeWrapper, diagrams-builder, extraPackages ? (self: []) }:
+
+let
+
+  # Used same technique as for the yiCustom package.
+  wrappedGhc = ghcWithPackages 
+    (self: [ diagrams-builder ] ++ extraPackages self);
+  ghcVersion = wrappedGhc.version;
+
+  exeWrapper = backend : ''
+    makeWrapper \
+    "${diagrams-builder}/bin/diagrams-builder-${backend}" "$out/bin/diagrams-builder-${backend}" \
+      --set NIX_GHC ${wrappedGhc}/bin/ghc \
+      --set NIX_GHC_LIBDIR ${wrappedGhc}/lib/ghc-${ghcVersion}
+  '';
+  
+  backends = ["svg" "cairo" "ps"];
+
+in
+
+stdenv.mkDerivation {
+  name = "diagrams-builder";
+
+  buildInputs = [ makeWrapper ];
+
+  buildCommand = with stdenv.lib; 
+    concatStrings (intersperse "\n" (map exeWrapper backends));
+
+  # Will be faster to build the wrapper locally then to fetch it from a binary cache.
+  preferLocalBuild = true;
+  meta = diagrams-builder.meta;
+}
\ No newline at end of file
diff --git a/nixpkgs/pkgs/tools/graphics/ditaa/default.nix b/nixpkgs/pkgs/tools/graphics/ditaa/default.nix
new file mode 100644
index 000000000000..c8c330d80e5b
--- /dev/null
+++ b/nixpkgs/pkgs/tools/graphics/ditaa/default.nix
@@ -0,0 +1,34 @@
+{ stdenv, fetchurl, jre }:
+
+stdenv.mkDerivation rec {
+  name = "ditaa-0.11.0";
+
+  src = fetchurl {
+    url = https://github.com/stathissideris/ditaa/releases/download/v0.11.0/ditaa-0.11.0-standalone.jar;
+    sha256 = "1acnl7khz8aasg230nbsx9dyf8716scgb5l3679cb2bdzxisl64l";
+  };
+
+  phases = [ "installPhase" ];
+
+  installPhase = ''
+    mkdir -p "$out/bin"
+    mkdir -p "$out/lib"
+
+    cp ${src} "$out/lib/ditaa.jar"
+
+    cat > "$out/bin/ditaa" << EOF
+    #!${stdenv.shell}
+    exec ${jre}/bin/java -jar "$out/lib/ditaa.jar" "\$@"
+    EOF
+
+    chmod a+x "$out/bin/ditaa"
+  '';
+
+  meta = with stdenv.lib; {
+    description = "Convert ascii art diagrams into proper bitmap graphics";
+    homepage = https://github.com/stathissideris/ditaa;
+    license = licenses.lgpl3;
+    platforms = platforms.unix;
+    maintainers = [ maintainers.bjornfor ];
+  };
+}
diff --git a/nixpkgs/pkgs/tools/graphics/dmtx-utils/default.nix b/nixpkgs/pkgs/tools/graphics/dmtx-utils/default.nix
new file mode 100644
index 000000000000..bb816e489404
--- /dev/null
+++ b/nixpkgs/pkgs/tools/graphics/dmtx-utils/default.nix
@@ -0,0 +1,30 @@
+{stdenv, fetchurl, libdmtx, pkgconfig, imagemagick}:
+let
+  s = # Generated upstream information
+  rec {
+    baseName="dmtx-utils";
+    version="0.7.4";
+    name="${baseName}-${version}";
+    hash="1di8ymlziy9856abd6rb72z0zqzmrff4r3vql0q9r5sk5ax4s417";
+    url="mirror://sourceforge/project/libdmtx/libdmtx/0.7.4/dmtx-utils-0.7.4.tar.gz";
+    sha256="1di8ymlziy9856abd6rb72z0zqzmrff4r3vql0q9r5sk5ax4s417";
+  };
+  nativeBuildInputs = [ pkgconfig ];
+  buildInputs = [
+    libdmtx imagemagick
+  ];
+in
+stdenv.mkDerivation {
+  inherit (s) name version;
+  inherit nativeBuildInputs buildInputs;
+  src = fetchurl {
+    inherit (s) url sha256;
+  };
+  meta = {
+    inherit (s) version;
+    description = "Data matrix command-line utilities";
+    license = stdenv.lib.licenses.lgpl2 ;
+    maintainers = [stdenv.lib.maintainers.raskin];
+    platforms = stdenv.lib.platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/tools/graphics/dmtx-utils/default.upstream b/nixpkgs/pkgs/tools/graphics/dmtx-utils/default.upstream
new file mode 100644
index 000000000000..2bb7fe31bf7c
--- /dev/null
+++ b/nixpkgs/pkgs/tools/graphics/dmtx-utils/default.upstream
@@ -0,0 +1,4 @@
+url https://sourceforge.net/projects/libdmtx/files/libdmtx/
+SF_version_dir
+version_link 'dmtx-utils-.*[.]tar[.][a-z0-9]+/download$'
+SF_redirect
diff --git a/nixpkgs/pkgs/tools/graphics/dpic/default.nix b/nixpkgs/pkgs/tools/graphics/dpic/default.nix
new file mode 100644
index 000000000000..33e948663372
--- /dev/null
+++ b/nixpkgs/pkgs/tools/graphics/dpic/default.nix
@@ -0,0 +1,29 @@
+{ stdenv, fetchurl }:
+
+stdenv.mkDerivation rec {
+  name = "dpic-${version}";
+  version = "2016.01.12";
+
+  src = fetchurl {
+    url = "https://ece.uwaterloo.ca/~aplevich/dpic/${name}.tar.gz";
+    sha256 = "0iwwf8shgm8n4drz8mndvk7jga93yy8plnyby3lgk8376g5ps6cz";
+  };
+
+  phases = [ "unpackPhase" "buildPhase" "installPhase" ];
+
+  makeFlags = "CC=${stdenv.cc.outPath}/bin/cc";
+
+  installPhase = ''
+    mkdir -p $out/bin
+    cp -fv dpic $out/bin
+  '';
+
+  meta = {
+    homepage = https://ece.uwaterloo.ca/~aplevich/dpic/;
+    description = "An implementation of the pic little language for creating drawings";
+    license = stdenv.lib.licenses.bsd2;
+    maintainers = [ stdenv.lib.maintainers.aespinosa ];
+    platforms = stdenv.lib.platforms.all;
+  };
+}
+
diff --git a/nixpkgs/pkgs/tools/graphics/editres/default.nix b/nixpkgs/pkgs/tools/graphics/editres/default.nix
new file mode 100644
index 000000000000..cb83e02689cf
--- /dev/null
+++ b/nixpkgs/pkgs/tools/graphics/editres/default.nix
@@ -0,0 +1,24 @@
+{ stdenv, fetchurl, pkgconfig, libXt, libXaw, libXres, utilmacros }:
+
+stdenv.mkDerivation rec {
+  name = "editres-1.0.7";
+
+  src = fetchurl {
+    url = "mirror://xorg/individual/app/${name}.tar.gz";
+    sha256 = "10mbgijb6ac6wqb2grpy9mrazzw68jxjkxr9cbdf1111pa64yj19";
+  };
+
+  nativeBuildInputs = [ pkgconfig ];
+  buildInputs = [ libXt libXaw libXres utilmacros ];
+
+  configureFlags = [ "--with-appdefaultdir=$(out)/share/X11/app-defaults/editres" ];
+
+  hardeningDisable = [ "format" ];
+
+  meta = with stdenv.lib; {
+    homepage = https://cgit.freedesktop.org/xorg/app/editres/;
+    description = "A dynamic resource editor for X Toolkit applications";
+    license = licenses.mit;
+    platforms = platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/tools/graphics/enblend-enfuse/default.nix b/nixpkgs/pkgs/tools/graphics/enblend-enfuse/default.nix
new file mode 100644
index 000000000000..2ffe4eb7f809
--- /dev/null
+++ b/nixpkgs/pkgs/tools/graphics/enblend-enfuse/default.nix
@@ -0,0 +1,30 @@
+{ stdenv, fetchurl
+, boost, freeglut, glew, gsl, lcms2, libpng, libtiff, libGLU_combined, vigra
+, help2man, pkgconfig, perl, texlive }:
+
+stdenv.mkDerivation rec {
+  name = "enblend-enfuse-${version}";
+  version = "4.2";
+
+  src = fetchurl {
+    url = "mirror://sourceforge/enblend/${name}.tar.gz";
+    sha256 = "0j5x011ilalb47ssah50ag0a4phgh1b0wdgxdbbp1gcyjcjf60w7";
+  };
+
+  buildInputs = [ boost freeglut glew gsl lcms2 libpng libtiff libGLU_combined vigra ];
+
+  nativeBuildInputs = [ help2man perl pkgconfig texlive.combined.scheme-small ];
+
+  preConfigure = ''
+    patchShebangs src/embrace
+  '';
+
+  enableParallelBuilding = true;
+
+  meta = with stdenv.lib; {
+    homepage = http://enblend.sourceforge.net/;
+    description = "Blends away the seams in a panoramic image mosaic using a multiresolution spline";
+    license = licenses.gpl2;
+    platforms = with platforms; linux;
+  };
+}
diff --git a/nixpkgs/pkgs/tools/graphics/eplot/default.nix b/nixpkgs/pkgs/tools/graphics/eplot/default.nix
new file mode 100644
index 000000000000..a98a5e0aaece
--- /dev/null
+++ b/nixpkgs/pkgs/tools/graphics/eplot/default.nix
@@ -0,0 +1,47 @@
+{ stdenv, fetchurl, gnuplot, ruby }:
+
+stdenv.mkDerivation rec {
+  name = "eplot-2.07";
+
+  # Upstream has been contacted (2015-03) regarding providing versioned
+  # download URLs. Initial response was positive, but no action yet.
+  src = fetchurl {
+    url = "http://liris.cnrs.fr/christian.wolf/software/eplot/download/eplot";
+    sha256 = "0y9x82i3sfpgxsqz2w42r6iad6ph7vxb7np1xbwapx5iipciclw5";
+  };
+
+  ecSrc = fetchurl {
+    url = "http://liris.cnrs.fr/christian.wolf/software/eplot/download/ec";
+    sha256 = "0fg31g8mrcx14h2rjcf091cbd924n19z55iscaiflspifya30yhd";
+  };
+
+  buildInputs = [ ruby ];
+
+  unpackPhase = "true";
+
+  installPhase = ''
+    mkdir -p "$out/bin"
+    cp "$src" "$out/bin/eplot"
+    cp "$ecSrc" "$out/bin/ec"
+    chmod +x "$out/bin/"*
+
+    sed -i -e "s|gnuplot -persist|${gnuplot}/bin/gnuplot -persist|" "$out/bin/eplot"
+  '';
+
+  meta = with stdenv.lib; {
+    description = "Create plots quickly with gnuplot";
+    longDescription = ''
+      eplot ("easy gnuplot") is a ruby script which allows to pipe data easily
+      through gnuplot and create plots quickly, which can be saved in
+      postscript, PDF, PNG or EMF files. Plotting of multiple files into a
+      single diagram is supported.
+
+      This package also includes the complementary 'ec' tool (say "extract
+      column").
+    '';
+    homepage = http://liris.cnrs.fr/christian.wolf/software/eplot/;
+    license = licenses.gpl2Plus;
+    platforms = platforms.all;
+    maintainers = [ maintainers.bjornfor ];
+  };
+}
diff --git a/nixpkgs/pkgs/tools/graphics/epstool/default.nix b/nixpkgs/pkgs/tools/graphics/epstool/default.nix
new file mode 100644
index 000000000000..9735adca53dc
--- /dev/null
+++ b/nixpkgs/pkgs/tools/graphics/epstool/default.nix
@@ -0,0 +1,25 @@
+{ stdenv, fetchurl }:
+
+stdenv.mkDerivation rec {
+  version = "3.08";
+  name = "epstool-${version}";
+
+  src = fetchurl {
+    url = "http://ftp.de.debian.org/debian/pool/main/e/epstool/epstool_${version}+repack.orig.tar.gz";
+    sha256 = "1pfgqbipwk36clhma2k365jkpvyy75ahswn8jczzys382jalpwgk";
+  };
+
+  installPhase = ''
+    make EPSTOOL_ROOT=$out install
+  '';
+
+  patches = [ ./gcc43.patch ];
+
+  meta = with stdenv.lib; {
+    description = "A utility to create or extract preview images in EPS files, fix bounding boxes and convert to bitmaps";
+    homepage = http://pages.cs.wisc.edu/~ghost/gsview/epstool.htm;
+    license = licenses.gpl2;
+    maintainers = [ maintainers.asppsa ];
+    platforms = platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/tools/graphics/epstool/gcc43.patch b/nixpkgs/pkgs/tools/graphics/epstool/gcc43.patch
new file mode 100644
index 000000000000..398ce08c5182
--- /dev/null
+++ b/nixpkgs/pkgs/tools/graphics/epstool/gcc43.patch
@@ -0,0 +1,20 @@
+--- epstool-3.08.orig/src/epstool.c	2005-06-10 04:41:00.000000000 -0500
++++ epstool-3.08/src/epstool.c	2009-02-16 20:55:43.186140029 -0600
+@@ -2824,7 +2824,7 @@
+ 		code = -1;
+ 	}
+ 	if ((code==0) && stdout_name && (hChildStdoutWr == -1)) {
+-	    handle = open(stdout_name, O_WRONLY | O_CREAT);
++	    handle = open(stdout_name, O_WRONLY | O_CREAT, 0644);
+ 	    hChildStdoutWr = dup2(handle, 1);
+ 	    if (handle != -1)
+ 		close(handle);
+@@ -2832,7 +2832,7 @@
+ 		code = -1;
+ 	}
+ 	if ((code==0) && stderr_name && (hChildStderrWr == -1)) {
+-	    handle = open(stderr_name, O_WRONLY | O_CREAT);
++	    handle = open(stderr_name, O_WRONLY | O_CREAT, 0644);
+ 	    hChildStderrWr = dup2(handle, 2);
+ 	    if (handle != -1)
+ 		close(handle);
diff --git a/nixpkgs/pkgs/tools/graphics/escrotum/default.nix b/nixpkgs/pkgs/tools/graphics/escrotum/default.nix
new file mode 100644
index 000000000000..2a4f3c9cbff7
--- /dev/null
+++ b/nixpkgs/pkgs/tools/graphics/escrotum/default.nix
@@ -0,0 +1,25 @@
+{ lib, fetchFromGitHub, buildPythonApplication
+, pygtk
+, numpy ? null
+}:
+
+buildPythonApplication {
+  name = "escrotum-2017-01-28";
+
+  src = fetchFromGitHub {
+    owner  = "Roger";
+    repo   = "escrotum";
+    rev    = "a51e330f976c1c9e1ac6932c04c41381722d2171";
+    sha256 = "0vbpyihqgm0fyh22ashy4lhsrk67n31nw3bs14d1wr7ky0l3rdnj";
+  };
+
+  propagatedBuildInputs = [ pygtk numpy ];
+
+  meta = with lib; {
+    homepage = https://github.com/Roger/escrotum;
+    description = "Linux screen capture using pygtk, inspired by scrot";
+    platforms = platforms.linux;
+    maintainers = with maintainers; [ rasendubi ];
+    license = licenses.gpl3;
+  };
+}
diff --git a/nixpkgs/pkgs/tools/graphics/exif/default.nix b/nixpkgs/pkgs/tools/graphics/exif/default.nix
new file mode 100644
index 000000000000..83fec1287a6b
--- /dev/null
+++ b/nixpkgs/pkgs/tools/graphics/exif/default.nix
@@ -0,0 +1,20 @@
+{ stdenv, fetchurl, pkgconfig, libexif, popt, libintl }:
+
+stdenv.mkDerivation rec {
+  name = "exif-0.6.21";
+
+  src = fetchurl {
+    url = "mirror://sourceforge/libexif/${name}.tar.bz2";
+    sha256 = "1zb9hwdl783d4vd2s2rw642hg8hd6n0mfp6lrbiqmp9jmhlq5rsr";
+  };
+
+  nativeBuildInputs = [ pkgconfig ];
+  buildInputs = [ libexif popt libintl ];
+
+  meta = with stdenv.lib; {
+    homepage = https://libexif.github.io;
+    description = "A utility to read and manipulate EXIF data in digital photographs";
+    platforms = platforms.unix;
+    license = licenses.lgpl21;
+  };
+}
diff --git a/nixpkgs/pkgs/tools/graphics/exiftags/default.nix b/nixpkgs/pkgs/tools/graphics/exiftags/default.nix
new file mode 100644
index 000000000000..9ce95154cb0b
--- /dev/null
+++ b/nixpkgs/pkgs/tools/graphics/exiftags/default.nix
@@ -0,0 +1,26 @@
+{stdenv, fetchurl}:
+
+stdenv.mkDerivation {
+  name = "exiftags-1.01";
+
+  src = fetchurl {
+    url = https://johnst.org/sw/exiftags/exiftags-1.01.tar.gz;
+    sha256 = "194ifl6hybx2a5x8jhlh9i56k3qfc6p2l72z0ii1b7v0bzg48myr";
+  };
+
+  patchPhase = ''
+    sed -i -e s@/usr/local@$out@ Makefile
+  '';
+
+  preInstall = ''
+    mkdir -p $out/bin $out/man/man1
+  '';
+
+  meta = {
+    homepage = http://johnst.org/sw/exiftags/;
+    description = "Displays EXIF data from JPEG files";
+    license = stdenv.lib.licenses.free;
+    maintainers = with stdenv.lib.maintainers; [viric];
+    platforms = with stdenv.lib.platforms; unix;
+  };
+}
diff --git a/nixpkgs/pkgs/tools/graphics/facedetect/default.nix b/nixpkgs/pkgs/tools/graphics/facedetect/default.nix
new file mode 100644
index 000000000000..02a3a70fe516
--- /dev/null
+++ b/nixpkgs/pkgs/tools/graphics/facedetect/default.nix
@@ -0,0 +1,37 @@
+{ stdenv, fetchFromGitHub, python2Packages }:
+
+stdenv.mkDerivation rec {
+  name = "facedetect-${version}";
+  version = "0.1";
+
+  src = fetchFromGitHub {
+    owner = "wavexx";
+    repo = "facedetect";
+    rev = "v${version}";
+    sha256 = "0mddh71cjbsngpvjli406ndi2x613y39ydgb8bi4z1jp063865sd";
+  };
+
+  buildInputs = [ python2Packages.python python2Packages.wrapPython ];
+  pythonPath = [ python2Packages.numpy python2Packages.opencv ];
+
+  phases = [ "unpackPhase" "patchPhase" "installPhase" ];
+
+  patchPhase = ''
+    substituteInPlace facedetect \
+      --replace /usr/share/opencv "${python2Packages.opencv}/share/OpenCV"
+  '';
+
+  installPhase = ''
+    install -v -m644 -D README.rst $out/share/doc/${name}/README.rst
+    install -v -m755 -D facedetect $out/bin/facedetect
+    wrapPythonPrograms
+  '';
+
+  meta = with stdenv.lib; {
+    homepage = https://www.thregr.org/~wavexx/software/facedetect/;
+    description = "A simple face detector for batch processing";
+    license = licenses.gpl2Plus;
+    platforms = platforms.all;
+    maintainers = [ maintainers.rycee ];
+  };
+}
diff --git a/nixpkgs/pkgs/tools/graphics/fast-neural-doodle/default.nix b/nixpkgs/pkgs/tools/graphics/fast-neural-doodle/default.nix
new file mode 100644
index 000000000000..5d42482b3091
--- /dev/null
+++ b/nixpkgs/pkgs/tools/graphics/fast-neural-doodle/default.nix
@@ -0,0 +1,63 @@
+{stdenv, fetchFromGitHub, fetchurl, torch, torch-hdf5, loadcaffe, bash
+  , python, numpy, scipy, h5py, scikitlearn, pillow
+  }:
+stdenv.mkDerivation rec {
+  name = "fast-neural-doodle-${version}";
+  version = "0.0pre2016-07-01";
+  buildInputs = [
+    torch torch-hdf5 python numpy h5py scikitlearn scipy pillow
+  ];
+
+  inherit torch loadcaffe bash python;
+  torch_hdf5 = torch-hdf5;
+  python_libPrefix = python.libPrefix;
+
+  src = fetchFromGitHub {
+    owner = "DmitryUlyanov";
+    repo = "fast-neural-doodle";
+    rev = "00c35a4440d1d58b029d7bdf9bc56743b1a1835f";
+    sha256 = "0xhmhxhjm59pfjm2q27g2xfb35hg0vlqkk3sb3llx2qqq2c7jk8m";
+  };
+  models = [
+    (fetchurl {
+      url = "https://gist.githubusercontent.com/ksimonyan/3785162f95cd2d5fee77/raw/bb2b4fe0a9bb0669211cf3d0bc949dfdda173e9e/VGG_ILSVRC_19_layers_deploy.prototxt";
+      sha256 = "09cpz7pyvc8sypg2q5j2i8yqwj1sjdbnmd6skl293p9pv13dmjg7";
+    })
+    (fetchurl {
+      url = "https://bethgelab.org/media/uploads/deeptextures/vgg_normalised.caffemodel";
+      sha256 = "11qckdvlck7wwl3pan0nawgxm8l2ccddi272i5l8rs9qzm7b23rf";
+    })
+    (fetchurl {
+      url = "http://www.robots.ox.ac.uk/~vgg/software/very_deep/caffe/VGG_ILSVRC_19_layers.caffemodel";
+      sha256 = "0m399x7pl4lnhy435ycsyz8xpzapqmx9n1sz698y2vhcqhkwdd1i";
+    })
+  ];
+  installPhase = ''
+    mkdir -p "$out"/{doc/fast-neural-doodle,lib/lua/fast_neural_doodle,lib/${python.libPrefix}/fast_neural_doodle,bin}
+    cp -r data src fast_neural_doodle.lua "$out/lib/lua/fast_neural_doodle/"
+    for file in $models; do
+      ln -s "$file" "$out/lib/lua/fast_neural_doodle/data/pretrained/$(basename "$file" | sed -e 's/[^-]*-//')"
+    done;
+    cp get_mask_hdf5.py "$out/lib/${python.libPrefix}/fast_neural_doodle"
+    cp *.md LICENSE "$out/doc/fast-neural-doodle"
+
+    export pythonpath="$PYTHONPATH"
+
+    substituteAll "${./get-mask-hdf5.sh}" "$out/bin/get-mask-hdf5"
+    substituteAll "${./fast-neural-doodle.sh}" "$out/bin/fast-neural-doodle"
+
+    chmod a+x "$out/bin"/*
+
+    "$out/bin/get-mask-hdf5" --n_colors=4 --style_image data/Renoir/style.png --style_mask data/Renoir/style_mask.png --target_mask data/Renoir/target_mask.png --out_hdf5 masks.hdf5
+
+    "$out/bin/fast-neural-doodle" -gpu -1 -masks_hdf5 masks.hdf5 -num_iterations 1
+  '';
+  meta = {
+    inherit version;
+    description = ''Faster neural doodle'';
+    license = stdenv.lib.licenses.mit;
+    maintainers = [stdenv.lib.maintainers.raskin];
+    platforms = stdenv.lib.platforms.linux;
+    broken = true;
+  };
+}
diff --git a/nixpkgs/pkgs/tools/graphics/fast-neural-doodle/fast-neural-doodle.sh b/nixpkgs/pkgs/tools/graphics/fast-neural-doodle/fast-neural-doodle.sh
new file mode 100644
index 000000000000..a089d5a95061
--- /dev/null
+++ b/nixpkgs/pkgs/tools/graphics/fast-neural-doodle/fast-neural-doodle.sh
@@ -0,0 +1,28 @@
+#! @bash@/bin/bash
+
+declare -a args
+c=1
+flag=
+
+for arg in "$@"; do
+        if test "$arg" = "${arg#-}" && test "$arg" = "${arg#/}" && test -n "$flag"; then
+                arg="$PWD/$arg"
+                flag=
+        elif (test "$arg" != "${arg%_image}" || test "$arg" == "-masks_hdf5") && test "$arg" != "${arg#-}"; then
+                flag=1
+        else
+                flag=
+        fi
+        args[c]="$arg";
+        c=$((c+1));
+done
+
+cd "@out@/lib/lua/fast_neural_doodle"
+
+export LUA_PATH="$LUA_PATH${LUA_PATH:+;}@loadcaffe@/lua/?/init.lua;@loadcaffe@/lua/?.lua"
+export LUA_PATH="$LUA_PATH${LUA_PATH:+;}@torch_hdf5@/lua/?/init.lua;@torch_hdf5@/lua/?.lua"
+export LUA_CPATH="$LUA_CPATH${LUA_CPATH:+;}@loadcaffe@/lib/?.so"
+
+set -x
+
+@torch@/bin/th fast_neural_doodle.lua "${args[@]}"
diff --git a/nixpkgs/pkgs/tools/graphics/fast-neural-doodle/get-mask-hdf5.sh b/nixpkgs/pkgs/tools/graphics/fast-neural-doodle/get-mask-hdf5.sh
new file mode 100644
index 000000000000..cfff76d141fb
--- /dev/null
+++ b/nixpkgs/pkgs/tools/graphics/fast-neural-doodle/get-mask-hdf5.sh
@@ -0,0 +1,5 @@
+#! @bash@/bin/bash
+
+export PYTHONPATH="@pythonpath@"
+
+@python@/bin/python "@out@/lib/@python_libPrefix@/fast_neural_doodle/get_mask_hdf5.py" "$@"
diff --git a/nixpkgs/pkgs/tools/graphics/fbv/default.nix b/nixpkgs/pkgs/tools/graphics/fbv/default.nix
new file mode 100644
index 000000000000..c7fab1710672
--- /dev/null
+++ b/nixpkgs/pkgs/tools/graphics/fbv/default.nix
@@ -0,0 +1,25 @@
+{ stdenv, fetchurl, getopt, libjpeg, libpng12, libungif }:
+
+stdenv.mkDerivation rec {
+  name = "fbv-1.0b";
+
+  src = fetchurl {
+    url = "http://s-tech.elsat.net.pl/fbv/${name}.tar.gz";
+    sha256 = "0g5b550vk11l639y8p5sx1v1i6ihgqk0x1hd0ri1bc2yzpdbjmcv";
+  };
+
+  buildInputs = [ getopt libjpeg libpng12 libungif ];
+
+  enableParallelBuilding = true;
+
+  preInstall = ''
+    mkdir -p $out/{bin,man/man1}
+  '';
+
+  meta = with stdenv.lib; {
+    description = "View pictures on a linux framebuffer device";
+    homepage = http://s-tech.elsat.net.pl/fbv/;
+    license = licenses.gpl2;
+    maintainers = with maintainers; [ peterhoeg ];
+  };
+}
diff --git a/nixpkgs/pkgs/tools/graphics/feedgnuplot/default.nix b/nixpkgs/pkgs/tools/graphics/feedgnuplot/default.nix
new file mode 100644
index 000000000000..4ff769eadf54
--- /dev/null
+++ b/nixpkgs/pkgs/tools/graphics/feedgnuplot/default.nix
@@ -0,0 +1,56 @@
+{ stdenv, fetchFromGitHub, makeWrapper, gawk
+, makeFontsConf, freefont_ttf, gnuplot, perl, perlPackages
+}:
+
+let
+
+  fontsConf = makeFontsConf { fontDirectories = [ freefont_ttf ]; };
+
+in
+
+perlPackages.buildPerlPackage rec {
+  name = "feedgnuplot-${version}";
+  version = "1.51";
+
+  src = fetchFromGitHub {
+    owner = "dkogan";
+    repo = "feedgnuplot";
+    rev = "v${version}";
+    sha256 = "0npk2l032cnmibjj5zf3ii09mpxciqn32lx6g5bal91bkxwn7r5i";
+  };
+
+  outputs = [ "out" ];
+
+  nativeBuildInputs = [ makeWrapper gawk ];
+
+  buildInputs = [ gnuplot perl ]
+    ++ (with perlPackages; [ ListMoreUtils IPCRun StringShellQuote ]);
+
+  # Fontconfig error: Cannot load default config file
+  FONTCONFIG_FILE = fontsConf;
+
+  postPatch = ''
+    patchShebangs .
+  '';
+
+  # Tests require gnuplot 4.6.4 and are completely skipped with gnuplot 5.
+  doCheck = false;
+
+  postInstall = ''
+    wrapProgram $out/bin/feedgnuplot \
+        --prefix "PATH" ":" "$PATH" \
+        --prefix "PERL5LIB" ":" "$PERL5LIB"
+    install -D -m 444 -t $out/share/bash-completion/completions \
+        completions/bash/feedgnuplot
+    install -D -m 444 -t $out/share/zsh/site-functions \
+        completions/zsh/_feedgnuplot
+  '';
+
+  meta = with stdenv.lib; {
+    description = "General purpose pipe-oriented plotting tool";
+    homepage = https://github.com/dkogan/feedgnuplot/;
+    license = with licenses; [ artistic1 gpl1Plus ];
+    platforms = platforms.unix;
+    maintainers = with maintainers; [ mnacamura ];
+  };
+}
diff --git a/nixpkgs/pkgs/tools/graphics/fgallery/default.nix b/nixpkgs/pkgs/tools/graphics/fgallery/default.nix
new file mode 100644
index 000000000000..a7bb616d82b5
--- /dev/null
+++ b/nixpkgs/pkgs/tools/graphics/fgallery/default.nix
@@ -0,0 +1,46 @@
+{ stdenv, fetchurl, unzip, makeWrapper, perl, ImageExifTool
+, CpanelJSONXS, coreutils, zip, imagemagick, pngcrush, lcms2
+, facedetect, fbida }:
+
+# TODO: add optional dependencies (snippet from fgallery source):
+#
+# if(system("jpegoptim -V >/dev/null 2>&1")) {
+#   $jpegoptim = 0;
+# }
+
+stdenv.mkDerivation rec {
+  name = "fgallery-1.8.2";
+
+  src = fetchurl {
+    url = "https://www.thregr.org/~wavexx/software/fgallery/releases/${name}.zip";
+    sha256 = "18wlvqbxcng8pawimbc8f2422s8fnk840hfr6946lzsxr0ijakvf";
+  };
+
+  buildInputs = [ unzip makeWrapper perl ImageExifTool CpanelJSONXS ];
+
+  installPhase = ''
+    mkdir -p "$out/bin"
+    mkdir -p "$out/share/fgallery"
+
+    cp -r * "$out/share/fgallery"
+    ln -s -r "$out/share/fgallery/fgallery" "$out/bin/fgallery"
+
+    # Don't preserve file attributes when copying files to output directories.
+    # (fgallery copies parts of itself to each output directory, and without
+    # this change the read-only nix store causes some bumps in the workflow.)
+    sed -i -e "s|'cp'|'cp', '--no-preserve=all'|g" "$out/share/fgallery/fgallery"
+
+    wrapProgram "$out/share/fgallery/fgallery" \
+        --set PERL5LIB "$PERL5LIB" \
+        --set PATH "${stdenv.lib.makeBinPath
+                     [ coreutils zip imagemagick pngcrush lcms2 facedetect fbida ]}"
+  '';
+
+  meta = with stdenv.lib; {
+    description = "Static photo gallery generator";
+    homepage = http://www.thregr.org/~wavexx/software/fgallery/;
+    license = licenses.gpl2;
+    platforms = platforms.all;
+    maintainers = [ maintainers.bjornfor ];
+  };
+}
diff --git a/nixpkgs/pkgs/tools/graphics/fim/default.nix b/nixpkgs/pkgs/tools/graphics/fim/default.nix
new file mode 100644
index 000000000000..7303f27fe111
--- /dev/null
+++ b/nixpkgs/pkgs/tools/graphics/fim/default.nix
@@ -0,0 +1,52 @@
+{ stdenv, fetchurl, autoconf, automake, pkgconfig
+, perl, flex, bison, readline, libexif
+, x11Support ? true, SDL
+, svgSupport ? true, inkscape
+, asciiArtSupport ? true, aalib
+, gifSupport ? true, giflib
+, tiffSupport ? true, libtiff
+, jpegSupport ? true, libjpeg
+, pngSupport ? true, libpng
+}:
+
+stdenv.mkDerivation rec {
+  name = "fim-${version}";
+  version = "0.6";
+
+  src = fetchurl {
+    url = "mirror://savannah/fbi-improved/${name}-trunk.tar.gz";
+    sha256 = "124b7c4flx5ygmy5sqq0gpvxqzafnknbcj6f45ddnbdxik9lazzp";
+  };
+
+  postPatch = ''
+   substituteInPlace doc/vim2html.pl \
+     --replace /usr/bin/perl ${perl}/bin/perl
+  '';
+
+  nativeBuildInputs = [ autoconf automake pkgconfig ];
+
+  buildInputs = with stdenv.lib;
+    [ perl flex bison readline libexif ]
+    ++ optional x11Support SDL
+    ++ optional svgSupport inkscape
+    ++ optional asciiArtSupport aalib
+    ++ optional gifSupport giflib
+    ++ optional tiffSupport libtiff
+    ++ optional jpegSupport libjpeg
+    ++ optional pngSupport libpng;
+
+  NIX_CFLAGS_COMPILE = stdenv.lib.optional x11Support "-lSDL";
+
+  meta = with stdenv.lib; {
+    description = "A lightweight, highly customizable and scriptable image viewer";
+    longDescription = ''
+      FIM (Fbi IMproved) is a lightweight, console based image viewer that aims
+      to be a highly customizable and scriptable for users who are comfortable
+      with software like the VIM text editor or the Mutt mail user agent.
+    '';
+    homepage = https://www.nongnu.org/fbi-improved/;
+    license = licenses.gpl2Plus;
+    platforms = platforms.linux;
+    maintainers = with maintainers; [ primeos ];
+  };
+}
diff --git a/nixpkgs/pkgs/tools/graphics/flam3/default.nix b/nixpkgs/pkgs/tools/graphics/flam3/default.nix
new file mode 100644
index 000000000000..e3c9cbf2e69f
--- /dev/null
+++ b/nixpkgs/pkgs/tools/graphics/flam3/default.nix
@@ -0,0 +1,25 @@
+{stdenv, fetchFromGitHub, zlib, libpng, libxml2, libjpeg }:
+
+stdenv.mkDerivation rec {
+  name = "${pname}-${version}";
+  pname = "flam3";
+  version = "3.1.1-${stdenv.lib.strings.substring 0 7 rev}";
+  rev = "e0801543538451234d7a8a240ba3b417cbda5b21";
+
+  src = fetchFromGitHub {
+    inherit rev;
+    owner = "scottdraves";
+    repo = "${pname}";
+    sha256 = "18iyj16k0sn3fs52fj23lj31xi4avlddhbib6kk309576nlxp17w";
+  };
+
+  buildInputs = [ zlib libpng libxml2 libjpeg ];
+
+  meta = with stdenv.lib; {
+    description = "Cosmic recursive fractal flames";
+    homepage = http://flam3.com/;
+    maintainers = [ maintainers.nand0p ];
+    platforms = platforms.linux;
+    license = licenses.cc-by-nc-sa-20;
+  };
+}
diff --git a/nixpkgs/pkgs/tools/graphics/ggobi/default.nix b/nixpkgs/pkgs/tools/graphics/ggobi/default.nix
new file mode 100644
index 000000000000..0ed1855a338c
--- /dev/null
+++ b/nixpkgs/pkgs/tools/graphics/ggobi/default.nix
@@ -0,0 +1,26 @@
+{ stdenv, fetchurl, pkgconfig, libxml2, gtk2 }:
+
+stdenv.mkDerivation rec {
+  version = "2.1.11";
+  name = "ggobi-${version}";
+
+  src = fetchurl {
+    url = "http://www.ggobi.org/downloads/ggobi-${version}.tar.bz2";
+    sha256 = "2c4ddc3ab71877ba184523e47b0637526e6f3701bd9afb6472e6dfc25646aed7";
+  };
+
+  nativeBuildInputs = [ pkgconfig ];
+  buildInputs = [ libxml2 gtk2 ];
+
+  configureFlags = [ "--with-all-plugins" ];
+
+  hardeningDisable = [ "format" ];
+
+  meta = with stdenv.lib; {
+    description = "Visualization program for exploring high-dimensional data";
+    homepage = http://www.ggobi.org/;
+    license = licenses.cpl10;
+    platforms = platforms.linux;
+    maintainers = [ maintainers.michelk ];
+  };
+}
diff --git a/nixpkgs/pkgs/tools/graphics/gifsicle/default.nix b/nixpkgs/pkgs/tools/graphics/gifsicle/default.nix
new file mode 100644
index 000000000000..76cb3ab199c2
--- /dev/null
+++ b/nixpkgs/pkgs/tools/graphics/gifsicle/default.nix
@@ -0,0 +1,33 @@
+{ stdenv, fetchurl, xproto, libXt, libX11, gifview ? false, static ? false }:
+
+with stdenv.lib;
+
+stdenv.mkDerivation rec {
+  name = "gifsicle-${version}";
+  version = "1.91";
+
+  src = fetchurl {
+    url = "https://www.lcdf.org/gifsicle/${name}.tar.gz";
+    sha256 = "00586z1yz86qcblgmf16yly39n4lkjrscl52hvfxqk14m81fckha";
+  };
+
+  buildInputs = optional gifview [ xproto libXt libX11 ];
+
+  configureFlags = []
+    ++ optional (!gifview) [ "--disable-gifview" ];
+
+  LDFLAGS = optional static "-static";
+
+  doCheck = true;
+  checkPhase = ''
+    ./src/gifsicle --info logo.gif
+  '';
+
+  meta = {
+    description = "Command-line tool for creating, editing, and getting information about GIF images and animations";
+    homepage = https://www.lcdf.org/gifsicle/;
+    license = stdenv.lib.licenses.gpl2;
+    platforms = platforms.all;
+    maintainers = with stdenv.lib.maintainers; [ fuuzetsu zimbatm ];
+  };
+}
diff --git a/nixpkgs/pkgs/tools/graphics/glee/default.nix b/nixpkgs/pkgs/tools/graphics/glee/default.nix
new file mode 100644
index 000000000000..52f5a0997274
--- /dev/null
+++ b/nixpkgs/pkgs/tools/graphics/glee/default.nix
@@ -0,0 +1,34 @@
+{stdenv, fetchgit, cmake, libGLU_combined, xorg }:
+
+stdenv.mkDerivation rec {
+  name = "${pname}-${version}";
+  pname = "glee";
+  rev = "f727ec7463d514b6279981d12833f2e11d62b33d";
+  version = "20170205-${stdenv.lib.strings.substring 0 7 rev}";
+
+  src = fetchgit {
+    inherit rev;
+    url = "https://git.code.sf.net/p/${pname}/${pname}";
+    sha256 = "13mf3s7nvmj26vr2wbcg08l4xxqsc1ha41sx3bfghvq8c5qpk2ph";
+  };
+
+  nativeBuildInputs = [ cmake ];
+
+  buildInputs = [ libGLU_combined xorg.libX11 ];
+
+  configureScript = ''
+    cmake
+  '';
+
+  preInstall = ''
+    sed -i 's/readme/Readme/' cmake_install.cmake
+  '';
+
+  meta = with stdenv.lib; {
+    description = "GL Easy Extension Library";
+    homepage = https://sourceforge.net/p/glee/glee/;
+    maintainers = with maintainers; [ nand0p ];
+    platforms = platforms.linux;
+    license = licenses.gpl3;
+  };
+}
diff --git a/nixpkgs/pkgs/tools/graphics/glmark2/default.nix b/nixpkgs/pkgs/tools/graphics/glmark2/default.nix
new file mode 100644
index 000000000000..70821468992b
--- /dev/null
+++ b/nixpkgs/pkgs/tools/graphics/glmark2/default.nix
@@ -0,0 +1,33 @@
+{ stdenv, fetchFromGitHub, pkgconfig, libjpeg, libpng, xorg, libX11, libGL, libdrm,
+  python27, wayland, udev, mesa_noglu, wafHook }:
+
+stdenv.mkDerivation rec {
+  name = "glmark2-${version}";
+  version = "2017-09-01";
+
+  src = fetchFromGitHub {
+    owner = "glmark2";
+    repo = "glmark2";
+    rev = "7265e8e6c77c4f60302507eca0e18560b1117a86";
+    sha256 = "076l75rfl6pnp1wgiwlaihy1vg2advg1z8bi0x84kk259kldgvwn";
+  };
+
+  nativeBuildInputs = [ pkgconfig wafHook ];
+  buildInputs = [
+    libjpeg libpng xorg.libxcb libX11 libGL libdrm python27 wayland udev mesa_noglu
+  ];
+
+  configureFlags = ["--with-flavors=x11-gl,x11-glesv2,drm-gl,drm-glesv2,wayland-gl,wayland-glesv2"];
+
+  meta = with stdenv.lib; {
+    description = "OpenGL (ES) 2.0 benchmark";
+    homepage = https://github.com/glmark2/glmark2;
+    license = licenses.gpl3Plus;
+    longDescription = ''
+      glmark2 is a benchmark for OpenGL (ES) 2.0. It uses only the subset of
+      the OpenGL 2.0 API that is compatible with OpenGL ES 2.0.
+    '';
+    platforms = platforms.linux;
+    maintainers = [ maintainers.wmertens ];
+  };
+}
diff --git a/nixpkgs/pkgs/tools/graphics/glxinfo/default.nix b/nixpkgs/pkgs/tools/graphics/glxinfo/default.nix
new file mode 100644
index 000000000000..6a2a3a5a46e8
--- /dev/null
+++ b/nixpkgs/pkgs/tools/graphics/glxinfo/default.nix
@@ -0,0 +1,34 @@
+{ stdenv, fetchurl, libGL, libX11 }:
+
+stdenv.mkDerivation rec {
+  name = "glxinfo-${version}";
+  version = "8.4.0";
+
+  src = fetchurl {
+    url = "ftp://ftp.freedesktop.org/pub/mesa/demos/mesa-demos-${version}.tar.bz2";
+    sha256 = "0zgzbz55a14hz83gbmm0n9gpjnf5zadzi2kjjvkn6khql2a9rs81";
+  };
+
+  buildInputs = [ libX11 libGL ];
+
+  configurePhase = "true";
+
+  buildPhase = "
+    $CC src/xdemos/{glxinfo.c,glinfo_common.c} -o glxinfo -lGL -lX11
+    $CC src/xdemos/glxgears.c -o glxgears -lGL -lX11 -lm
+    $CC src/egl/opengles2/es2_info.c -o es2_info -lEGL -lGLESv2 -lX11
+    $CC src/egl/opengles2/es2gears.c src/egl/eglut/{eglut.c,eglut_x11.c} -o es2gears -Isrc/egl/eglut -lEGL -lGLESv2 -lX11 -lm
+  ";
+
+  installPhase = "
+    install -Dm 555 -t $out/bin glx{info,gears} es2{_info,gears}
+  ";
+
+  meta = with stdenv.lib; {
+    description = "Test utilities for OpenGL";
+    homepage = https://www.mesa3d.org/;
+    license = licenses.mit;
+    platforms = platforms.linux;
+    maintainers = with maintainers; [ abbradar ];
+  };
+}
diff --git a/nixpkgs/pkgs/tools/graphics/gmic/default.nix b/nixpkgs/pkgs/tools/graphics/gmic/default.nix
new file mode 100644
index 000000000000..51212a3ea946
--- /dev/null
+++ b/nixpkgs/pkgs/tools/graphics/gmic/default.nix
@@ -0,0 +1,47 @@
+{ stdenv, fetchurl, cmake, ninja, pkgconfig
+, opencv, openexr, graphicsmagick, fftw, zlib, libjpeg, libtiff, libpng
+, withGimpPlugin ? true, gimp ? null}:
+
+assert withGimpPlugin -> gimp != null;
+
+let
+  version = "2.2.2";
+
+  # CMakeLists.txt is missing from the tarball and Makefile is terrible
+  CMakeLists = fetchurl {
+    url = "https://github.com/dtschump/gmic/raw/v.${version}/CMakeLists.txt";
+    sha256 = "0lv5jrg98cpbk13fl4xm7l4sk1axfz054q570bpi741w815d7cpg";
+  };
+in stdenv.mkDerivation rec {
+  name = "gmic-${version}";
+
+  outputs = [ "out" "lib" "dev" "man" ] ++ stdenv.lib.optional withGimpPlugin "gimpPlugin";
+
+  src = fetchurl {
+    url = "https://gmic.eu/files/source/gmic_${version}.tar.gz";
+    sha256 = "0zqfj2ym5nn3ff93xh2wf9ayxqlznabbdi00xw4lm7vw3iwkzqnc";
+  };
+
+  nativeBuildInputs = [ cmake ninja pkgconfig ];
+
+  buildInputs = [
+    fftw zlib libjpeg libtiff libpng opencv openexr graphicsmagick
+  ] ++ stdenv.lib.optionals withGimpPlugin [ gimp gimp.gtk ];
+
+  cmakeFlags = [
+    "-DBUILD_LIB_STATIC=OFF"
+    "-DBUILD_PLUGIN=${if withGimpPlugin then "ON" else "OFF"}"
+    "-DENABLE_DYNAMIC_LINKING=ON"
+  ] ++ stdenv.lib.optional withGimpPlugin "-DPLUGIN_INSTALL_PREFIX=${placeholder "gimpPlugin"}/${gimp.targetPluginDir}";
+
+  postPatch = ''
+    cp ${CMakeLists} CMakeLists.txt
+  '';
+
+  meta = with stdenv.lib; {
+    description = "G'MIC is an open and full-featured framework for image processing";
+    homepage = http://gmic.eu/;
+    license = licenses.cecill20;
+    platforms = platforms.unix;
+  };
+}
diff --git a/nixpkgs/pkgs/tools/graphics/gmic_krita_qt/default.nix b/nixpkgs/pkgs/tools/graphics/gmic_krita_qt/default.nix
new file mode 100644
index 000000000000..14d47dc30bd8
--- /dev/null
+++ b/nixpkgs/pkgs/tools/graphics/gmic_krita_qt/default.nix
@@ -0,0 +1,82 @@
+{ stdenv, fetchurl, fetchFromGitHub, cmake, ninja, pkgconfig
+, opencv, openexr, graphicsmagick, fftw, zlib, libjpeg, libtiff, libpng
+, curl, krita, qtbase, qttools
+, fetchgit }:
+
+let
+  version = "2.3.6";
+
+in stdenv.mkDerivation rec {
+  name = "gmic_krita_qt-${version}";
+
+  gmic-community = fetchFromGitHub {
+    owner = "dtschump";
+    repo = "gmic-community";
+    rev = "3fd528f20a2a7d651e96078c205ff21efb9cdd1a";
+    sha256 = "08d37b49qgh5d4rds7hvr5wjj4p1y8cnbidz1cyqsibq0555pwq2";
+  };
+
+  CImg = fetchgit {
+    url = "https://framagit.org/dtschump/CImg";
+    rev = "90f5657d8eab7b549ef945103ef680e747385805";
+    sha256 = "1af3dwqq18dkw0lz2gvnlw8y0kc1cw01hnc72rf3pg2wyjcp0pvc";
+  };
+
+  gmic_stdlib = fetchurl {
+    name = "gmic_stdlib.h";
+    # Version should e in sync with gmic. Basically the version string without dots
+    url = "http://gmic.eu/gmic_stdlib236.h";
+    sha256 = "0q5g87dsn9byd2qqsa9xrsggfb9qv055s3l2gc0jrcvpx2qbza4q";
+  };
+
+  gmic = fetchFromGitHub {
+    owner = "dtschump";
+    repo = "gmic";
+    rev = "v.${version}";
+    sha256 = "1yg9ri3n07drv8gz4x0mn39ryi801ibl26jaza47m19ma893m8fi";
+  };
+
+  gmic_qt = fetchFromGitHub {
+    owner = "c-koi";
+    repo = "gmic-qt";
+    rev = "v.${version}";
+    sha256= "0j9wqlq67dwzir36yg58xy5lbblwizvgcvlmzcv9d6l901d5ayf3";
+  };
+
+  unpackPhase = ''
+    cp -r ${gmic} gmic
+    ln -s ${gmic-community} gmic-community
+    cp -r ${gmic_qt} gmic_qt
+    chmod -R +w gmic gmic_qt
+    ln -s ${CImg} CImg
+
+    cp ${gmic_stdlib} gmic/src/gmic_stdlib.h
+
+    cd gmic_qt
+  '';
+
+  preConfigure = ''
+    make -C ../gmic/src CImg.h gmic_stdlib.h
+  '';
+
+  nativeBuildInputs = [ cmake pkgconfig ];
+
+  buildInputs = [
+    qtbase qttools fftw zlib libjpeg libtiff libpng
+    opencv openexr graphicsmagick curl krita
+  ];
+
+  cmakeFlags = [ "-DGMIC_QT_HOST=krita" ];
+
+  installPhase = ''
+    mkdir -p $out/bin;
+    install -Dm755 gmic_krita_qt "$out/bin/gmic_krita_qt"
+  '';
+
+  meta = with stdenv.lib; {
+    description = "Krita plugin for the G'MIC image processing framework";
+    homepage = http://gmic.eu/;
+    license = licenses.gpl3;
+    platforms = platforms.unix;
+  };
+}
diff --git a/nixpkgs/pkgs/tools/graphics/gnuplot/default.nix b/nixpkgs/pkgs/tools/graphics/gnuplot/default.nix
new file mode 100644
index 000000000000..8de7ca3262cf
--- /dev/null
+++ b/nixpkgs/pkgs/tools/graphics/gnuplot/default.nix
@@ -0,0 +1,75 @@
+{ lib, stdenv, fetchurl, makeWrapper, pkgconfig, texinfo
+, cairo, gd, libcerf, pango, readline, zlib
+, withTeXLive ? false, texlive
+, withLua ? false, lua
+, libX11 ? null
+, libXt ? null
+, libXpm ? null
+, libXaw ? null
+, aquaterm ? false
+, withWxGTK ? false, wxGTK ? null
+, fontconfig ? null
+, gnused ? null
+, coreutils ? null
+, withQt ? false, qttools, qtbase, qtsvg
+}:
+
+assert libX11 != null -> (fontconfig != null && gnused != null && coreutils != null);
+let
+  withX = libX11 != null && !aquaterm && !stdenv.isDarwin;
+in
+stdenv.mkDerivation rec {
+  name = "gnuplot-5.2.5";
+
+  src = fetchurl {
+    url = "mirror://sourceforge/gnuplot/${name}.tar.gz";
+    sha256 = "1ajw8xcb1kg2vy8n3rhrz71knjr2yivfavv9lqqzvp1dwv6b5783";
+  };
+
+  nativeBuildInputs = [ makeWrapper pkgconfig texinfo ] ++ lib.optional withQt qttools;
+
+  buildInputs =
+    [ cairo gd libcerf pango readline zlib ]
+    ++ lib.optional withTeXLive (texlive.combine { inherit (texlive) scheme-small; })
+    ++ lib.optional withLua lua
+    ++ lib.optionals withX [ libX11 libXpm libXt libXaw ]
+    ++ lib.optionals withQt [ qtbase qtsvg ]
+    ++ lib.optional withWxGTK wxGTK;
+
+  postPatch = ''
+    # lrelease is in qttools, not in qtbase.
+    sed -i configure -e 's|''${QT5LOC}/lrelease|lrelease|'
+  '';
+
+  configureFlags = [
+    (if withX then "--with-x" else "--without-x")
+    (if withQt then "--with-qt=qt5" else "--without-qt")
+    (if aquaterm then "--with-aquaterm" else "--without-aquaterm")
+  ];
+
+  postInstall = lib.optionalString withX ''
+    wrapProgram $out/bin/gnuplot \
+       --prefix PATH : '${gnused}/bin' \
+       --prefix PATH : '${coreutils}/bin' \
+       --prefix PATH : '${fontconfig.bin}/bin' \
+       --run '. ${./set-gdfontpath-from-fontconfig.sh}'
+  '';
+
+  enableParallelBuilding = true;
+
+  meta = with lib; {
+    homepage = http://www.gnuplot.info/;
+    description = "A portable command-line driven graphing utility for many platforms";
+    platforms = platforms.linux ++ platforms.darwin;
+    license = {
+      # Essentially a BSD license with one modifaction:
+      # Permission to modify the software is granted, but not the right to
+      # distribute the complete modified source code.  Modifications are to
+      # be distributed as patches to the released version.  Permission to
+      # distribute binaries produced by compiling modified sources is granted,
+      # provided you: ...
+      url = https://sourceforge.net/p/gnuplot/gnuplot-main/ci/master/tree/Copyright;
+    };
+    maintainers = with maintainers; [ lovek323 ];
+  };
+}
diff --git a/nixpkgs/pkgs/tools/graphics/gnuplot/set-gdfontpath-from-fontconfig.sh b/nixpkgs/pkgs/tools/graphics/gnuplot/set-gdfontpath-from-fontconfig.sh
new file mode 100644
index 000000000000..92ad2e97b5b4
--- /dev/null
+++ b/nixpkgs/pkgs/tools/graphics/gnuplot/set-gdfontpath-from-fontconfig.sh
@@ -0,0 +1,4 @@
+p=( $(fc-list : file | sed "s@/[^/]*: @@" | sort -u) )
+IFS=:
+export GDFONTPATH="${GDFONTPATH}${GDFONTPATH:+:}${p[*]}"
+unset IFS p
diff --git a/nixpkgs/pkgs/tools/graphics/graph-easy/default.nix b/nixpkgs/pkgs/tools/graphics/graph-easy/default.nix
new file mode 100644
index 000000000000..c21fc02753ec
--- /dev/null
+++ b/nixpkgs/pkgs/tools/graphics/graph-easy/default.nix
@@ -0,0 +1,17 @@
+{ stdenv, perlPackages, fetchurl }:
+
+perlPackages.buildPerlPackage rec {
+  name = "Graph-Easy-${version}";
+  version = "0.76";
+  src = fetchurl {
+    url = "mirror://cpan/authors/id/S/SH/SHLOMIF/${name}.tar.gz";
+    sha256 = "d4a2c10aebef663b598ea37f3aa3e3b752acf1fbbb961232c3dbe1155008d1fa";
+  };
+
+  meta = with stdenv.lib; {
+    description = "Render/convert graphs in/from various formats";
+    license = licenses.gpl1;
+    platforms = platforms.linux;
+    maintainers = [ maintainers.jensbin ];
+  };
+}
diff --git a/nixpkgs/pkgs/tools/graphics/graphviz/2.32.nix b/nixpkgs/pkgs/tools/graphics/graphviz/2.32.nix
new file mode 100644
index 000000000000..544949f33b71
--- /dev/null
+++ b/nixpkgs/pkgs/tools/graphics/graphviz/2.32.nix
@@ -0,0 +1,5 @@
+import ./base.nix {
+  rev = "10c3c34c5198beacfba950764f34960c6884a34f";
+  version = "2.32.0";
+  sha256 = "18b2wnz6xk8hndy7dlr1vn9vziyryyflh747n9966778gmh8bick";
+}
diff --git a/nixpkgs/pkgs/tools/graphics/graphviz/base.nix b/nixpkgs/pkgs/tools/graphics/graphviz/base.nix
new file mode 100644
index 000000000000..68ff84c7495a
--- /dev/null
+++ b/nixpkgs/pkgs/tools/graphics/graphviz/base.nix
@@ -0,0 +1,70 @@
+{ rev, sha256, version }:
+
+{ stdenv, fetchFromGitLab, autoreconfHook, pkgconfig, cairo, expat, flex
+, fontconfig, gd, gettext, gts, libdevil, libjpeg, libpng, libtool, pango
+, yacc, xorg ? null, ApplicationServices ? null }:
+
+assert stdenv.isDarwin -> ApplicationServices != null;
+
+let
+  inherit (stdenv.lib) optionals optionalString;
+in
+
+stdenv.mkDerivation rec {
+  name = "graphviz-${version}";
+
+  src = fetchFromGitLab {
+    owner = "graphviz";
+    repo = "graphviz";
+    inherit sha256 rev;
+  };
+
+  nativeBuildInputs = [ autoreconfHook pkgconfig ];
+
+  buildInputs = [
+    libpng libjpeg expat yacc libtool fontconfig gd gts libdevil flex pango
+    gettext
+  ] ++ optionals (xorg != null) (with xorg; [ libXrender libXaw libXpm ])
+    ++ optionals (stdenv.isDarwin) [ ApplicationServices ];
+
+  hardeningDisable = [ "fortify" ];
+
+  CPPFLAGS = stdenv.lib.optionalString (xorg != null && stdenv.isDarwin)
+    "-I${cairo.dev}/include/cairo";
+
+  configureFlags = [
+    "--with-ltdl-lib=${libtool.lib}/lib"
+    "--with-ltdl-include=${libtool}/include"
+  ] ++ stdenv.lib.optional (xorg == null) [ "--without-x" ];
+
+  postPatch = ''
+    for f in $(find . -name Makefile.in); do
+      substituteInPlace $f --replace "-lstdc++" "-lc++"
+    done
+  '';
+
+  # ''
+  #   substituteInPlace rtest/rtest.sh \
+  #     --replace "/bin/ksh" "${mksh}/bin/mksh"
+  # '';
+
+  doCheck = false; # fails with "Graphviz test suite requires ksh93" which is not in nixpkgs
+
+  preAutoreconf = "./autogen.sh";
+
+  postFixup = optionalString (xorg != null) ''
+    substituteInPlace $out/bin/dotty --replace '`which lefty`' $out/bin/lefty
+    substituteInPlace $out/bin/vimdot \
+      --replace /usr/bin/vi '$(command -v vi)' \
+      --replace /usr/bin/vim '$(command -v vim)' \
+      --replace /usr/bin/vimdot $out/bin/vimdot \
+  '';
+
+  meta = with stdenv.lib; {
+    homepage = https://graphviz.org;
+    description = "Graph visualization tools";
+    license = licenses.epl10;
+    platforms = platforms.unix;
+    maintainers = with maintainers; [ bjornfor raskin ];
+  };
+}
diff --git a/nixpkgs/pkgs/tools/graphics/graphviz/default.nix b/nixpkgs/pkgs/tools/graphics/graphviz/default.nix
new file mode 100644
index 000000000000..48b1b0764c51
--- /dev/null
+++ b/nixpkgs/pkgs/tools/graphics/graphviz/default.nix
@@ -0,0 +1,5 @@
+import ./base.nix rec {
+  rev = "stable_release_${version}";
+  version = "2.40.1";
+  sha256 = "1xjqq3g2n6jgwp5xzyvibgrxawlskkpam69fjjz9ksrrjas2qwzj";
+ }
diff --git a/nixpkgs/pkgs/tools/graphics/gromit-mpx/default.nix b/nixpkgs/pkgs/tools/graphics/gromit-mpx/default.nix
new file mode 100644
index 000000000000..48d40ac49652
--- /dev/null
+++ b/nixpkgs/pkgs/tools/graphics/gromit-mpx/default.nix
@@ -0,0 +1,38 @@
+{ stdenv, fetchFromGitHub, autoreconfHook, autoconf, automake, pkgconfig
+, gtk, glib, pcre, libappindicator, libpthreadstubs, libXdmcp
+, libxkbcommon, epoxy, at-spi2-core, dbus, libdbusmenu
+}:
+
+stdenv.mkDerivation rec {
+  name = "gromit-mpx-${version}";
+  version = "1.2";
+
+  src = fetchFromGitHub {
+    owner = "bk138";
+    repo = "gromit-mpx";
+    rev = "${version}";
+    sha256 = "1dkmp5rhzp56sz9cfxill2pkdz2anwb8kkxkypvk2xhqi64cvkrs";
+  };
+
+  nativeBuildInputs = [ pkgconfig ];
+  buildInputs = [
+    autoconf automake autoreconfHook
+    gtk glib pcre libappindicator libpthreadstubs
+    libXdmcp libxkbcommon epoxy at-spi2-core
+    dbus libdbusmenu
+  ];
+
+  meta = with stdenv.lib; {
+    description = "Desktop annotation tool";
+
+    longDescription = ''
+      Gromit-MPX (GRaphics Over MIscellaneous Things) is a small tool
+      to make annotations on the screen.
+    '';
+
+    homepage = https://github.com/bk138/gromit-mpx;
+    maintainers = with maintainers; [ pjones ];
+    platforms = platforms.linux;
+    license = licenses.gpl2;
+  };
+}
diff --git a/nixpkgs/pkgs/tools/graphics/guff/default.nix b/nixpkgs/pkgs/tools/graphics/guff/default.nix
new file mode 100644
index 000000000000..db218a812e69
--- /dev/null
+++ b/nixpkgs/pkgs/tools/graphics/guff/default.nix
@@ -0,0 +1,25 @@
+{ stdenv, fetchFromGitHub }:
+
+stdenv.mkDerivation rec {
+  pname = "guff";
+  version = "0.1.0";
+
+  src = fetchFromGitHub {
+    owner = "silentbicycle";
+    repo = "guff";
+    rev = "v${version}";
+    sha256 = "0n8mc9j3044j4b3vgc94ryd2j9ik6g73fqja54yxfdfrks4ksyds";
+  };
+
+  makeFlags = [ "PREFIX=$(out)" ];
+
+  doCheck = true;
+
+  meta = with stdenv.lib;  {
+    description = "A plot device";
+    homepage = https://github.com/silentbicycle/guff;
+    license = licenses.isc;
+    maintainers = [ maintainers.marsam ];
+    platforms = platforms.all;
+  };
+}
diff --git a/nixpkgs/pkgs/tools/graphics/ibniz/default.nix b/nixpkgs/pkgs/tools/graphics/ibniz/default.nix
new file mode 100644
index 000000000000..11fad25b85ae
--- /dev/null
+++ b/nixpkgs/pkgs/tools/graphics/ibniz/default.nix
@@ -0,0 +1,26 @@
+{ stdenv, fetchurl, SDL }:
+
+stdenv.mkDerivation rec {
+  name = "ibniz-${version}";
+  version = "1.18";
+
+  src = fetchurl {
+    url = "http://www.pelulamu.net/ibniz/${name}.tar.gz";
+    sha256 = "10b4dka8zx7y84m1a58z9j2vly8mz9aw9wn8z9vx9av739j95wp2";
+  };
+
+  buildInputs = [ SDL ];
+
+  installPhase = ''
+    mkdir -p $out/bin
+    cp ibniz $out/bin
+  '';
+
+  meta = with stdenv.lib; {
+    description = "Virtual machine designed for extremely compact low-level audiovisual programs";
+    homepage = "http://www.pelulamu.net/ibniz/";
+    license = licenses.zlib;
+    platforms = platforms.linux;
+    maintainers = [ maintainers.dezgeg ];
+  };
+}
diff --git a/nixpkgs/pkgs/tools/graphics/icoutils/default.nix b/nixpkgs/pkgs/tools/graphics/icoutils/default.nix
new file mode 100644
index 000000000000..b16dbe219853
--- /dev/null
+++ b/nixpkgs/pkgs/tools/graphics/icoutils/default.nix
@@ -0,0 +1,32 @@
+{ stdenv, fetchurl, libpng, perl, perlPackages, makeWrapper }:
+
+stdenv.mkDerivation rec {
+  name = "icoutils-0.32.3";
+
+  src = fetchurl {
+    url = "mirror://savannah/icoutils/${name}.tar.bz2";
+    sha256 = "1q66cksms4l62y0wizb8vfavhmf7kyfgcfkynil3n99s0hny1aqp";
+  };
+
+  buildInputs = [ makeWrapper libpng perl ];
+  propagatedBuildInputs = [ perlPackages.LWP ];
+
+  patchPhase = ''
+    patchShebangs extresso/extresso
+    patchShebangs extresso/extresso.in
+    patchShebangs extresso/genresscript
+    patchShebangs extresso/genresscript.in
+  '';
+
+  preFixup = ''
+    wrapProgram $out/bin/extresso --prefix PERL5LIB : $PERL5LIB
+    wrapProgram $out/bin/genresscript --prefix PERL5LIB : $PERL5LIB
+  '';
+
+  meta = {
+    homepage = https://www.nongnu.org/icoutils/;
+    description = "Set of programs to deal with Microsoft Windows(R) icon and cursor files";
+    license = stdenv.lib.licenses.gpl3Plus;
+    platforms = with stdenv.lib.platforms; linux ++ darwin;
+  };
+}
diff --git a/nixpkgs/pkgs/tools/graphics/imgur-screenshot/default.nix b/nixpkgs/pkgs/tools/graphics/imgur-screenshot/default.nix
new file mode 100644
index 000000000000..8db5b6c7dea7
--- /dev/null
+++ b/nixpkgs/pkgs/tools/graphics/imgur-screenshot/default.nix
@@ -0,0 +1,29 @@
+{ stdenv, fetchFromGitHub, makeWrapper, curl, gnugrep, libnotify, scrot, which, xclip }:
+
+let deps = stdenv.lib.makeBinPath [ curl gnugrep libnotify scrot which xclip ];
+in stdenv.mkDerivation rec {
+  version = "1.7.4";
+  name = "imgur-screenshot-${version}";
+
+  src = fetchFromGitHub {
+    owner = "jomo";
+    repo = "imgur-screenshot";
+    rev = "v${version}";
+    sha256 = "1bhi9sk8v7szh2fj13qwvdwzy5dw2w4kml86sy1ns1rn0xin0cgr";
+  };
+
+  nativeBuildInputs = [ makeWrapper ];
+
+  installPhase = ''
+    install -Dm755 imgur-screenshot.sh $out/bin/imgur-screenshot
+    wrapProgram $out/bin/imgur-screenshot --prefix PATH ':' ${deps}
+  '';
+
+  meta = with stdenv.lib; {
+    description = "A tool for easy screencapping and uploading to imgur";
+    homepage = https://github.com/jomo/imgur-screenshot/;
+    platforms = platforms.linux;
+    license = licenses.mit;
+    maintainers = with maintainers; [ lw ];
+  };
+}
diff --git a/nixpkgs/pkgs/tools/graphics/imgurbash2/default.nix b/nixpkgs/pkgs/tools/graphics/imgurbash2/default.nix
new file mode 100644
index 000000000000..5a655b9ff162
--- /dev/null
+++ b/nixpkgs/pkgs/tools/graphics/imgurbash2/default.nix
@@ -0,0 +1,31 @@
+{ stdenv, fetchFromGitHub, bash, curl, xsel }:
+
+stdenv.mkDerivation rec {
+  name = "imgurbash2-${version}";
+  version = "2.1";
+
+  src = fetchFromGitHub {
+    owner = "ram-on";
+    repo = "imgurbash2";
+    rev = version;
+    sha256 = "1vdkyy0gvjqwc2g7a1lqx6cbynfxbd4f66m8sg1xjvd0kdpgi9wk";
+  };
+
+  installPhase = ''
+    mkdir -p $out/bin
+    cat <<EOF >$out/bin/imgurbash2
+    #!${bash}/bin/bash
+    PATH=${stdenv.lib.makeBinPath [curl xsel]}:\$PATH
+    EOF
+    cat imgurbash2 >> $out/bin/imgurbash2
+    chmod +x $out/bin/imgurbash2
+  '';
+
+  meta = with stdenv.lib; {
+    description = "A shell script that uploads images to imgur";
+    license = licenses.mit;
+    platforms = platforms.linux;
+    maintainers = with maintainers; [ abbradar ];
+    homepage = https://github.com/ram-on/imgurbash2;
+  };
+}
diff --git a/nixpkgs/pkgs/tools/graphics/jbig2enc/53ce5fe7e73d7ed95c9e12b52dd4984723f865fa.patch b/nixpkgs/pkgs/tools/graphics/jbig2enc/53ce5fe7e73d7ed95c9e12b52dd4984723f865fa.patch
new file mode 100644
index 000000000000..13e18fd04476
--- /dev/null
+++ b/nixpkgs/pkgs/tools/graphics/jbig2enc/53ce5fe7e73d7ed95c9e12b52dd4984723f865fa.patch
@@ -0,0 +1,47 @@
+From 53ce5fe7e73d7ed95c9e12b52dd4984723f865fa Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Zdenko=20Podobn=C3=BD?= <zdenop@gmail.com>
+Date: Sun, 6 Apr 2014 21:25:27 +0200
+Subject: [PATCH] fix build with leptonica 1.70
+
+---
+ configure.ac |  1 +
+ src/jbig2.cc | 13 +++++++++----
+ 2 files changed, 10 insertions(+), 4 deletions(-)
+
+diff --git a/configure.ac b/configure.ac
+index fe37c22..753a607 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -55,6 +55,7 @@ AC_CHECK_LIB([lept], [findFileFormatStream], [], [
+			echo "Error! Leptonica not detected."
+			exit -1
+			])
++AC_CHECK_FUNCS(expandBinaryPower2Low,,)
+ # test for function - it should detect leptonica dependecies
+
+ # Check for possible dependancies of leptonica.
+diff --git a/src/jbig2.cc b/src/jbig2.cc
+index e10f042..515c1ef 100644
+--- a/src/jbig2.cc
++++ b/src/jbig2.cc
+@@ -130,11 +130,16 @@ segment_image(PIX *pixb, PIX *piximg) {
+   // input color image, so we have to do it this way...
+   // is there a better way?
+   // PIX *pixd = pixExpandBinary(pixd4, 4);
+-  PIX *pixd = pixCreate(piximg->w, piximg->h, 1);
+-  pixCopyResolution(pixd, piximg);
+-  if (verbose) pixInfo(pixd, "mask image: ");
+-  expandBinaryPower2Low(pixd->data, pixd->w, pixd->h, pixd->wpl,
++  PIX *pixd;
++#ifdef HAVE_EXPANDBINARYPOWER2LOW
++    pixd = pixCreate(piximg->w, piximg->h, 1);
++    pixCopyResolution(pixd, piximg);
++    expandBinaryPower2Low(pixd->data, pixd->w, pixd->h, pixd->wpl,
+                         pixd4->data, pixd4->w, pixd4->h, pixd4->wpl, 4);
++#else
++    pixd = pixExpandBinaryPower2(pixd4, 4);
++#endif
++  if (verbose) pixInfo(pixd, "mask image: ");
+
+   pixDestroy(&pixd4);
+   pixDestroy(&pixsf4);
diff --git a/nixpkgs/pkgs/tools/graphics/jbig2enc/default.nix b/nixpkgs/pkgs/tools/graphics/jbig2enc/default.nix
new file mode 100644
index 000000000000..393c18d38529
--- /dev/null
+++ b/nixpkgs/pkgs/tools/graphics/jbig2enc/default.nix
@@ -0,0 +1,32 @@
+{ stdenv, fetchurl, leptonica, zlib, libwebp, giflib, libjpeg, libpng, libtiff }:
+
+stdenv.mkDerivation {
+  name = "jbig2enc-0.28";
+
+  src = fetchurl {
+    url = http://github.com/agl/jbig2enc/archive/0.28-dist.tar.gz;
+    sha256 = "1wc0lmqz4jag3rhhk1xczlqpfv2qqp3fz7wzic2lba3vsbi1rrw3";
+  };
+
+  propagatedBuildInputs = [ leptonica zlib libwebp giflib libjpeg libpng libtiff ];
+
+  patches = [
+    # https://github.com/agl/jbig2enc/commit/53ce5fe7e73d7ed95c9e12b52dd4984723f865fa
+    ./53ce5fe7e73d7ed95c9e12b52dd4984723f865fa.patch
+  ];
+
+  # This is necessary, because the resulting library has
+  # /tmp/nix-build-jbig2enc/src/.libs before /nix/store/jbig2enc/lib
+  # in its rpath, which means that patchelf --shrink-rpath removes
+  # the /nix/store one.  By cleaning up before fixup, we ensure that
+  # the /tmp/nix-build-jbig2enc/src/.libs directory is gone.
+  preFixup = ''
+    make clean
+  '';
+
+  meta = {
+    description = "Encoder for the JBIG2 image compression format";
+    license = stdenv.lib.licenses.asl20;
+    platforms = stdenv.lib.platforms.all;
+  };
+}
diff --git a/nixpkgs/pkgs/tools/graphics/jhead/default.nix b/nixpkgs/pkgs/tools/graphics/jhead/default.nix
new file mode 100644
index 000000000000..ce1d26e062c2
--- /dev/null
+++ b/nixpkgs/pkgs/tools/graphics/jhead/default.nix
@@ -0,0 +1,41 @@
+{ stdenv, fetchurl, libjpeg }:
+
+stdenv.mkDerivation rec {
+  name = "jhead-${version}";
+  version = "3.02";
+
+  src = fetchurl {
+    url = "http://www.sentex.net/~mwandel/jhead/${name}.tar.gz";
+    sha256 = "0apdqxqzssnlgn3z9ykvd487dvnbfsgxw1vklr0b916c7my77jc5";
+  };
+
+  buildInputs = [ libjpeg ];
+
+  patchPhase = ''
+    substituteInPlace makefile \
+      --replace /usr/local/bin $out/bin
+
+    substituteInPlace jhead.c \
+      --replace "\"   Compiled: \"__DATE__" "" \
+      --replace "jpegtran -trim" "${libjpeg.bin}/bin/jpegtran -trim"
+  '';
+
+  installPhase = ''
+    mkdir -p \
+      $out/bin \
+      $out/man/man1 \
+      $out/share/doc/${name}
+
+    cp -v jhead $out/bin
+    cp -v jhead.1 $out/man/man1
+    cp -v *.txt $out/share/doc/${name}
+  '';
+
+  meta = with stdenv.lib; {
+    homepage = http://www.sentex.net/~mwandel/jhead/;
+    description = "Exif Jpeg header manipulation tool";
+    license = licenses.publicDomain;
+    maintainers = with maintainers; [ rycee ];
+    platforms = platforms.all;
+  };
+}
diff --git a/nixpkgs/pkgs/tools/graphics/kst/default.nix b/nixpkgs/pkgs/tools/graphics/kst/default.nix
new file mode 100644
index 000000000000..24d678e11422
--- /dev/null
+++ b/nixpkgs/pkgs/tools/graphics/kst/default.nix
@@ -0,0 +1,32 @@
+{ stdenv, fetchurl, cmake, pkgconfig
+, qtbase, gsl, getdata, netcdf, muparser, matio
+}:
+stdenv.mkDerivation rec {
+  name = "Kst-2.0.8";
+  src = fetchurl {
+    url = "mirror://sourceforge/kst/${name}.tar.gz";
+    sha256 = "1ihqmwqw0h2p7hn5shd8iwb0gd4axybs60lgw22ijxqh6wzgvyyf";
+  };
+
+  nativeBuildInputs = [ cmake pkgconfig ];
+  buildInputs = [ qtbase gsl getdata netcdf muparser matio ];
+
+  cmakeFlags = "-Dkst_qt5=1 -Dkst_release=1";
+
+  postInstall = ''
+    mkdir -p $out
+    for d in bin lib share
+    do
+      cp -r INSTALLED/$d $out/
+    done
+  '';
+
+  meta = with stdenv.lib; {
+    description = "Real-time large-dataset viewing and plotting tool";
+    homepage = https://kst-plot.kde.org/;
+    license = licenses.gpl2;
+    platforms = platforms.all;
+    maintainers = [ maintainers.vbgl ];
+    broken = true;
+  };
+}
diff --git a/nixpkgs/pkgs/tools/graphics/leela/default.nix b/nixpkgs/pkgs/tools/graphics/leela/default.nix
new file mode 100644
index 000000000000..d1b31f391526
--- /dev/null
+++ b/nixpkgs/pkgs/tools/graphics/leela/default.nix
@@ -0,0 +1,25 @@
+{ stdenv, fetchFromGitHub, pkgconfig, poppler }:
+
+stdenv.mkDerivation {
+  name = "leela-12.fe7a35a";
+
+  src = fetchFromGitHub {
+    owner = "TrilbyWhite";
+    repo = "Leela";
+    rev = "576a60185b191d3a3030fef10492fe32d2125563";
+    sha256 = "1k6n758r9dhjmc1pnpk6qzpg0q7pkq2hf18z3b0s2z198jpkg9s3";
+  };
+
+  nativeBuildInputs = [ pkgconfig ];
+  buildInputs = [ poppler ];
+
+  installFlags = [ "PREFIX=$(out)" "MANDIR=$(out)/share/man" ];
+
+  meta = {
+    description = "CLI frontend to the poppler-glib libary of PDF tools";
+    homepage = https://github.com/TrilbyWhite/Leela;
+    license = stdenv.lib.licenses.gpl3;
+    maintainers = [ stdenv.lib.maintainers.puffnfresh ];
+    platforms = stdenv.lib.platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/tools/graphics/logstalgia/default.nix b/nixpkgs/pkgs/tools/graphics/logstalgia/default.nix
new file mode 100644
index 000000000000..93a6652eafbc
--- /dev/null
+++ b/nixpkgs/pkgs/tools/graphics/logstalgia/default.nix
@@ -0,0 +1,44 @@
+{ stdenv, fetchurl, SDL2, ftgl, pkgconfig, libpng, libjpeg, pcre, SDL2_image, glew
+, libGLU_combined, boost, glm, freetype }:
+
+stdenv.mkDerivation rec {
+  name = "logstalgia-${version}";
+  version = "1.1.2";
+
+  src = fetchurl {
+    url = "https://github.com/acaudwell/Logstalgia/releases/download/${name}/${name}.tar.gz";
+    sha256 = "1agwjlwzp1c86hqb1p7rmzqzhd3wpnyh8whsfq4sbx01wj0l0gzd";
+  };
+
+  nativeBuildInputs = [ pkgconfig ];
+  buildInputs = [ glew SDL2 ftgl libpng libjpeg pcre SDL2_image libGLU_combined boost
+                  glm freetype ];
+
+  meta = with stdenv.lib; {
+    homepage = http://logstalgia.io/;
+    description = "Website traffic visualization tool";
+    license = licenses.gpl3Plus;
+
+    longDescription = ''
+      Logstalgia is a website traffic visualization that replays or
+      streams web-server access logs as a pong-like battle between the
+      web server and an never ending torrent of requests.
+
+      Requests appear as colored balls (the same color as the host)
+      which travel across the screen to arrive at the requested
+      location. Successful requests are hit by the paddle while
+      unsuccessful ones (eg 404 - File Not Found) are missed and pass
+      through.
+
+      The paths of requests are summarized within the available space by
+      identifying common path prefixes. Related paths are grouped
+      together under headings. For instance, by default paths ending in
+      png, gif or jpg are grouped under the heading Images. Paths that
+      don’t match any of the specified groups are lumped together under
+      a Miscellaneous section.
+    '';
+
+    platforms = platforms.gnu ++ platforms.linux;
+    maintainers = with maintainers; [ pSub ];
+  };
+}
diff --git a/nixpkgs/pkgs/tools/graphics/lprof/default.nix b/nixpkgs/pkgs/tools/graphics/lprof/default.nix
new file mode 100644
index 000000000000..a4a2cfc1a7c4
--- /dev/null
+++ b/nixpkgs/pkgs/tools/graphics/lprof/default.nix
@@ -0,0 +1,37 @@
+{ stdenv, fetchurl, scons, qt3, lcms1, libtiff, vigra }:
+
+/*  how to calibrate your monitor:
+    Eg see https://wiki.archlinux.org/index.php/ICC_Profiles#Loading_ICC_Profiles
+*/
+stdenv.mkDerivation {
+  name = "lprof-1.11.4.1";
+  nativeBuildInputs = [ scons ];
+  buildInputs = [ qt3 lcms1 libtiff vigra ];
+
+  hardeningDisable = [ "format" ];
+
+  preConfigure = ''
+    export QTDIR=${qt3}
+    export qt_directory=${qt3}
+  '';
+
+  src = fetchurl {
+    url = mirror://sourceforge/lprof/lprof/lprof-1.11.4/lprof-1.11.4.1.tar.gz;
+    sha256 = "0q8x24fm5yyvm151xrl3l03p7hvvciqnkbviprfnvlr0lyg9wsrn";
+  };
+
+  sconsFlags = "SYSLIBS=1";
+  preBuild = ''
+    export CXX=g++
+  '';
+  prefixKey = "PREFIX=";
+
+  patches = [ ./lcms-1.17.patch  ./keep-environment.patch ];
+
+  meta = {
+    description = "Little CMS ICC profile construction set";
+    homepage = https://sourceforge.net/projects/lprof;
+    license = stdenv.lib.licenses.gpl2;
+    platforms = stdenv.lib.platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/tools/graphics/lprof/keep-environment.patch b/nixpkgs/pkgs/tools/graphics/lprof/keep-environment.patch
new file mode 100644
index 000000000000..4dcb5b0448dd
--- /dev/null
+++ b/nixpkgs/pkgs/tools/graphics/lprof/keep-environment.patch
@@ -0,0 +1,16 @@
+--- lprof-1.11.4.1.org/SConstruct	2006-06-06 02:11:32.000000000 +0100
++++ lprof-1.11.4.1/SConstruct	2017-08-29 12:56:13.425654683 +0100
+@@ -22,12 +22,7 @@
+ # opts.Add(BoolOption('qt-mt-lib', 'Flag used to set QT library to either qt-mt or qt. Value of 1 = qt-mt, 0 = qt.', 'yes'))
+ 
+ # setup base environemnt 
+-env = Environment(
+-    ENV = {
+-      'PATH' : os.environ[ 'PATH' ],
+-      'HOME' : os.environ[ 'HOME' ], # required for distcc
+-      'LDFLAGS' : ''
+-    }, options = opts)
++env = Environment(ENV = os.environ, options = opts)
+ 
+ opts.Update(env)
+ opts.Save('lprof.conf', env) # Save, so user doesn't have to 
diff --git a/nixpkgs/pkgs/tools/graphics/lprof/lcms-1.17.patch b/nixpkgs/pkgs/tools/graphics/lprof/lcms-1.17.patch
new file mode 100644
index 000000000000..a88471e143fd
--- /dev/null
+++ b/nixpkgs/pkgs/tools/graphics/lprof/lcms-1.17.patch
@@ -0,0 +1,13 @@
+--- a/src/liblprof/lcmsprf.h	2007-08-31 15:36:20.000000000 -0700
++++ b/src/liblprof/lcmsprf.h	2007-08-31 15:37:39.000000000 -0700
+@@ -67,6 +67,9 @@
+ #define mmax(a,b) ((a) > (b)?(a):(b))
+ #endif
+ 
++#if LCMS_VERSION > 116
++typedef int BOOL;
++#endif
+ 
+ /* Misc operations ------------------------------------------------------------------------ */
+ 
+
diff --git a/nixpkgs/pkgs/tools/graphics/luxcorerender/default.nix b/nixpkgs/pkgs/tools/graphics/luxcorerender/default.nix
new file mode 100644
index 000000000000..85713a300ec6
--- /dev/null
+++ b/nixpkgs/pkgs/tools/graphics/luxcorerender/default.nix
@@ -0,0 +1,88 @@
+{ stdenv, fetchFromGitHub, cmake, boost165, pkgconfig, python35
+, tbb, openimageio, libjpeg, libpng, zlib, libtiff, ilmbase
+, freetype, openexr, libXdmcp, libxkbcommon, epoxy, at-spi2-core
+, dbus, doxygen, qt5, c-blosc, libGLU, gnome3, pcre
+, bison, flex, libpthreadstubs, libX11
+, embree2, makeWrapper, gsettings-desktop-schemas, glib
+, withOpenCL ? true , opencl-headers, ocl-icd, opencl-clhpp
+}:
+
+let boost_static = boost165.override {
+      python = python35;
+      enableStatic = true;
+      enablePython = true;
+    };
+
+in stdenv.mkDerivation rec {
+  name = "luxcorerender-${version}";
+  version = "2.0";
+
+  src = fetchFromGitHub {
+    owner = "LuxCoreRender";
+    repo = "LuxCore";
+    rev = "luxcorerender_v2.0";
+    sha256 = "15nn39ybsfjf3cw3xgkbarvxn4a9ymfd579ankm7yjxkw5gcif38";
+  };
+
+  buildInputs =
+   [ embree2 pkgconfig cmake zlib boost_static libjpeg
+     libtiff libpng ilmbase freetype openexr openimageio
+     tbb qt5.full c-blosc libGLU pcre bison
+     flex libX11 libpthreadstubs python35 libXdmcp libxkbcommon
+     epoxy at-spi2-core dbus doxygen
+     # needed for GSETTINGS_SCHEMAS_PATH
+     gsettings-desktop-schemas glib gnome3.gtk
+     # needed for XDG_ICON_DIRS
+     gnome3.defaultIconTheme
+     makeWrapper
+     (stdenv.lib.getLib gnome3.dconf)
+   ] ++ stdenv.lib.optionals withOpenCL [opencl-headers ocl-icd opencl-clhpp];
+
+  cmakeFlags = [
+    "-DOpenEXR_Iex_INCLUDE_DIR=${openexr.dev}/include/OpenEXR"
+    "-DOpenEXR_IlmThread_INCLUDE_DIR=${ilmbase.dev}/include/OpenEXR"
+    "-DOpenEXR_Imath_INCLUDE_DIR=${openexr.dev}/include/OpenEXR"
+    "-DOpenEXR_half_INCLUDE_DIR=${ilmbase.dev}/include"
+    "-DPYTHON_LIBRARY=${python35}/lib/libpython3.so"
+    "-DPYTHON_INCLUDE_DIR=${python35}/include/python3.5"
+    "-DEMBREE_INCLUDE_PATH=${embree2}/include"
+    "-DEMBREE_LIBRARY=${embree2}/lib/libembree.so"
+    "-DBoost_PYTHON_LIBRARY_RELEASE=${boost_static}/lib/libboost_python3-mt.so"
+  ] ++ stdenv.lib.optional withOpenCL
+       "-DOPENCL_INCLUDE_DIR=${opencl-headers}/include";
+  preConfigure = ''
+    NIX_CFLAGS_COMPILE+=" -isystem ${python35}/include/python3.5"
+    NIX_LDFLAGS+=" -lpython3"
+  '';
+
+  installPhase = ''
+    mkdir -p $out/bin
+    mkdir -p $out/lib
+    cp -va bin/* $out/bin
+    cp -va lib/* $out/lib
+  '';
+
+  preFixup = ''
+    wrapProgram "$out/bin/luxcoreui" \
+      --prefix XDG_DATA_DIRS : "$GSETTINGS_SCHEMAS_PATH" \
+      --suffix XDG_DATA_DIRS : '${gnome3.defaultIconTheme}/share' \
+      --prefix GIO_EXTRA_MODULES : "${stdenv.lib.getLib gnome3.dconf}/lib/gio/modules"
+  '';
+
+  meta = with stdenv.lib; {
+    description = "Open source, physically based, unbiased rendering engine";
+    homepage = https://luxcorerender.org/;
+    maintainers = with maintainers; [ hodapp ];
+    license = licenses.asl20;
+    platforms = platforms.linux;
+  };
+}
+
+
+# TODO (might not be necessary):
+#
+# luxcoreui still gives warnings like: "failed to commit changes to
+# dconf: GDBus.Error:org.freedesktop.DBus.Error.ServiceUnknown: The
+# name ca.desrt.dconf was not provided by any .service files"
+
+# CMake complains of the FindOpenGL/GLVND preference
diff --git a/nixpkgs/pkgs/tools/graphics/maim/default.nix b/nixpkgs/pkgs/tools/graphics/maim/default.nix
new file mode 100644
index 000000000000..0cea8d4011c7
--- /dev/null
+++ b/nixpkgs/pkgs/tools/graphics/maim/default.nix
@@ -0,0 +1,36 @@
+{ stdenv, fetchFromGitHub, cmake, pkgconfig
+, zlib, libpng, libjpeg, libGLU_combined, glm
+, libX11, libXext, libXfixes, libXrandr, libXcomposite, slop, icu
+}:
+
+stdenv.mkDerivation rec {
+  name = "maim-${version}";
+  version = "5.5.2";
+
+  src = fetchFromGitHub {
+    owner = "naelstrof";
+    repo = "maim";
+    rev = "v${version}";
+    sha256 = "14mfxdm39kc5jk8wysrzx05ag2g4sk9l24i8m5pzqn8j611150v3";
+  };
+
+  nativeBuildInputs = [ cmake pkgconfig ];
+  buildInputs =
+    [ zlib libpng libjpeg libGLU_combined glm
+      libX11 libXext libXfixes libXrandr libXcomposite slop icu ];
+
+  doCheck = false;
+
+  meta = with stdenv.lib; {
+    inherit (src.meta) homepage;
+    description = "A command-line screenshot utility";
+    longDescription = ''
+      maim (make image) takes screenshots of your desktop. It has options to
+      take only a region, and relies on slop to query for regions. maim is
+      supposed to be an improved scrot.
+    '';
+    platforms = stdenv.lib.platforms.all;
+    license = stdenv.lib.licenses.gpl3Plus;
+    maintainers = with maintainers; [ primeos mbakke ];
+  };
+}
diff --git a/nixpkgs/pkgs/tools/graphics/mscgen/default.nix b/nixpkgs/pkgs/tools/graphics/mscgen/default.nix
new file mode 100644
index 000000000000..e9301731e856
--- /dev/null
+++ b/nixpkgs/pkgs/tools/graphics/mscgen/default.nix
@@ -0,0 +1,42 @@
+{ stdenv, fetchurl, flex, bison, gd, libpng, libjpeg, freetype, zlib, libwebp }:
+
+let
+  version = "0.20";
+in
+stdenv.mkDerivation {
+  name = "mscgen-${version}";
+
+  src = fetchurl {
+    url = "http://www.mcternan.me.uk/mscgen/software/mscgen-src-${version}.tar.gz";
+    sha256 = "3c3481ae0599e1c2d30b7ed54ab45249127533ab2f20e768a0ae58d8551ddc23";
+  };
+
+  buildInputs = [ flex bison gd libjpeg libpng freetype zlib libwebp ];
+
+  doCheck = true;
+  preCheck = ''
+    sed -i -e "s|#!/bin/bash|#!${stdenv.shell}|" test/renderercheck.sh
+  '';
+
+  meta = {
+    homepage = http://www.mcternan.me.uk/mscgen/;
+    description = "Convert Message Sequence Chart descriptions into PNG, SVG, or EPS images";
+    license = stdenv.lib.licenses.gpl2;
+
+    longDescription = ''
+      Mscgen is a small program that parses Message Sequence Chart
+      descriptions and produces PNG, SVG, EPS or server side image maps
+      (ismaps) as the output. Message Sequence Charts (MSCs) are a way
+      of representing entities and interactions over some time period
+      and are often used in combination with SDL. MSCs are popular in
+      Telecoms to specify how protocols operate although MSCs need not
+      be complicated to create or use. Mscgen aims to provide a simple
+      text language that is clear to create, edit and understand, which
+      can also be transformed into common image formats for display or
+      printing.
+    '';
+
+    platforms = stdenv.lib.platforms.linux;
+    maintainers = [ stdenv.lib.maintainers.peti ];
+  };
+}
diff --git a/nixpkgs/pkgs/tools/graphics/netpbm/default.nix b/nixpkgs/pkgs/tools/graphics/netpbm/default.nix
new file mode 100644
index 000000000000..534cefe9bf6c
--- /dev/null
+++ b/nixpkgs/pkgs/tools/graphics/netpbm/default.nix
@@ -0,0 +1,70 @@
+{ lib, stdenv, fetchsvn, pkgconfig, libjpeg, libpng, flex, zlib, perl, libxml2
+, makeWrapper, libtiff
+, enableX11 ? false, libX11 }:
+
+stdenv.mkDerivation rec {
+  # Determine version and revision from:
+  # https://sourceforge.net/p/netpbm/code/HEAD/log/?path=/advanced
+  name = "netpbm-10.82.01";
+
+  src = fetchsvn {
+    url = "https://svn.code.sf.net/p/netpbm/code/advanced";
+    rev = "3264";
+    sha256 = "17fmyjbxp1l18rma7gb0m8wd9kx2iwhqs8dd6fpalsn2cr8mf8hf";
+  };
+
+  postPatch = /* CVE-2005-2471, from Arch */ ''
+    substituteInPlace converter/other/pstopnm.c \
+      --replace '"-DSAFER"' '"-DPARANOIDSAFER"'
+  '';
+
+  buildInputs =
+    [ pkgconfig flex zlib perl libpng libjpeg libxml2 makeWrapper libtiff ]
+    ++ lib.optional enableX11 libX11;
+
+  configurePhase = ''
+    cp config.mk.in config.mk
+    echo "STATICLIB_TOO = n" >> config.mk
+    substituteInPlace "config.mk" \
+        --replace "TIFFLIB = NONE" "TIFFLIB = ${libtiff.out}/lib/libtiff.so" \
+        --replace "TIFFHDR_DIR =" "TIFFHDR_DIR = ${libtiff.dev}/include" \
+        --replace "JPEGLIB = NONE" "JPEGLIB = ${libjpeg.out}/lib/libjpeg.so" \
+        --replace "JPEGHDR_DIR =" "JPEGHDR_DIR = ${libjpeg.dev}/include"
+   '' + stdenv.lib.optionalString stdenv.isDarwin ''
+    echo "LDSHLIB=-dynamiclib -install_name $out/lib/libnetpbm.\$(MAJ).dylib" >> config.mk
+    echo "NETPBMLIBTYPE = dylib" >> config.mk
+    echo "NETPBMLIBSUFFIX = dylib" >> config.mk
+  '';
+
+  preBuild = ''
+    export LDFLAGS="-lz"
+    substituteInPlace "pm_config.in.h" \
+        --subst-var-by "rgbPath1" "$out/lib/rgb.txt" \
+        --subst-var-by "rgbPath2" "/var/empty/rgb.txt" \
+        --subst-var-by "rgbPath3" "/var/empty/rgb.txt"
+    touch lib/standardppmdfont.c
+  '';
+
+  enableParallelBuilding = false;
+
+  installPhase = ''
+    make package pkgdir=$out
+
+    rm -rf $out/link $out/*_template $out/{pkginfo,README,VERSION} $out/man/web
+
+    mkdir -p $out/share/netpbm
+    mv $out/misc $out/share/netpbm/
+
+    # wrap any scripts that expect other programs in the package to be in their PATH
+    for prog in ppmquant; do
+        wrapProgram "$out/bin/$prog" --prefix PATH : "$out/bin"
+    done
+  '';
+
+  meta = {
+    homepage = http://netpbm.sourceforge.net/;
+    description = "Toolkit for manipulation of graphic images";
+    license = "GPL,free";
+    platforms = with stdenv.lib.platforms; linux ++ darwin;
+  };
+}
diff --git a/nixpkgs/pkgs/tools/graphics/neural-style/default.nix b/nixpkgs/pkgs/tools/graphics/neural-style/default.nix
new file mode 100644
index 000000000000..99421cfde170
--- /dev/null
+++ b/nixpkgs/pkgs/tools/graphics/neural-style/default.nix
@@ -0,0 +1,58 @@
+{stdenv, fetchFromGitHub, torch, loadcaffe, fetchurl, bash}:
+stdenv.mkDerivation rec {
+  name = "neural-style-${version}";
+  version = "0.0pre2016.08.15";
+  buildInputs = [torch loadcaffe];
+  src = fetchFromGitHub {
+    owner = "jcjohnson";
+    repo = "neural-style";
+    rev = "ec5ba3a690d3090428d3b92b0c5d686a311bf432";
+    sha256 = "14qzbs9f95izvd0vbbirhymdw9pq2nw0jvhrh7vnyzr99xllwp02";
+  };
+  models = [
+    (fetchurl {
+      url = "https://gist.githubusercontent.com/ksimonyan/3785162f95cd2d5fee77/raw/bb2b4fe0a9bb0669211cf3d0bc949dfdda173e9e/VGG_ILSVRC_19_layers_deploy.prototxt";
+      sha256 = "09cpz7pyvc8sypg2q5j2i8yqwj1sjdbnmd6skl293p9pv13dmjg7";
+    })
+    (fetchurl {
+      url = "https://bethgelab.org/media/uploads/deeptextures/vgg_normalised.caffemodel";
+      sha256 = "11qckdvlck7wwl3pan0nawgxm8l2ccddi272i5l8rs9qzm7b23rf";
+    })
+    (fetchurl {
+      url = "http://www.robots.ox.ac.uk/~vgg/software/very_deep/caffe/VGG_ILSVRC_19_layers.caffemodel";
+      sha256 = "0m399x7pl4lnhy435ycsyz8xpzapqmx9n1sz698y2vhcqhkwdd1i";
+    })
+  ];
+  installPhase = ''
+    mkdir -p "$out"/{bin,lib/lua/neural-style/models,share/doc/neural-style,share/neural-style}
+    for file in $models; do
+      ln -s "$file" "$out/lib/lua/neural-style/models/$(basename "$file" | sed -e 's/[^-]*-//')"
+    done;
+    cp README* INSTALL* LICEN?E* "$out"/share/doc/neural-style/
+    cp neural_style.lua "$out"/lib/lua/neural-style
+
+    substituteAll "${./neural-style.sh}" "$out/bin/neural-style"
+    chmod a+x "$out/bin/neural-style"
+    cp "$out/bin/neural-style" .
+    cp "$out/lib/lua/neural-style/models/"* models/
+
+    echo "Testing..."
+
+    "$out/bin/neural-style" -style_image examples/inputs/golden_gate.jpg \
+      -content_image examples/inputs/golden_gate.jpg -output_image $PWD/test.png \
+      -gpu -1 -save_iter 1 -print_iter 1 -num_iterations 1 || true
+
+    cp -f "$out/lib/lua/neural-style/models/"* models/
+
+    test -e test.png || exit 1
+  '';
+  inherit torch bash loadcaffe;
+  meta = {
+    inherit version;
+    description = ''A torch implementation of the paper A Neural Algorithm of Artistic Style'';
+    license = stdenv.lib.licenses.mit ;
+    maintainers = [stdenv.lib.maintainers.raskin];
+    # Eats a lot of RAM
+    platforms = ["x86_64-linux"];
+  };
+}
diff --git a/nixpkgs/pkgs/tools/graphics/neural-style/neural-style.sh b/nixpkgs/pkgs/tools/graphics/neural-style/neural-style.sh
new file mode 100644
index 000000000000..07a4d6dedc04
--- /dev/null
+++ b/nixpkgs/pkgs/tools/graphics/neural-style/neural-style.sh
@@ -0,0 +1,25 @@
+#! @bash@/bin/bash
+
+declare -a args
+c=1
+flag=
+
+for arg in "$@"; do
+        if test "$arg" = "${arg#-}" && test "$arg" = "${arg#/}" && test -n "$flag"; then
+                arg="$PWD/$arg"
+                flag=
+        elif test "$arg" != "${arg%_image}" && test "$arg" != "${arg#-}"; then
+                flag=1
+        else
+                flag=
+        fi
+        args[c]="$arg";
+        c=$((c+1));
+done
+
+cd "@out@/lib/lua/neural-style"
+
+export LUA_PATH="$LUA_PATH${LUA_PATH:+;}@loadcaffe@/lua/?/init.lua;@loadcaffe@/lua/?.lua"
+export LUA_CPATH="$LUA_CPATH${LUA_CPATH:+;}@loadcaffe@/lib/?.so"
+
+@torch@/bin/th neural_style.lua "${args[@]}"
diff --git a/nixpkgs/pkgs/tools/graphics/nifskope/default.nix b/nixpkgs/pkgs/tools/graphics/nifskope/default.nix
new file mode 100644
index 000000000000..c5651d0418e4
--- /dev/null
+++ b/nixpkgs/pkgs/tools/graphics/nifskope/default.nix
@@ -0,0 +1,68 @@
+{ stdenv, fetchFromGitHub, qmake, qtbase, qttools, substituteAll, libGLU, makeWrapper }:
+
+stdenv.mkDerivation rec {
+  name = "nifskope-${version}";
+  version = "2.0.dev7";
+
+  src = fetchFromGitHub {
+    owner = "niftools";
+    repo = "nifskope";
+    rev = "47b788d26ae0fa12e60e8e7a4f0fa945a510c7b2"; # `v${version}` doesn't work with submodules
+    sha256 = "1wqpn53rkq28ws3apqghkzyrib4wis91x171ns64g8kp4q6mfczi";
+    fetchSubmodules = true;
+  };
+
+  patches = [
+    ./external-lib-paths.patch
+    (substituteAll {
+      src = ./qttools-bins.patch;
+      qttools = "${qttools.dev}/bin";
+    })
+  ];
+
+  buildInputs = [ qtbase qttools libGLU.dev makeWrapper ];
+  nativeBuildInputs = [ qmake ];
+
+  preConfigure = ''
+    shopt -s globstar
+    for i in **/*.cpp; do
+      substituteInPlace $i --replace /usr/share/nifskope $out/share/nifskope
+    done
+  '';
+
+  enableParallelBuilding = true;
+
+  # Inspired by install/linux-install/nifskope.spec.in.
+  installPhase = let
+    qtVersion = "5.${stdenv.lib.versions.minor qtbase.version}";
+  in ''
+    runHook preInstall
+
+    d=$out/share/nifskope
+    mkdir -p $out/bin $out/share/applications $out/share/pixmaps $d/{shaders,lang}
+    cp release/NifSkope $out/bin/
+    cp ./res/nifskope.png $out/share/pixmaps/
+    cp release/{nif.xml,kfm.xml,style.qss} $d/
+    cp res/shaders/*.frag res/shaders/*.prog res/shaders/*.vert $d/shaders/
+    cp ./res/lang/*.ts ./res/lang/*.tm $d/lang/
+    cp ./install/linux-install/nifskope.desktop $out/share/applications
+
+    substituteInPlace $out/share/applications/nifskope.desktop \
+      --replace 'Exec=nifskope' "Exec=$out/bin/NifSkope" \
+      --replace 'Icon=nifskope' "Icon=$out/share/pixmaps/nifskope.png"
+
+    find $out/share -type f -exec chmod -x {} \;
+
+    wrapProgram $out/bin/NifSkope --prefix QT_PLUGIN_PATH : "${qtbase}/lib/qt-${qtVersion}/plugins"
+
+    runHook postInstall
+  '';
+
+  meta = with stdenv.lib; {
+    homepage = http://niftools.sourceforge.net/wiki/NifSkope;
+    description = "A tool for analyzing and editing NetImmerse/Gamebryo '*.nif' files";
+    maintainers = with maintainers; [ eelco ma27 ];
+    platforms = platforms.linux;
+    license = licenses.bsd3;
+  };
+}
diff --git a/nixpkgs/pkgs/tools/graphics/nifskope/external-lib-paths.patch b/nixpkgs/pkgs/tools/graphics/nifskope/external-lib-paths.patch
new file mode 100644
index 000000000000..a7f329caf74f
--- /dev/null
+++ b/nixpkgs/pkgs/tools/graphics/nifskope/external-lib-paths.patch
@@ -0,0 +1,33 @@
+diff --git a/NifSkope.pro b/NifSkope.pro
+index 1c0bc5a..cc29fc5 100644
+--- a/NifSkope.pro
++++ b/NifSkope.pro
+@@ -330,14 +330,14 @@ nvtristrip {
+ }
+ 
+ qhull {
+-    !*msvc*:QMAKE_CFLAGS += -isystem ../nifskope/lib/qhull/src
+-    !*msvc*:QMAKE_CXXFLAGS += -isystem ../nifskope/lib/qhull/src
++    !*msvc*:QMAKE_CFLAGS += -isystem ./lib/qhull/src
++    !*msvc*:QMAKE_CXXFLAGS += -isystem ./lib/qhull/src
+     else:INCLUDEPATH += lib/qhull/src
+     HEADERS += $$files($$PWD/lib/qhull/src/libqhull/*.h, false)
+ }
+ 
+ gli {
+-    !*msvc*:QMAKE_CXXFLAGS += -isystem ../nifskope/lib/gli/gli -isystem ../nifskope/lib/gli/external
++    !*msvc*:QMAKE_CXXFLAGS += -isystem ./lib/gli/gli -isystem ./lib/gli/external
+     else:INCLUDEPATH += lib/gli/gli lib/gli/external
+     HEADERS += $$files($$PWD/lib/gli/gli/*.hpp, true)
+     HEADERS += $$files($$PWD/lib/gli/gli/*.inl, true)
+@@ -346,8 +346,8 @@ gli {
+ }
+ 
+ zlib {
+-    !*msvc*:QMAKE_CFLAGS += -isystem ../nifskope/lib/zlib
+-    !*msvc*:QMAKE_CXXFLAGS += -isystem ../nifskope/lib/zlib
++    !*msvc*:QMAKE_CFLAGS += -isystem ./lib/zlib
++    !*msvc*:QMAKE_CXXFLAGS += -isystem ./lib/zlib
+     else:INCLUDEPATH += lib/zlib
+     HEADERS += $$files($$PWD/lib/zlib/*.h, false)
+     SOURCES += $$files($$PWD/lib/zlib/*.c, false)
diff --git a/nixpkgs/pkgs/tools/graphics/nifskope/qttools-bins.patch b/nixpkgs/pkgs/tools/graphics/nifskope/qttools-bins.patch
new file mode 100644
index 000000000000..5d85f9ef4fdd
--- /dev/null
+++ b/nixpkgs/pkgs/tools/graphics/nifskope/qttools-bins.patch
@@ -0,0 +1,22 @@
+diff --git a/NifSkope_targets.pri b/NifSkope_targets.pri
+index 05324c2..d8389b1 100644
+--- a/NifSkope_targets.pri
++++ b/NifSkope_targets.pri
+@@ -11,7 +11,7 @@ else:EXE = ""
+ ## lupdate / lrelease
+ ###############################
+ 
+-QMAKE_LUPDATE = $$[QT_INSTALL_BINS]/lupdate$${EXE}
++QMAKE_LUPDATE = @qttools@/lupdate$${EXE}
+ exists($$QMAKE_LUPDATE) {
+ 	# Make target for Updating .ts
+ 	updatets.target = updatets
+@@ -23,7 +23,7 @@ exists($$QMAKE_LUPDATE) {
+ 	message("lupdate could not be found, ignoring make target")
+ }
+ 
+-QMAKE_LRELEASE = $$[QT_INSTALL_BINS]/lrelease$${EXE}
++QMAKE_LRELEASE = @qttools@/lrelease$${EXE}
+ exists($$QMAKE_LRELEASE) {
+ 	# Build Step for Releasing .ts->.qm
+ 	updateqm.input = TRANSLATIONS
diff --git a/nixpkgs/pkgs/tools/graphics/nip2/default.nix b/nixpkgs/pkgs/tools/graphics/nip2/default.nix
new file mode 100644
index 000000000000..d0ad0c27f20d
--- /dev/null
+++ b/nixpkgs/pkgs/tools/graphics/nip2/default.nix
@@ -0,0 +1,24 @@
+{ stdenv, fetchurl, pkgconfig, glib, libxml2, flex, bison, vips, gnome2,
+fftw, gsl, goffice, libgsf }:
+
+stdenv.mkDerivation rec {
+  name = "nip2-8.3.0";
+
+  src = fetchurl {
+    url = "http://www.vips.ecs.soton.ac.uk/supported/current/${name}.tar.gz";
+    sha256 = "0vr12gyfvhxx2a28y74lzfg379d1fk0g9isc69k0vdgpn4y1i8aa";
+  };
+
+  buildInputs =
+  [ pkgconfig glib libxml2 flex bison vips
+    gnome2.gtk fftw gsl goffice libgsf
+  ];
+
+  meta = with stdenv.lib; {
+    homepage = http://www.vips.ecs.soton.ac.uk;
+    description = "Graphical user interface for VIPS image processing system";
+    license = licenses.gpl2Plus;
+    maintainers = with maintainers; [ kovirobi ];
+    platforms = platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/tools/graphics/optar/default.nix b/nixpkgs/pkgs/tools/graphics/optar/default.nix
new file mode 100644
index 000000000000..bc1419070757
--- /dev/null
+++ b/nixpkgs/pkgs/tools/graphics/optar/default.nix
@@ -0,0 +1,35 @@
+{ stdenv, fetchurl, imagemagick, libpng }:
+
+stdenv.mkDerivation rec {
+  name = "optar-${version}";
+  version = "20150210";
+
+  src = fetchurl {
+    url    = "http://ronja.twibright.com/optar.tgz";
+    sha256 = "10lr31k3xfcpa6vxkbl3abph7j3gks2210489khnnzmhmfdnm1a4";
+  };
+
+  buildInputs = [ libpng ];
+
+  enableParallelBuilding = true;
+
+  postPatch = ''
+    substituteInPlace Makefile \
+      --replace /usr/local $out
+
+    substituteInPlace pgm2ps \
+      --replace 'convert ' "${stdenv.lib.getBin imagemagick}/bin/convert "
+  '';
+
+  preInstall = ''
+    mkdir -p $out/bin
+  '';
+
+  meta = with stdenv.lib; {
+    description = "Optar stands for OPTical ARchiver - it's a codec for encoding data on paper";
+    homepage = http://ronja.twibright.com/optar/;
+    license = licenses.gpl2;
+    maintainers = with maintainers; [ peterhoeg ];
+    platforms = with platforms; linux; # possibly others, but only tested on Linux
+  };
+}
diff --git a/nixpkgs/pkgs/tools/graphics/optipng/default.nix b/nixpkgs/pkgs/tools/graphics/optipng/default.nix
new file mode 100644
index 000000000000..bc849b21117f
--- /dev/null
+++ b/nixpkgs/pkgs/tools/graphics/optipng/default.nix
@@ -0,0 +1,42 @@
+{ stdenv, fetchurl, libpng, static ? false
+}:
+
+# This package comes with its own copy of zlib, libpng and pngxtern
+
+with stdenv.lib;
+
+stdenv.mkDerivation rec {
+  name = "optipng-0.7.7";
+
+  src = fetchurl {
+    url = "mirror://sourceforge/optipng/${name}.tar.gz";
+    sha256 = "0lj4clb851fzpaq446wgj0sfy922zs5l5misbpwv6w7qrqrz4cjg";
+  };
+
+  buildInputs = [ libpng ];
+
+  LDFLAGS = optional static "-static";
+  # Workaround for crash in cexcept.h. See
+  # https://github.com/NixOS/nixpkgs/issues/28106
+  preConfigure = ''
+    export LD=$CC
+  '';
+
+  configureFlags = [
+    "--with-system-zlib"
+    "--with-system-libpng"
+  ] ++ stdenv.lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [
+    #"-prefix=$out"
+  ];
+
+  postInstall = if stdenv.hostPlatform != stdenv.buildPlatform && stdenv.hostPlatform.isWindows then ''
+    mv "$out"/bin/optipng{,.exe}
+  '' else null;
+
+  meta = with stdenv.lib; {
+    homepage = http://optipng.sourceforge.net/;
+    description = "A PNG optimizer";
+    license = licenses.zlib;
+    platforms = platforms.unix;
+  };
+}
diff --git a/nixpkgs/pkgs/tools/graphics/oxipng/default.nix b/nixpkgs/pkgs/tools/graphics/oxipng/default.nix
new file mode 100644
index 000000000000..10b4dd4a0318
--- /dev/null
+++ b/nixpkgs/pkgs/tools/graphics/oxipng/default.nix
@@ -0,0 +1,26 @@
+{ stdenv, fetchFromGitHub, rustPlatform }:
+
+rustPlatform.buildRustPackage rec {
+  version = "2.1.8";
+  name = "oxipng-${version}";
+
+  src = fetchFromGitHub {
+    owner = "shssoichiro";
+    repo = "oxipng";
+    rev = "v${version}";
+    sha256 = "18ld65vm58s6x918g6bhfkrg7lw2lca8daidv88ff14wm5khjvik";
+  };
+
+  cargoSha256 = "034i8hgi0zgv085bimlja1hl3nd096rqpi167pw6rda5aj18c625";
+
+  meta = with stdenv.lib; {
+    homepage = https://github.com/shssoichiro/oxipng;
+    description = "A multithreaded lossless PNG compression optimizer";
+    license = licenses.mit;
+    maintainers = with maintainers; [ dywedir ];
+    platforms = platforms.all;
+
+    # Needs newer/unstable rust: error[E0658]: macro is_arm_feature_detected! is unstable
+    broken = stdenv.isAarch64;
+  };
+}
diff --git a/nixpkgs/pkgs/tools/graphics/pdf2svg/default.nix b/nixpkgs/pkgs/tools/graphics/pdf2svg/default.nix
new file mode 100644
index 000000000000..058900b8e237
--- /dev/null
+++ b/nixpkgs/pkgs/tools/graphics/pdf2svg/default.nix
@@ -0,0 +1,25 @@
+{ stdenv, fetchFromGitHub, autoreconfHook, pkgconfig
+, cairo, gtk2, poppler }:
+
+stdenv.mkDerivation rec {
+  name = "pdf2svg-${version}";
+  version = "0.2.3";
+
+  src = fetchFromGitHub {
+    owner = "db9052";
+    repo = "pdf2svg";
+    rev = "v${version}";
+    sha256 = "14ffdm4y26imq99wjhkrhy9lp33165xci1l5ndwfia8hz53bl02k";
+  };
+
+  nativeBuildInputs = [ autoreconfHook pkgconfig ];
+  buildInputs = [ cairo poppler gtk2 ];
+
+  meta = with stdenv.lib; {
+    description = "PDF converter to SVG format";
+    homepage = http://www.cityinthesky.co.uk/opensource/pdf2svg;
+    license = licenses.gpl2;
+    maintainers = [ maintainers.ianwookim ];
+    platforms = platforms.unix;
+  };
+}
diff --git a/nixpkgs/pkgs/tools/graphics/pdfread/default.nix b/nixpkgs/pkgs/tools/graphics/pdfread/default.nix
new file mode 100644
index 000000000000..8733b2c1caa0
--- /dev/null
+++ b/nixpkgs/pkgs/tools/graphics/pdfread/default.nix
@@ -0,0 +1,50 @@
+{stdenv, fetchurl, unzip, python, makeWrapper, ghostscript, pngnq, pillow, djvulibre
+, optipng, unrar}:
+
+stdenv.mkDerivation {
+  name = "pdfread-1.8.2";
+
+  src = fetchurl {
+    # I got it from http://www.mobileread.com/forums/showthread.php?t=21906
+    # But that needs user registration to allow downloading.
+    # This is an evolution from pdfread 1.7 in http://pdfread.sourceforge.net/
+    # Temporary place:
+    url = http://vicerveza.homeunix.net/~viric/soft/PDFRead-1.8.2-Source-noGUI-noInstaller.zip;
+    sha256 = "0mzxpnk97f0ww5ds7h4wsval3g4lnrhv6rhspjs7cy4i41gmk8an";
+  };
+
+  buildInputs = [ unzip python makeWrapper ];
+
+  broken = true; # Not found.
+
+  phases = "unpackPhase patchPhase installPhase";
+
+  unpackPhase = ''
+    unzip $src
+    sourceRoot=`pwd`/PDFRead/src
+  '';
+
+  patchPhase = ''
+    sed -i 's,#!/usr.*,#!${python}/bin/python,' pdfread.py
+  '';
+
+  installPhase = ''
+    mkdir -p $out/bin
+    cp pdfread.py $out/bin
+    chmod +x $out/bin/pdfread.py
+
+    LIBSUFFIX=lib/${python.libPrefix}/site-packages/
+    PYDIR=$out/$LIBSUFFIX
+    mkdir -p $PYDIR
+    cp -R *.py pylrs $PYDIR
+
+    wrapProgram $out/bin/pdfread.py --prefix PYTHONPATH : $PYTHONPATH:${pillow}/$LIBSUFFIX/PIL:$PYDIR \
+      --prefix PATH : ${stdenv.lib.makeBinPath [ ghostscript pngnq djvulibre unrar optipng ]}
+  '';
+
+  meta = with stdenv.lib; {
+    description = "PDF/DJVU to ebook format converter";
+    homepage = https://www.mobileread.com/forums/showthread.php?t=21906;
+    license = licenses.mit;
+  };
+}
diff --git a/nixpkgs/pkgs/tools/graphics/pdfredacttools/default.nix b/nixpkgs/pkgs/tools/graphics/pdfredacttools/default.nix
new file mode 100644
index 000000000000..28b13c782b91
--- /dev/null
+++ b/nixpkgs/pkgs/tools/graphics/pdfredacttools/default.nix
@@ -0,0 +1,38 @@
+{ stdenv, fetchFromGitHub, python2Packages, imagemagick, exiftool, file, ghostscript }:
+
+python2Packages.buildPythonApplication rec {
+  pname = "pdf-redact-tools";
+  version = "0.1.2";
+
+  src = fetchFromGitHub {
+    owner = "firstlookmedia";
+    repo = pname;
+    rev = "v${version}";
+    sha256 = "01vs1bc0pfgk6x2m36vwra605fg59yc31d0hl9jmj86n8q6wwvss";
+  };
+
+  patchPhase = ''substituteInPlace pdf-redact-tools      \
+    --replace \'convert\' \'${imagemagick}/bin/convert\' \
+    --replace \'exiftool\' \'${exiftool}/bin/exiftool\'  \
+    --replace \'file\' \'${file}/bin/file\'
+   '';
+
+  propagatedBuildInputs = [ imagemagick exiftool ghostscript ];
+
+  meta = with stdenv.lib; {
+    description = "Redact and strip metadata from documents before publishing";
+    longDescription = ''
+	PDF Redact Tools helps with securely redacting and stripping metadata
+	from documents before publishing. Note that this is not a security tool.
+        It uses ImageMagick to parse PDFs.  While ImageMagick is a versatile tool, it has
+        a history of several security bugs. A malicious PDF could exploit a bug in
+        ImageMagick to take over your computer. If you're working with potentially
+        malicious PDFs, it's safest to run them through PDF Redact Tools in an isolated
+        environment, such as a virtual machine, or by using a tool such as the Qubes
+        PDF Converter instead.
+    '';
+    platforms = platforms.all;
+    license = licenses.gpl3;
+    maintainers = with maintainers; [ leenaars ];
+  };
+}
diff --git a/nixpkgs/pkgs/tools/graphics/pdftag/default.nix b/nixpkgs/pkgs/tools/graphics/pdftag/default.nix
new file mode 100644
index 000000000000..8428480ca037
--- /dev/null
+++ b/nixpkgs/pkgs/tools/graphics/pdftag/default.nix
@@ -0,0 +1,25 @@
+{ stdenv, fetchFromGitHub, pkgconfig, meson, vala, ninja
+, gtk3, poppler, wrapGAppsHook }:
+
+stdenv.mkDerivation rec {
+  pname = "pdftag";
+  name = "${pname}-${version}";
+  version = "1.0.5";
+
+  src = fetchFromGitHub {
+    owner = "arrufat";
+    repo = pname;
+    rev = "v${version}";
+    sha256 = "1paj8hs27akzsivn01a30fl3zx5gfn1h89wxg2m72fd806hk0hql";
+  };
+
+  nativeBuildInputs = [ pkgconfig meson ninja wrapGAppsHook vala ];
+  buildInputs = [ gtk3 poppler ];
+
+  meta = with stdenv.lib; {
+    description = "Edit metadata found in PDFs";
+    license = licenses.gpl3;
+    maintainers = with maintainers; [ leenaars ];
+    platforms = platforms.unix;
+  };
+}
diff --git a/nixpkgs/pkgs/tools/graphics/perceptualdiff/default.nix b/nixpkgs/pkgs/tools/graphics/perceptualdiff/default.nix
new file mode 100644
index 000000000000..d394a816a49d
--- /dev/null
+++ b/nixpkgs/pkgs/tools/graphics/perceptualdiff/default.nix
@@ -0,0 +1,25 @@
+{ stdenv, fetchFromGitHub, cmake, freeimage }:
+
+stdenv.mkDerivation rec {
+  pname = "perceptualdiff";
+  name = "${pname}-${version}";
+  version = "2.1";
+
+  src = fetchFromGitHub {
+    owner = "myint";
+    repo = pname;
+    rev = "v${version}";
+    sha256 = "176n518xv0pczf1yyz9r5a8zw5r6sh5ym596kmvw30qznp8n4a8j";
+  };
+
+  nativeBuildInputs = [ cmake ];
+  buildInputs = [ freeimage ];
+
+  meta = with stdenv.lib; {
+    description = "A program that compares two images using a perceptually based image metric";
+    homepage = "https://github.com/myint/perceptualdiff";
+    license = licenses.gpl2;
+    maintainers = with maintainers; [ uri-canva ];
+    platforms = platforms.x86;
+  };
+}
diff --git a/nixpkgs/pkgs/tools/graphics/pfstools/default.nix b/nixpkgs/pkgs/tools/graphics/pfstools/default.nix
new file mode 100644
index 000000000000..4c1ff5024331
--- /dev/null
+++ b/nixpkgs/pkgs/tools/graphics/pfstools/default.nix
@@ -0,0 +1,37 @@
+{ stdenv, fetchurl, cmake, pkgconfig
+, openexr, zlib, imagemagick, libGLU_combined, freeglut, fftwFloat
+, fftw, gsl, libexif, perl, opencv, qt4
+}:
+
+stdenv.mkDerivation rec {
+  name = "${pname}-${version}";
+  pname = "pfstools";
+  version = "2.1.0";
+
+  src = fetchurl {
+    url = "mirror://sourceforge/${pname}/${version}/${name}.tgz";
+    sha256 = "04rlb705gmdiphcybf9dyr0d5lla2cfs3c308zz37x0vwi445six";
+  };
+
+  outputs = [ "out" "dev" "man"];
+
+  cmakeFlags = ''
+    -DWITH_MATLAB=false 
+  '';
+
+  nativeBuildInputs = [ cmake pkgconfig ];
+  buildInputs = [
+    openexr zlib imagemagick libGLU_combined freeglut fftwFloat
+    fftw gsl libexif perl opencv qt4
+  ];
+
+  patches = [ ./threads.patch ./pfstools.patch ];
+
+  meta = with stdenv.lib; {
+    homepage = http://pfstools.sourceforge.net/;
+    description = "Toolkit for manipulation of HDR images";
+    platforms = platforms.linux;
+    license = licenses.lgpl2;
+    maintainers = [ maintainers.juliendehos ];
+  };
+}
diff --git a/nixpkgs/pkgs/tools/graphics/pfstools/pfstools.patch b/nixpkgs/pkgs/tools/graphics/pfstools/pfstools.patch
new file mode 100644
index 000000000000..c678a25b01bd
--- /dev/null
+++ b/nixpkgs/pkgs/tools/graphics/pfstools/pfstools.patch
@@ -0,0 +1,21 @@
+--- a/CMakeLists.txt	2016-05-26 11:31:16.000000000 +0200
++++ b/CMakeLists.txt	2016-07-22 19:07:22.074669909 +0200
+@@ -320,12 +320,12 @@
+ 
+ # ======== libexif ==========
+ 
+-find_package(EXIF)
+-if( NOT EXIF_FOUND )
+-    message( "EXIF library (libexif) not found. 'pfsalign' will not be compiled" )
+-else( NOT EXIF_FOUND )
+-    message(STATUS "libexif library found.")  
+-endif( NOT EXIF_FOUND )
++find_package( PkgConfig REQUIRED )
++pkg_check_modules( MYPKG REQUIRED libexif IlmBase )
++if( MYPKG_FOUND )
++    message( STATUS "libexif and IlmBase found." )
++endif( MYPKG_FOUND )
++include_directories( ${MYPKG_INCLUDE_DIRS} )
+ 
+ # ======== Config and sub dirs ===========
+ 
diff --git a/nixpkgs/pkgs/tools/graphics/pfstools/threads.patch b/nixpkgs/pkgs/tools/graphics/pfstools/threads.patch
new file mode 100644
index 000000000000..e3f61db60899
--- /dev/null
+++ b/nixpkgs/pkgs/tools/graphics/pfstools/threads.patch
@@ -0,0 +1,20 @@
+--- a/src/fileformat/CMakeLists.txt	2016-05-26 11:31:23.000000000 +0200
++++ b/src/fileformat/CMakeLists.txt	2016-07-21 23:19:56.510958771 +0200
+@@ -53,13 +53,15 @@
+ if( OPENEXR_FOUND )
+     include_directories("${OPENEXR_INCLUDE_DIR}")
+ 
++    find_package (Threads)
++
+     add_executable(pfsinexr pfsinexr.cpp "${GETOPT_OBJECT}")
+-    target_link_libraries(pfsinexr pfs ${OPENEXR_LIBRARIES})
++    target_link_libraries(pfsinexr pfs ${OPENEXR_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
+     install (TARGETS pfsinexr DESTINATION bin)
+     install (FILES pfsinexr.1 DESTINATION ${MAN_DIR})
+ 
+     add_executable(pfsoutexr pfsoutexr.cpp "${GETOPT_OBJECT}")
+-    target_link_libraries(pfsoutexr pfs ${OPENEXR_LIBRARIES})
++    target_link_libraries(pfsoutexr pfs ${OPENEXR_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
+     install (TARGETS pfsoutexr DESTINATION bin)
+     install (FILES pfsoutexr.1 DESTINATION ${MAN_DIR})
+  endif( OPENEXR_FOUND )
diff --git a/nixpkgs/pkgs/tools/graphics/pgf/default.nix b/nixpkgs/pkgs/tools/graphics/pgf/default.nix
new file mode 100644
index 000000000000..c91c18e3f0b6
--- /dev/null
+++ b/nixpkgs/pkgs/tools/graphics/pgf/default.nix
@@ -0,0 +1,33 @@
+{ stdenv, fetchurl, autoconf, automake, libtool, dos2unix, libpgf, freeimage, doxygen }:
+
+with stdenv.lib;
+
+let
+  version = "6.14.12";
+in
+stdenv.mkDerivation {
+  name = "pgf-${version}";
+
+  src = fetchurl {
+    url = "mirror://sourceforge/libpgf/pgf-console-src-${version}.tar.gz";
+    sha256 = "1vfm12cfq3an3xg0679bcwdmjq2x1bbij1iwsmm60hwmrm3zvab0";
+  };
+
+  buildInputs = [ autoconf automake libtool dos2unix libpgf freeimage doxygen ];
+
+  patchPhase = ''
+      sed 1i'#include <inttypes.h>' -i src/PGF.cpp
+      sed s/__int64/int64_t/g -i src/PGF.cpp
+  '';
+
+  preConfigure = "dos2unix configure.ac; sh autogen.sh";
+
+# configureFlags = optional static "--enable-static --disable-shared";
+
+  meta = {
+    homepage = http://www.libpgf.org/;
+    description = "Progressive Graphics Format command line program";
+    license = stdenv.lib.licenses.lgpl21Plus;
+    platforms = stdenv.lib.platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/tools/graphics/ploticus/builder.sh b/nixpkgs/pkgs/tools/graphics/ploticus/builder.sh
new file mode 100644
index 000000000000..2fb16b259bdc
--- /dev/null
+++ b/nixpkgs/pkgs/tools/graphics/ploticus/builder.sh
@@ -0,0 +1,33 @@
+source $stdenv/setup
+
+preBuild() {
+  cd src
+}
+
+preInstall() {
+  mkdir -p $out/bin
+}
+
+postInstall() {
+  # Install the "prefabs".
+  mkdir -p $out/share/ploticus/prefabs &&		\
+  cd .. &&						\
+  cp -rv prefabs/* $out/share/ploticus/prefabs
+
+  # Create a wrapper that knows where to find them.  Debian's package
+  # does something similar by patching directly the C file that looks
+  # for `$PLOTICUS_PREFABS'.
+  cat > $out/bin/ploticus <<EOF
+#! $SHELL -e
+PLOTICUS_PREFABS="$out/share/ploticus/prefabs"
+export PLOTICUS_PREFABS
+exec "$out/bin/pl" \$@
+EOF
+  chmod +x $out/bin/ploticus
+
+  # Install the man pages.
+  cp -rv man $out
+  ln -s "$out/man/man1/pl.1" "$out/man/man1/ploticus.1"
+}
+
+genericBuild
diff --git a/nixpkgs/pkgs/tools/graphics/ploticus/default.nix b/nixpkgs/pkgs/tools/graphics/ploticus/default.nix
new file mode 100644
index 000000000000..d0e678578723
--- /dev/null
+++ b/nixpkgs/pkgs/tools/graphics/ploticus/default.nix
@@ -0,0 +1,37 @@
+{stdenv, fetchurl, zlib, libX11, libpng}:
+
+stdenv.mkDerivation {
+  name = "ploticus-2.42";
+
+  builder = ./builder.sh;
+  src = fetchurl {
+    url = mirror://sourceforge/ploticus/ploticus/2.41/pl241src.tar.gz;
+    sha256 = "1065r0nizjixi9sxxfxrnwg10r458i6fgsd23nrxa200rypvdk7c";
+  };
+
+  buildInputs = [ zlib libX11 libpng ];
+
+  hardeningDisable = [ "format" ];
+
+  patches = [ ./ploticus-install.patch ];
+
+  # Make the symlink relative instead of absolute.
+  # Otherwise it breaks when auto-moved to $out/share.
+  preFixup = ''
+    ln -sf pl.1 "$out"/man/man1/ploticus.1
+  '';
+
+  meta = with stdenv.lib; {
+    description = "A non-interactive software package for producing plots and charts";
+    longDescription = ''Ploticus is a free, GPL'd, non-interactive
+      software package for producing plots, charts, and graphics from
+      data.  Ploticus is good for automated or just-in-time graph
+      generation, handles date and time data nicely, and has basic
+      statistical capabilities.  It allows significant user control
+      over colors, styles, options and details.'';
+    license = licenses.gpl2Plus;
+    maintainers = with maintainers; [ pSub ];
+    homepage = http://ploticus.sourceforge.net/;
+    platforms = with platforms; linux;
+  };
+}
diff --git a/nixpkgs/pkgs/tools/graphics/ploticus/ploticus-install.patch b/nixpkgs/pkgs/tools/graphics/ploticus/ploticus-install.patch
new file mode 100644
index 000000000000..04edbc709d0a
--- /dev/null
+++ b/nixpkgs/pkgs/tools/graphics/ploticus/ploticus-install.patch
@@ -0,0 +1,12 @@
+--- pl240src/src/Makefile	2008-01-15 21:05:14.000000000 +0100
++++ pl240src/src/Makefile	2008-03-26 23:51:53.000000000 +0100
+@@ -131,7 +131,7 @@ ZFLAG = -DWZ
+ 
+ 
+ #### If you do a "make install", where do you want the executable(s) to be moved to?
+-INSTALLBIN = /usr/local/bin
++INSTALLBIN = $(out)/bin
+ 
+ 
+ #### For LOCALE support (non-roman alphabets & collation), uncomment the following..
+
diff --git a/nixpkgs/pkgs/tools/graphics/plotutils/debian-patches.nix b/nixpkgs/pkgs/tools/graphics/plotutils/debian-patches.nix
new file mode 100644
index 000000000000..d7c60a11eb67
--- /dev/null
+++ b/nixpkgs/pkgs/tools/graphics/plotutils/debian-patches.nix
@@ -0,0 +1,42 @@
+# Generated by debian-patches.sh from debian-patches.txt
+let
+  prefix = "https://sources.debian.org/data/main/p/plotutils/2.6-9/debian/patches";
+in
+[
+  {
+    url = "${prefix}/01_AC_PROG_CXX.diff";
+    sha256 = "0r7xgwbk2yqs7b29gwhr8pnbqvy3a3x698j17s4yg501ragw1gqv";
+  }
+  {
+    url = "${prefix}/10_repair_postscript";
+    sha256 = "01v4a8mdhgsjxbf9a2xppx2lb05lp818v8afp5x2njv64wpgla8p";
+  }
+  {
+    url = "${prefix}/11_manpages_sb_macro";
+    sha256 = "01vvhznw5z7lb7afwgw53cwg8w676s4v30kychlrl8kn5yks94qs";
+  }
+  {
+    url = "${prefix}/14_manpage_spline";
+    sha256 = "1xp3cx9y9njp5wp40dkp7rwd2flkiik2gb08nh4516vkm73avfrd";
+  }
+  {
+    url = "${prefix}/20_svg_attribute_syntax";
+    sha256 = "0vy089w00x2zh87igv3dcqq7kggqxpc4javb694pa5xl5bvddnqk";
+  }
+  {
+    url = "${prefix}/21_plot2svg_test.diff";
+    sha256 = "0lv8hj9fiqj6z72pnaw3imk3164n1kcy5ym0j9jl2pn3a19p1jmb";
+  }
+  {
+    url = "${prefix}/25_libpng15";
+    sha256 = "0l640rcsgc2mwpk7iqm0cf3b0gfcdgcn9wg4x88gaqxzx9rriph0";
+  }
+  {
+    url = "${prefix}/30_hershey_glyphs";
+    sha256 = "0n7rn6ln9ikzq2dialif58ag5pch7q7zqd5zcsxxdyyasx4s5gm2";
+  }
+  {
+    url = "${prefix}/35_spline.test.error.diff";
+    sha256 = "1kqj1n8myk8xmglj6qcybj34zm4kpn6aw320jbpqhblkgp7m0fb1";
+  }
+]
diff --git a/nixpkgs/pkgs/tools/graphics/plotutils/debian-patches.txt b/nixpkgs/pkgs/tools/graphics/plotutils/debian-patches.txt
new file mode 100644
index 000000000000..c28d96fdd5bc
--- /dev/null
+++ b/nixpkgs/pkgs/tools/graphics/plotutils/debian-patches.txt
@@ -0,0 +1,10 @@
+plotutils/2.6-9
+01_AC_PROG_CXX.diff
+10_repair_postscript
+11_manpages_sb_macro
+14_manpage_spline
+20_svg_attribute_syntax
+21_plot2svg_test.diff
+25_libpng15
+30_hershey_glyphs
+35_spline.test.error.diff
diff --git a/nixpkgs/pkgs/tools/graphics/plotutils/default.nix b/nixpkgs/pkgs/tools/graphics/plotutils/default.nix
new file mode 100644
index 000000000000..61e21b1a33da
--- /dev/null
+++ b/nixpkgs/pkgs/tools/graphics/plotutils/default.nix
@@ -0,0 +1,58 @@
+{ fetchurl, stdenv, libpng, autoreconfHook }:
+
+# debian splits this package into plotutils and libplot2c2
+
+# gentoo passes X, this package contains fonts
+# I'm only interested in making pstoedit convert to svg
+
+stdenv.mkDerivation rec {
+  name = "plotutils-2.6";
+
+  src = fetchurl {
+    url = "mirror://gnu/plotutils/${name}.tar.gz";
+    sha256 = "1arkyizn5wbgvbh53aziv3s6lmd3wm9lqzkhxb3hijlp1y124hjg";
+  };
+
+  nativeBuildInputs = [ autoreconfHook ];
+  buildInputs = [ libpng ];
+  patches = map fetchurl (import ./debian-patches.nix);
+
+  preBuild = ''
+    # Fix parallel building.
+    make -C libplot xmi.h
+  '';
+
+  configureFlags = [ "--enable-libplotter" ]; # required for pstoedit
+
+  hardeningDisable = [ "format" ];
+
+  doCheck = true;
+
+  enableParallelBuilding = true;
+
+  meta = {
+    description = "Powerful C/C++ library for exporting 2D vector graphics";
+
+    longDescription =
+      '' The GNU plotutils package contains software for both programmers and
+         technical users.  Its centerpiece is libplot, a powerful C/C++
+         function library for exporting 2-D vector graphics in many file
+         formats, both vector and raster.  It can also do vector graphics
+         animations.
+
+         libplot is device-independent in the sense that its API (application
+         programming interface) does not depend on the type of graphics file
+         to be exported.
+
+         Besides libplot, the package contains command-line programs for
+         plotting scientific data.  Many of them use libplot to export
+         graphics.
+      '';
+
+    homepage = https://www.gnu.org/software/plotutils/;
+
+    license = stdenv.lib.licenses.gpl2Plus;
+    maintainers = [ stdenv.lib.maintainers.marcweber ];
+    platforms = stdenv.lib.platforms.unix;
+  };
+}
diff --git a/nixpkgs/pkgs/tools/graphics/pngcheck/default.nix b/nixpkgs/pkgs/tools/graphics/pngcheck/default.nix
new file mode 100644
index 000000000000..6814a06e3b95
--- /dev/null
+++ b/nixpkgs/pkgs/tools/graphics/pngcheck/default.nix
@@ -0,0 +1,30 @@
+{ stdenv, fetchurl, zlib }:
+
+stdenv.mkDerivation rec {
+  name = "pngcheck-2.3.0";
+
+  src = fetchurl {
+    url = "mirror://sourceforge/png-mng/${name}.tar.gz";
+    sha256 = "0pzkj1bb4kdybk6vbfq9s0wzdm5szmrgixkas3xmbpv4mhws1w3p";
+  };
+
+  hardeningDisable = [ "format" ];
+
+  makefile = "Makefile.unx";
+  makeFlags = "ZPATH=${zlib.static}/lib";
+
+  buildInputs = [ zlib ];
+
+  installPhase = ''
+    mkdir -p $out/bin/
+    cp pngcheck $out/bin/pngcheck
+  '';
+
+  meta = {
+    homepage = http://pmt.sourceforge.net/pngcrush;
+    description = "Verifies the integrity of PNG, JNG and MNG files";
+    license = stdenv.lib.licenses.free;
+    platforms = with stdenv.lib.platforms; linux;
+    maintainers = with stdenv.lib.maintainers; [ the-kenny ];
+  };
+}
diff --git a/nixpkgs/pkgs/tools/graphics/pngcrush/default.nix b/nixpkgs/pkgs/tools/graphics/pngcrush/default.nix
new file mode 100644
index 000000000000..fce1f3f913cf
--- /dev/null
+++ b/nixpkgs/pkgs/tools/graphics/pngcrush/default.nix
@@ -0,0 +1,26 @@
+{ stdenv, fetchurl, libpng }:
+
+stdenv.mkDerivation rec {
+  name = "pngcrush-1.8.13";
+
+  src = fetchurl {
+    url = "mirror://sourceforge/pmt/${name}-nolib.tar.xz";
+    sha256 = "0l43c59d6v9l0g07z3q3ywhb8xb3vz74llv3mna0izk9bj6aqkiv";
+  };
+
+  makeFlags = [ "CC=cc" "LD=cc" ];      # gcc and/or clang compat
+
+  configurePhase = ''
+    sed -i s,/usr,$out, Makefile
+  '';
+
+  buildInputs = [ libpng ];
+
+  meta = {
+    homepage = http://pmt.sourceforge.net/pngcrush;
+    description = "A PNG optimizer";
+    license = stdenv.lib.licenses.free;
+    platforms = with stdenv.lib.platforms; linux ++ darwin;
+    maintainers = with stdenv.lib.maintainers; [ the-kenny ];
+  };
+}
diff --git a/nixpkgs/pkgs/tools/graphics/pngnq/default.nix b/nixpkgs/pkgs/tools/graphics/pngnq/default.nix
new file mode 100644
index 000000000000..e01f3ea2acc5
--- /dev/null
+++ b/nixpkgs/pkgs/tools/graphics/pngnq/default.nix
@@ -0,0 +1,25 @@
+{ stdenv, fetchurl, pkgconfig, libpng, zlib }:
+
+stdenv.mkDerivation rec {
+  name = "pngnq-1.1";
+
+  src = fetchurl {
+    url = "mirror://sourceforge/pngnq/${name}.tar.gz";
+    sha256 = "1qmnnl846agg55i7h4vmrn11lgb8kg6gvs8byqz34bdkjh5gwiy1";
+  };
+
+  nativeBuildInputs = [ pkgconfig ];
+  buildInputs = [ libpng zlib ];
+
+  patchPhase = ''
+    sed -i '/png.h/a \#include <zlib.h>' src/rwpng.c
+  '';
+
+  meta = with stdenv.lib; {
+    homepage = http://pngnq.sourceforge.net/;
+    description = "A PNG quantizer";
+    license = licenses.bsd3;
+    maintainers = with maintainers; [ pSub ];
+    platforms = platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/tools/graphics/pngout/default.nix b/nixpkgs/pkgs/tools/graphics/pngout/default.nix
new file mode 100644
index 000000000000..333e5f600765
--- /dev/null
+++ b/nixpkgs/pkgs/tools/graphics/pngout/default.nix
@@ -0,0 +1,33 @@
+{stdenv, fetchurl}:
+
+let
+  folder = if stdenv.hostPlatform.system == "i686-linux" then "i686"
+  else if stdenv.hostPlatform.system == "x86_64-linux" then "x86_64"
+  else throw "Unsupported system: ${stdenv.hostPlatform.system}";
+in
+stdenv.mkDerivation {
+  name = "pngout-20130221";
+
+  src = fetchurl {
+    url = http://static.jonof.id.au/dl/kenutils/pngout-20130221-linux.tar.gz;
+    sha256 = "1qdzmgx7si9zr7wjdj8fgf5dqmmqw4zg19ypg0pdz7521ns5xbvi";
+  };
+
+  installPhase = ''
+    mkdir -p $out/bin
+    cp ${folder}/pngout $out/bin
+    
+    ${if stdenv.hostPlatform.system == "i686-linux" then ''
+        patchelf --set-interpreter ${stdenv.glibc.out}/lib/ld-linux.so.2 $out/bin/pngout
+      '' else if stdenv.hostPlatform.system == "x86_64-linux" then ''
+        patchelf --set-interpreter ${stdenv.glibc.out}/lib/ld-linux-x86-64.so.2 $out/bin/pngout
+      '' else ""}
+  '';
+
+  meta = {
+    description = "A tool that aggressively optimizes the sizes of PNG images";
+    license = stdenv.lib.licenses.unfree;
+    homepage = http://advsys.net/ken/utils.htm;
+    maintainers = [ stdenv.lib.maintainers.sander ];
+  };
+}
diff --git a/nixpkgs/pkgs/tools/graphics/pngquant/default.nix b/nixpkgs/pkgs/tools/graphics/pngquant/default.nix
new file mode 100644
index 000000000000..4e7d1e361f91
--- /dev/null
+++ b/nixpkgs/pkgs/tools/graphics/pngquant/default.nix
@@ -0,0 +1,27 @@
+{ stdenv, fetchFromGitHub, pkgconfig, libpng, zlib, lcms2 }:
+
+stdenv.mkDerivation rec {
+  name = "pngquant-${version}";
+  version = "2.12.1";
+
+  src = fetchFromGitHub {
+    owner = "pornel";
+    repo = "pngquant";
+    rev = version;
+    sha256 = "0jdvry3kvmmxcgwf5a3zbfz0idl6yl3700ag7pf8sk4lg4qp0llp";
+    fetchSubmodules = true;
+  };
+
+  preConfigure = "patchShebangs .";
+
+  nativeBuildInputs = [ pkgconfig ];
+  buildInputs = [ libpng zlib lcms2 ];
+
+  meta = with stdenv.lib; {
+    homepage = https://pngquant.org/;
+    description = "A tool to convert 24/32-bit RGBA PNGs to 8-bit palette with alpha channel preserved";
+    platforms = platforms.unix;
+    license = licenses.gpl3;
+    maintainers = [ maintainers.volth ];
+  };
+}
diff --git a/nixpkgs/pkgs/tools/graphics/pngtoico/default.nix b/nixpkgs/pkgs/tools/graphics/pngtoico/default.nix
new file mode 100644
index 000000000000..e4163cd93a87
--- /dev/null
+++ b/nixpkgs/pkgs/tools/graphics/pngtoico/default.nix
@@ -0,0 +1,23 @@
+{ stdenv, fetchurl, libpng }:
+
+stdenv.mkDerivation rec {
+  name = "pngtoico-1.0";
+
+  src = fetchurl {
+    url = mirror://kernel/software/graphics/pngtoico/pngtoico-1.0.tar.gz;
+    sha256 = "1xb4aa57sjvgqfp01br3dm72hf7q0gb2ad144s1ifrs09215fgph";
+  };
+
+  configurePhase = ''
+    sed -i s,/usr/local,$out, Makefile
+  '';
+
+  buildInputs = [ libpng ];
+
+  meta = {
+    homepage = https://www.kernel.org/pub/software/graphics/pngtoico/;
+    description = "Small utility to convert a set of PNG images to Microsoft ICO format";
+    license = stdenv.lib.licenses.gpl2Plus;
+    platforms = with stdenv.lib.platforms; linux;
+  };
+}
diff --git a/nixpkgs/pkgs/tools/graphics/povray/default.nix b/nixpkgs/pkgs/tools/graphics/povray/default.nix
new file mode 100644
index 000000000000..76829b6b7271
--- /dev/null
+++ b/nixpkgs/pkgs/tools/graphics/povray/default.nix
@@ -0,0 +1,49 @@
+{ stdenv, fetchFromGitHub, autoconf, automake, boost
+, zlib, libpng, libjpeg, libtiff, xlibsWrapper, SDL
+}:
+
+stdenv.mkDerivation rec {
+  name = "povray-${version}";
+  version = "3.7.0.8";
+
+  src = fetchFromGitHub {
+    owner = "POV-Ray";
+    repo = "povray";
+    rev = "v${version}";
+    sha256 = "1q114n4m3r7qy3yn954fq7p46rg7ypdax5fazxr9yj1jklf1lh6z";
+  };
+
+
+  buildInputs = [ autoconf automake boost zlib libpng libjpeg libtiff xlibsWrapper SDL ];
+
+  # the installPhase wants to put files into $HOME. I let it put the files
+  # to $TMPDIR, so they don't get into the $out
+  postPatch = '' cd unix
+                 ./prebuild.sh
+                 cd ..
+                 sed -i -e 's/^povconfuser.*/povconfuser=$(TMPDIR)\/povray/' Makefile.{am,in}
+                 sed -i -e 's/^povuser.*/povuser=$(TMPDIR)\/.povray/' Makefile.{am,in}
+                 sed -i -e 's/^povowner.*/povowner=nobody/' Makefile.{am,in}
+                 sed -i -e 's/^povgroup.*/povgroup=nogroup/' Makefile.{am,in}
+               '';
+
+  configureFlags = [ "COMPILED_BY='nix'" "--with-boost-thread=boost_thread" "--with-x" ];
+
+  enableParallelBuilding = true;
+
+  preInstall = ''
+    mkdir "$TMP/bin"
+    for i in chown chgrp; do
+      echo '#!/bin/sh' >> "$TMP/bin/$i"
+      chmod +x "$TMP/bin/$i"
+      PATH="$TMP/bin:$PATH"
+    done
+  '';
+
+  meta = with stdenv.lib; {
+    homepage = http://www.povray.org/;
+    description = "Persistence of Vision Raytracer";
+    license = licenses.free;
+    platforms = platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/tools/graphics/pstoedit/default.nix b/nixpkgs/pkgs/tools/graphics/pstoedit/default.nix
new file mode 100644
index 000000000000..4f3e5271183d
--- /dev/null
+++ b/nixpkgs/pkgs/tools/graphics/pstoedit/default.nix
@@ -0,0 +1,39 @@
+{ stdenv, fetchurl, pkgconfig, darwin, lib
+, zlib, ghostscript, imagemagick, plotutils, gd
+, libjpeg, libwebp, libiconv
+}:
+
+stdenv.mkDerivation rec {
+  name = "pstoedit-3.73";
+
+  src = fetchurl {
+    url = "mirror://sourceforge/pstoedit/${name}.tar.gz";
+    sha256 = "147jkgvm9n6mbkl6ndqnm9x74x5y9agbxkfwj0jrw6yxyhxx2cdd";
+  };
+
+  #
+  # Turn on "-rdb" option (REALLYDELAYBIND) by default to ensure compatibility with gs-9.22
+  #
+  patches = [ ./pstoedit-gs-9.22-compat.patch  ];
+
+  outputs = [ "out" "dev" ];
+  nativeBuildInputs = [ pkgconfig ];
+  buildInputs = [ zlib ghostscript imagemagick plotutils gd libjpeg libwebp ]
+  ++ lib.optionals stdenv.isDarwin (with darwin.apple_sdk.frameworks; [
+    libiconv ApplicationServices
+  ]);
+
+  # '@LIBPNG_LDFLAGS@' is no longer substituted by autoconf (the code is commented out)
+  # so we need to remove it from the pkg-config file as well
+  preConfigure = ''
+    substituteInPlace config/pstoedit.pc.in --replace '@LIBPNG_LDFLAGS@' ""
+  '';
+
+  meta = with stdenv.lib; {
+    description = "Translates PostScript and PDF graphics into other vector formats";
+    homepage = https://sourceforge.net/projects/pstoedit/;
+    license = licenses.gpl2;
+    maintainers = [ maintainers.marcweber ];
+    platforms = platforms.unix;
+  };
+}
diff --git a/nixpkgs/pkgs/tools/graphics/pstoedit/pstoedit-gs-9.22-compat.patch b/nixpkgs/pkgs/tools/graphics/pstoedit/pstoedit-gs-9.22-compat.patch
new file mode 100644
index 000000000000..64fe805d5015
--- /dev/null
+++ b/nixpkgs/pkgs/tools/graphics/pstoedit/pstoedit-gs-9.22-compat.patch
@@ -0,0 +1,13 @@
+diff --git a/src/pstoeditoptions.h b/src/pstoeditoptions.h
+index 7846883..0fb6a6f 100755
+--- a/src/pstoeditoptions.h
++++ b/src/pstoeditoptions.h
+@@ -453,7 +453,7 @@ private:
+ 		"Later versions of Ghostscript will probably support -dDELAYBIND again. "
+ 		"But also in that case the security risk remains. So be careful with what "
+ 		"files you process with pstoedit and Ghostscript.",
+-		false),	//
++		true),	//
+ #endif
+ 	pagetoextract		(true, "-page","page number",g_t,"extract a specific page: 0 means all pages",
+ 		"Select a single page from a multi-page PostScript or PDF file.",
diff --git a/nixpkgs/pkgs/tools/graphics/qrcode/default.nix b/nixpkgs/pkgs/tools/graphics/qrcode/default.nix
new file mode 100644
index 000000000000..44444e6148ab
--- /dev/null
+++ b/nixpkgs/pkgs/tools/graphics/qrcode/default.nix
@@ -0,0 +1,28 @@
+{ stdenv, fetchFromGitHub }:
+
+stdenv.mkDerivation rec {
+  name = "qrcode-git-${version}";
+  version = "20160804";
+
+  src = fetchFromGitHub {
+    owner  = "qsantos";
+    repo   = "qrcode";
+    rev    = "ad0fdb4aafd0d56b903f110f697abaeb27deee73";
+    sha256 = "0v81745nx5gny2g05946k8j553j18a29ikmlyh6c3syq6c15k8cf";
+  };
+
+  NIX_CFLAGS_COMPILE = "-Wno-error=unused-result";
+
+  installPhase = ''
+    mkdir -p "$out"/{bin,share/doc/qrcode}
+    cp qrcode "$out/bin"
+    cp DOCUMENTATION LICENCE "$out/share/doc/qrcode"
+  '';
+
+  meta = with stdenv.lib; {
+    description = ''A small QR-code tool'';
+    license = licenses.gpl3Plus;
+    maintainers = with maintainers; [ raskin ];
+    platforms = with platforms; linux;
+  };
+}
diff --git a/nixpkgs/pkgs/tools/graphics/qrencode/default.nix b/nixpkgs/pkgs/tools/graphics/qrencode/default.nix
new file mode 100644
index 000000000000..7c5aed9b4e23
--- /dev/null
+++ b/nixpkgs/pkgs/tools/graphics/qrencode/default.nix
@@ -0,0 +1,21 @@
+{ stdenv, fetchurl, libpng, pkgconfig }:
+
+stdenv.mkDerivation rec {
+  name = "qrencode-4.0.2";
+
+  src = fetchurl {
+    url = "${meta.homepage}/${name}.tar.bz2";
+    sha256 = "1d2q5d3v8g3hsi3h5jq4n177bjhf3kawms09immw7p187f6jgjy9";
+  };
+
+  buildInputs = [ libpng ];
+  nativeBuildInputs = [ pkgconfig ];
+
+  meta = with stdenv.lib; {
+    homepage = https://fukuchi.org/works/qrencode/;
+    description = "QR code encoder";
+    platforms = platforms.all;
+    license = licenses.lgpl21Plus;
+    maintainers = with maintainers; [ yegortimoshenko ];
+  };
+}
diff --git a/nixpkgs/pkgs/tools/graphics/quirc/default.nix b/nixpkgs/pkgs/tools/graphics/quirc/default.nix
new file mode 100644
index 000000000000..9891ea5e52b0
--- /dev/null
+++ b/nixpkgs/pkgs/tools/graphics/quirc/default.nix
@@ -0,0 +1,39 @@
+{stdenv, fetchgit, SDL_gfx, SDL, libjpeg, libpng, pkgconfig}:
+let
+  s =
+  rec {
+    date = "2016-08-16";
+    version = "git-${date}";
+    baseName = "quirc";
+    name = "${baseName}-${version}";
+    url = "https://github.com/dlbeer/quirc";
+    rev = "5b262480091d5f84a67a4a56c728fc8b39844339";
+    sha256 = "1w5qvjafn14s6jjs7kiwsqirlsqbgv0p152hrsq463pm34hp0lzy";
+  };
+in
+stdenv.mkDerivation {
+  inherit (s) name version;
+  nativeBuildInputs = [ pkgconfig ];
+  buildInputs = [
+    SDL SDL_gfx libjpeg libpng
+  ];
+  src = fetchgit {
+    inherit (s) url sha256 rev;
+  };
+  NIX_CFLAGS_COMPILE="-I${SDL.dev}/include/SDL -I${SDL_gfx}/include/SDL";
+  configurePhase = ''
+    sed -e 's/-[og] root//g' -i Makefile
+  '';
+  preInstall = ''
+    mkdir -p "$out"/{bin,lib,include}
+    find . -maxdepth 1 -type f -perm -0100 -exec cp '{}' "$out"/bin ';'
+  '';
+  makeFlags = "PREFIX=$(out)";
+  meta = {
+    inherit (s) version;
+    description = ''A small QR code decoding library'';
+    license = stdenv.lib.licenses.isc;
+    maintainers = [stdenv.lib.maintainers.raskin];
+    platforms = stdenv.lib.platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/tools/graphics/rocket/default.nix b/nixpkgs/pkgs/tools/graphics/rocket/default.nix
new file mode 100644
index 000000000000..513439989501
--- /dev/null
+++ b/nixpkgs/pkgs/tools/graphics/rocket/default.nix
@@ -0,0 +1,31 @@
+{ stdenv, fetchFromGitHub, qmake, qtbase }:
+
+stdenv.mkDerivation rec {
+  name = "rocket-${version}";
+  version = "2018-06-09";
+
+  src = fetchFromGitHub {
+    owner = "rocket";
+    repo = "rocket";
+    rev = "7bc1e9826cad5dbc63e56371c6aa1798b2a7b50b";
+    sha256 = "13bdg2dc6ypk17sz39spqdlb3wai2y085bdb36pls2as2nf22drp";
+  };
+
+  nativeBuildInputs = [ qmake ];
+  buildInputs = [ qtbase ];
+
+  configurePhase = ":";
+
+  installPhase = ''
+    mkdir -p $out/bin
+    cp -r editor/editor $out/bin/
+  '';
+
+  meta = with stdenv.lib; {
+    description = "A tool for synchronizing music and visuals in demoscene productions";
+    homepage = "https://github.com/rocket/rocket";
+    license = licenses.zlib;
+    platforms = platforms.linux;
+    maintainers = [ maintainers.dezgeg ];
+  };
+}
diff --git a/nixpkgs/pkgs/tools/graphics/s2png/default.nix b/nixpkgs/pkgs/tools/graphics/s2png/default.nix
new file mode 100644
index 000000000000..fd538eec573d
--- /dev/null
+++ b/nixpkgs/pkgs/tools/graphics/s2png/default.nix
@@ -0,0 +1,24 @@
+{ stdenv, fetchFromGitHub, diffutils, gd, pkgconfig }:
+
+stdenv.mkDerivation rec {
+  name = "s2png-${version}";
+  version = "0.7.2";
+
+  src = fetchFromGitHub {
+    owner = "dbohdan";
+    repo = "s2png";
+    rev = "v${version}";
+    sha256 = "0y3crfm0jqprgxamlly713cka2x1bp6z63p1lw9wh4wc37kpira6";
+  };
+
+  buildInputs = [ diffutils gd pkgconfig ];
+  installFlags = [ "prefix=" "DESTDIR=$(out)" ];
+
+  meta = {
+    homepage = https://github.com/dbohdan/s2png/;
+    description = "Store any data in PNG images";
+    license = stdenv.lib.licenses.gpl2;
+    maintainers = [ stdenv.lib.maintainers.dbohdan ];
+    platforms = stdenv.lib.platforms.unix;
+  };
+}
diff --git a/nixpkgs/pkgs/tools/graphics/scanbd/default.nix b/nixpkgs/pkgs/tools/graphics/scanbd/default.nix
new file mode 100644
index 000000000000..5dbbd20cd827
--- /dev/null
+++ b/nixpkgs/pkgs/tools/graphics/scanbd/default.nix
@@ -0,0 +1,56 @@
+{ stdenv, fetchurl, pkgconfig
+, dbus, libconfuse, libjpeg, sane-backends, systemd }:
+
+stdenv.mkDerivation rec {
+  name = "scanbd-${version}";
+  version = "1.5.1";
+
+  src = fetchurl {
+    sha256 = "0pvy4qirfjdfm8aj6x5rkbgl7hk3jfa2s21qkk8ic5dqfjjab75n";
+    url = "mirror://sourceforge/scanbd/${name}.tgz";
+  };
+
+  nativeBuildInputs = [ pkgconfig ];
+  buildInputs = [ dbus libconfuse libjpeg sane-backends systemd ];
+
+  configureFlags = [
+    "--disable-Werror"
+    "--enable-udev"
+    "--with-scanbdconfdir=/etc/scanbd"
+    "--with-systemdsystemunitdir=$out/lib/systemd/system"
+  ];
+
+  enableParallelBuilding = true;
+
+  installFlags = [
+    "scanbdconfdir=$(out)/etc/scanbd"
+    "scannerconfdir=$(scanbdconfdir)/scanner.d"
+  ];
+
+  doCheck = true;
+
+  meta = with stdenv.lib; {
+    description = "Scanner button daemon";
+    longDescription = ''
+      scanbd polls a scanner's buttons, looking for button presses, function
+      knob changes, or other scanner events such as paper inserts and removals,
+      while at the same time allowing scan-applications to access the scanner.
+      
+      Various actions can be submitted (scan, copy, email, ...) via action
+      scripts. The function knob values are passed to the action scripts as
+      well. Scan actions are also signaled via dbus. This can be useful for
+      foreign applications. Scans can also be triggered via dbus from foreign
+      applications.
+      
+      On platforms which support signaling of dynamic device insertion/removal
+      (libudev, dbus, hal), scanbd supports this as well.
+
+      scanbd can use all sane-backends or some special backends from the (old)
+      scanbuttond project. 
+    '';
+    homepage = http://scanbd.sourceforge.net/;
+    downloadPage = https://sourceforge.net/projects/scanbd/;
+    license = licenses.gpl2Plus;
+    platforms = platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/tools/graphics/scrot/default.nix b/nixpkgs/pkgs/tools/graphics/scrot/default.nix
new file mode 100644
index 000000000000..e3c7254457db
--- /dev/null
+++ b/nixpkgs/pkgs/tools/graphics/scrot/default.nix
@@ -0,0 +1,32 @@
+{ stdenv, fetchurl, fetchzip, giblib, xlibsWrapper }:
+
+let
+  debPatch = fetchzip {
+    url = mirror://debian/pool/main/s/scrot/scrot_0.8-18.debian.tar.xz;
+    sha256 = "1m8m8ad0idf3nzw0k57f6rfbw8n7dza69a7iikriqgbrpyvxqybx";
+  };
+in
+stdenv.mkDerivation rec {
+  name = "scrot-0.8-18";
+
+  src = fetchurl {
+    url = "http://linuxbrit.co.uk/downloads/${name}.tar.gz";
+    sha256 = "1wll744rhb49lvr2zs6m93rdmiq59zm344jzqvijrdn24ksiqgb1";
+  };
+
+  postPatch = ''
+    for patch in $(cat ${debPatch}/patches/series); do
+      patch -p1 < "${debPatch}/patches/$patch"
+    done
+  '';
+
+  buildInputs = [ giblib xlibsWrapper ];
+
+  meta = with stdenv.lib; {
+    homepage = http://linuxbrit.co.uk/scrot/;
+    description = "A command-line screen capture utility";
+    platforms = platforms.linux;
+    maintainers = with maintainers; [ garbas ];
+    license = licenses.mit;
+  };
+}
diff --git a/nixpkgs/pkgs/tools/graphics/sng/default.nix b/nixpkgs/pkgs/tools/graphics/sng/default.nix
new file mode 100644
index 000000000000..098721d6b932
--- /dev/null
+++ b/nixpkgs/pkgs/tools/graphics/sng/default.nix
@@ -0,0 +1,25 @@
+{ stdenv, fetchurl, libpng, netpbm }:
+
+stdenv.mkDerivation rec {
+  name = "sng-${version}";
+  version = "1.1.0";
+
+  src = fetchurl {
+    url = "mirror://sourceforge/sng/sng-${version}.tar.gz";
+    sha256 = "06a6ydvx9xb3vxvrzdrg3hq0rjwwj9ibr7fyyxjxq6qx1j3mb70i";
+  };
+
+  buildInputs = [ libpng ];
+
+  configureFlags = [
+    "--with-rgbtxt=${netpbm}/share/netpbm/misc/rgb.txt"
+  ];
+
+  meta = with stdenv.lib; {
+    description = "Minilanguage designed to represent the entire contents of a PNG file in an editable form";
+    homepage = http://sng.sourceforge.net/;
+    license = licenses.zlib;
+    maintainers = [ maintainers.dezgeg ];
+    platforms = platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/tools/graphics/structure-synth/default.nix b/nixpkgs/pkgs/tools/graphics/structure-synth/default.nix
new file mode 100644
index 000000000000..c1e6c2afecce
--- /dev/null
+++ b/nixpkgs/pkgs/tools/graphics/structure-synth/default.nix
@@ -0,0 +1,47 @@
+{ stdenv, fetchurl, qt4, qmake4Hook, unzip, libGLU, makeWrapper }:
+
+stdenv.mkDerivation rec {
+
+  name = "structure-synth-${version}";
+  version = "v1.5";
+
+  src = fetchurl {
+    url = mirror://sourceforge/structuresynth/StructureSynth-Source-v1.5.0.zip;
+    sha256 = "1kiammx46719az6jzrav8yrwz82nk4m72ybj0kpbnvp9wfl3swbb";
+  };
+
+  buildInputs = [ qt4 unzip libGLU makeWrapper ];
+  nativeBuildInputs = [ qmake4Hook ];
+
+  # Thanks to https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=672000#15:
+  patches = [ ./gcc47.patch ];
+
+  enableParallelBuilding = true;
+
+  preConfigure = ''
+    ${qt4}/bin/qmake -project -after "CONFIG+=opengl" -after "QT+=xml opengl script" -after "unix:LIBS+=-lGLU"
+  '';
+
+  installPhase = ''
+    mkdir -p $out/bin;
+    mkdir -p $out/share/Examples $out/share/Misc;
+    cp "Structure Synth Source Code" $out/bin/structure-synth;
+    cp -r Examples/* $out/share/Examples;
+    cp -r Misc/* $out/share/Misc;
+  '';
+
+  # Structure Synth expects to see 'Examples' and 'Misc' directory in
+  # either $HOME or $PWD - so help it along by moving $PWD to 'share',
+  # where we just copied those two directories:
+  preFixup = ''
+    wrapProgram "$out/bin/structure-synth" --run "cd $out/share"
+  '';
+
+  meta = with stdenv.lib; {
+    description = "Application for generating 3D structures by specifying a design grammar";
+    homepage = http://structuresynth.sourceforge.net;
+    maintainers = with maintainers; [ hodapp ];
+    license = licenses.gpl3;
+    platforms = platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/tools/graphics/structure-synth/gcc47.patch b/nixpkgs/pkgs/tools/graphics/structure-synth/gcc47.patch
new file mode 100644
index 000000000000..8726e89c8308
--- /dev/null
+++ b/nixpkgs/pkgs/tools/graphics/structure-synth/gcc47.patch
@@ -0,0 +1,50 @@
+diff -rc "Structure Synth Source Code/SyntopiaCore/GLEngine/Raytracer/RayTracer.cpp" "Structure Synth Source Code2/SyntopiaCore/GLEngine/Raytracer/RayTracer.cpp"
+*** "Structure Synth Source Code/SyntopiaCore/GLEngine/Raytracer/RayTracer.cpp"	2010-11-13 22:32:44.000000000 -0500
+--- "Structure Synth Source Code2/SyntopiaCore/GLEngine/Raytracer/RayTracer.cpp"	2018-06-24 14:23:30.794296776 -0400
+***************
+*** 1,5 ****
+  #include <QThread>

+! 

+  

+  #include "RayTracer.h"

+  

+--- 1,5 ----
+  #include <QThread>

+! #include <GL/glu.h>

+  

+  #include "RayTracer.h"

+  

+diff -rc "Structure Synth Source Code/SyntopiaCore/GLEngine/Raytracer/VoxelStepper.cpp" "Structure Synth Source Code2/SyntopiaCore/GLEngine/Raytracer/VoxelStepper.cpp"
+*** "Structure Synth Source Code/SyntopiaCore/GLEngine/Raytracer/VoxelStepper.cpp"	2010-09-08 21:25:30.000000000 -0400
+--- "Structure Synth Source Code2/SyntopiaCore/GLEngine/Raytracer/VoxelStepper.cpp"	2018-06-24 14:23:12.542868194 -0400
+***************
+*** 122,128 ****
+  						currentT = p;

+  

+  						// We do not intersect grid.

+! 						if (!found) return false;

+  				}

+  

+  				stepX = (dir.x() > 0) ? 1 : -1;

+--- 122,128 ----
+  						currentT = p;

+  

+  						// We do not intersect grid.

+! 						if (!found) return NULL;

+  				}

+  

+  				stepX = (dir.x() > 0) ? 1 : -1;

+Only in Structure Synth Source Code2/SyntopiaCore/GLEngine/Raytracer: VoxelStepper.cpp.orig
+diff -rc "Structure Synth Source Code/SyntopiaCore/GLEngine/Sphere.h" "Structure Synth Source Code2/SyntopiaCore/GLEngine/Sphere.h"
+*** "Structure Synth Source Code/SyntopiaCore/GLEngine/Sphere.h"	2010-08-11 15:12:22.000000000 -0400
+--- "Structure Synth Source Code2/SyntopiaCore/GLEngine/Sphere.h"	2018-06-24 14:23:30.793296807 -0400
+***************
+*** 2,7 ****
+--- 2,8 ----
+  

+  #include "SyntopiaCore/Math/Vector3.h"

+  #include "Object3D.h"

++ #include <GL/glu.h>

+  

+  namespace SyntopiaCore {

+  	namespace GLEngine {	

diff --git a/nixpkgs/pkgs/tools/graphics/svgcleaner/default.nix b/nixpkgs/pkgs/tools/graphics/svgcleaner/default.nix
new file mode 100644
index 000000000000..266221de1735
--- /dev/null
+++ b/nixpkgs/pkgs/tools/graphics/svgcleaner/default.nix
@@ -0,0 +1,23 @@
+{ stdenv, fetchFromGitHub, rustPlatform }:
+
+rustPlatform.buildRustPackage rec {
+  name = "svgcleaner-${version}";
+  version = "0.9.2";
+
+  src = fetchFromGitHub {
+    owner = "RazrFalcon";
+    repo = "svgcleaner";
+    rev = "v${version}";
+    sha256 = "1jpnqsln37kkxz98vj7gly3c2170v6zamd876nc9nfl9vns41s0f";
+  };
+
+  cargoSha256 = "0d5jlq301s55xgdg9mv26hbj75pkjkyxfny7vbiqp9igj128lza3";
+
+  meta = with stdenv.lib; {
+    description = "A tool for tidying and optimizing SVGs";
+    homepage = "https://github.com/RazrFalcon/svgcleaner";
+    license = licenses.gpl2;
+    platforms = platforms.all;
+    maintainers = [ maintainers.mehandes ];
+  };
+}
diff --git a/nixpkgs/pkgs/tools/graphics/swfdec/default.nix b/nixpkgs/pkgs/tools/graphics/swfdec/default.nix
new file mode 100644
index 000000000000..1c3c0f3b4515
--- /dev/null
+++ b/nixpkgs/pkgs/tools/graphics/swfdec/default.nix
@@ -0,0 +1,38 @@
+{stdenv, fetchurl
+, cairo, pango, glib, liboil, zlib, gstreamer, gst-plugins-base
+, gst-plugins-good , gtk2, libsoup, alsaLib, pkgconfig
+}:
+
+stdenv.mkDerivation rec {
+  name = "${pname}-${version}";
+  pname = "swfdec";
+  version = "0.8.4";
+
+  src = fetchurl {
+    url = "http://swfdec.freedesktop.org/download/swfdec/0.8/swfdec-${version}.tar.gz";
+    sha256 = "00nqrd0fzf0g76rn80d7h56n6hxv7x1x6k89zj45bj564lzwc3vs";
+  };
+
+  buildInputs = [
+    cairo glib liboil pango zlib gstreamer gst-plugins-base gst-plugins-good
+    gtk2 libsoup alsaLib pkgconfig
+  ];
+  
+  postInstall = ''
+    mkdir "$out/bin"
+    cp tools/.libs/swfdec-extract "$out/bin"
+    cp tools/.libs/dump "$out/bin/swfdec-dump"
+    cp player/.libs/swfplay "$out/bin/swfplay"
+  '';
+
+  enableParallelBuilding = true;
+
+  meta = {
+    inherit version;
+    description = "Decoder/renderer for Macromedia Flash animations";
+    license = stdenv.lib.licenses.lgpl21 ;
+    maintainers = [stdenv.lib.maintainers.raskin];
+    platforms = stdenv.lib.platforms.linux;
+    homepage = https://swfdec.freedesktop.org/wiki/;
+  };
+}
diff --git a/nixpkgs/pkgs/tools/graphics/syntex/default.nix b/nixpkgs/pkgs/tools/graphics/syntex/default.nix
new file mode 100644
index 000000000000..0862293830d5
--- /dev/null
+++ b/nixpkgs/pkgs/tools/graphics/syntex/default.nix
@@ -0,0 +1,34 @@
+{stdenv, fetchFromGitHub, mono}:
+stdenv.mkDerivation rec {
+  name = "syntex-${version}";
+  version = "0.0pre20160915";
+  src = fetchFromGitHub {
+    owner = "mxgmn";
+    repo = "SynTex";
+    rev = "f499a7c8112be4a63eb44843ba72957c2c9a04db";
+    sha256 = "13fz6frlxsdz8qq94fsvim27cd5klmdsax5109yxm9175vgvpa0a";
+  };
+  buildPhase = ''
+    mcs *.cs -out:syntex.exe -r:System.Drawing
+    grep -m1 -B999 '^[*][/]' SynTex.cs > COPYING.MIT
+  '';
+  installPhase = ''
+    mkdir -p "$out"/{bin,share/doc/syntex,share/syntex}
+    cp README.md COPYING.MIT "$out"/share/doc/syntex
+    cp syntex.exe "$out"/bin
+    cp -r [Ss]amples samples.xml "$out/share/syntex"
+
+    echo "#! ${stdenv.shell}" >> "$out/bin/syntex"
+    echo "chmod u+w ." >> "$out/bin/syntex"
+    echo "'${mono}/bin/mono' '$out/bin/syntex.exe' \"\$@\"" >>  "$out/bin/syntex"
+    chmod a+x "$out/bin/syntex"
+  '';
+  buildInputs = [mono];
+  meta = {
+    inherit version;
+    description = ''Texture synthesis from examples'';
+    license = stdenv.lib.licenses.mit;
+    maintainers = [stdenv.lib.maintainers.raskin];
+    platforms = stdenv.lib.platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/tools/graphics/transfig/default.nix b/nixpkgs/pkgs/tools/graphics/transfig/default.nix
new file mode 100644
index 000000000000..ceee3b7674d9
--- /dev/null
+++ b/nixpkgs/pkgs/tools/graphics/transfig/default.nix
@@ -0,0 +1,61 @@
+{ stdenv, fetchurl, zlib, libjpeg, libpng, imake, gccmakedep }:
+
+stdenv.mkDerivation rec {
+  name = "transfig-3.2.4";
+  src = fetchurl {
+    url = ftp://ftp.tex.ac.uk/pub/archive/graphics/transfig/transfig.3.2.4.tar.gz;
+    sha256 = "0429snhp5acbz61pvblwlrwv8nxr6gf12p37f9xxwrkqv4ir7dd4";
+  };
+
+  nativeBuildInputs = [ imake gccmakedep ];
+  buildInputs = [ zlib libjpeg libpng ];
+
+  patches = [
+    ./patch-fig2dev-dev-Imakefile
+    ./patch-fig2dev-Imakefile
+    ./patch-transfig-Imakefile
+    ./patch-fig2dev-fig2dev.h
+    ./patch-fig2dev-dev-gensvg.c
+  ];
+
+  patchPhase = ''
+    runHook prePatch
+
+    configureImakefiles() {
+        local sedcmd=$1
+
+        sed "$sedcmd" fig2dev/Imakefile > tmpsed
+        cp tmpsed fig2dev/Imakefile
+
+        sed "$sedcmd" fig2dev/dev/Imakefile > tmpsed
+        cp tmpsed fig2dev/dev/Imakefile
+
+        sed "$sedcmd" transfig/Imakefile > tmpsed
+        cp tmpsed transfig/Imakefile
+    }
+
+    for i in $patches; do
+        header "applying patch $i" 3
+        patch -p0 < $i
+        stopNest
+    done
+
+    configureImakefiles "s:__PREFIX_PNG:${libpng}:"
+    configureImakefiles "s:__PREFIX:$out:"
+
+    runHook postPatch
+  '';
+
+  makeFlags = [ "CC=${stdenv.cc.targetPrefix}cc" ];
+
+  preInstall = ''
+    mkdir -p $out
+    mkdir -p $out/lib
+  '';
+
+  hardeningDisable = [ "format" ];
+
+  meta = {
+    platforms = stdenv.lib.platforms.unix;
+  };
+}
diff --git a/nixpkgs/pkgs/tools/graphics/transfig/patch-fig2dev-Imakefile b/nixpkgs/pkgs/tools/graphics/transfig/patch-fig2dev-Imakefile
new file mode 100644
index 000000000000..9c1895b15196
--- /dev/null
+++ b/nixpkgs/pkgs/tools/graphics/transfig/patch-fig2dev-Imakefile
@@ -0,0 +1,75 @@
+--- fig2dev/Imakefile.orig	Thu Mar 25 22:39:10 2004
++++ fig2dev/Imakefile	Thu Mar 25 22:41:01 2004
+@@ -16,17 +16,23 @@
+ XCOMM party to do so, with the only requirement being that this copyright 
+ XCOMM notice remain intact.
+ 
++BINDIR = __PREFIX/bin
++DESTDIR = __DESTROOT
++MKDIRHIER = mkdirhier
++MANDIR = __PREFIX/share/man/$(MANSUFFIX)
++INSTALLFLAGS = -c
++
+ XCOMM ******
+ XCOMM You should point XFIGLIBDIR to the same directory you did when you compiled
+ XCOMM and installed xfig.
+ 
+-XFIGLIBDIR =	/usr/local/lib/X11/xfig
++XFIGLIBDIR =	__PREFIX/lib/xfig
+ 
+ XCOMM ******
+ XCOMM If your system has the strerror() function (doesn't have sys_errlist) then
+ XCOMM comment out NEED_STRERROR with an XCOMM comment.
+ 
+-NEED_STRERROR = -DNEED_STRERROR
++XCOMM NEED_STRERROR = -DNEED_STRERROR
+ 
+ XCOMM The following probably only applies to Windows 9x/NT:
+ XCOMM If your system can open files in text and binary modes and has the
+@@ -39,7 +45,7 @@
+ XCOMM inline functions. With the "INLINE" keyword, you should notice that
+ XCOMM the display will be a bit faster in complex figures
+ 
+-XCOMM USEINLINE = -DUSE_INLINE
++USEINLINE = -DUSE_INLINE
+ 
+ XCOMM ****************
+ XCOMM Change RGB if necessary, to point to your rgb.txt color database
+@@ -60,8 +66,8 @@
+ XCOMM are in different places
+ 
+ #ifdef USEPNG
+-PNGLIBDIR = $(USRLIBDIR)
+-PNGINC = -I/usr/include/X11
++PNGLIBDIR = __PREFIX_PNG/lib
++PNGINC = -I__PREFIX_PNG/include
+ #endif
+ 
+ XCOMM ****************
+@@ -73,7 +79,7 @@
+ XCOMM Change XPMINC if necessary to point to the include file for xpm (xpm.h)
+ XCOMM
+ 
+-XCOMM #define USEXPM
++XCOMM #define USEXPM
+ 
+ #ifdef USEXPM
+ XPMLIBDIR = $(USRLIBDIR)
+@@ -126,7 +132,7 @@
+ 
+ #ifdef I18N
+ I18N_DEFS = -DI18N 
+-FIG2DEV_LIBDIR = /usr/local/lib/fig2dev
++FIG2DEV_LIBDIR = __PREFIX/lib/fig2dev
+ I18N_DEV_DEFS = $(I18N_DEFS) -DFIG2DEV_LIBDIR=\\\"$(FIG2DEV_LIBDIR)\\\"
+ 
+ install::
+@@ -177,7 +183,7 @@
+ 
+ IMAKE_DEFINES = $(DUSEPNG) $(DUSEXPM)
+ 
+-DEVDEFINES = $(DUSEPNG) $(DUSEXPM) $(XPMINC) $(DDNFSS) $(DDA4) \
++DEVDEFINES = $(DUSEPNG) $(DUSEXPM) $(PNGINC) $(XPMINC) $(DDNFSS) $(DDA4) \
+ 		$(DDLATEX2E_GRAPHICS) $(DDEPSFIG) $(DDIBMGEC) $(DDDVIPS) $(I18N_DEV_DEFS)
+ 
+ #define IHaveSubdirs
diff --git a/nixpkgs/pkgs/tools/graphics/transfig/patch-fig2dev-dev-Imakefile b/nixpkgs/pkgs/tools/graphics/transfig/patch-fig2dev-dev-Imakefile
new file mode 100644
index 000000000000..87f01f70d302
--- /dev/null
+++ b/nixpkgs/pkgs/tools/graphics/transfig/patch-fig2dev-dev-Imakefile
@@ -0,0 +1,15 @@
+--- fig2dev/dev/Imakefile.orig	Thu Mar 25 22:47:18 2004
++++ fig2dev/dev/Imakefile	Thu Mar 25 22:47:51 2004
+@@ -18,6 +18,12 @@
+ XCOMM party to do so, with the only requirement being that this copyright 
+ XCOMM notice remain intact.
+ 
++BINDIR = __PREFIX/bin
++USRLIBDIR = __PREFIX/lib
++DESTDIR = __DESTROOT
++MKDIRHIER = mkdirhier
++MANDIR = __PREFIX/share/man/$(MANSUFFIX)
++
+ INCLUDES = -I.. -I../..
+ 
+ #ifdef USE_PNG
diff --git a/nixpkgs/pkgs/tools/graphics/transfig/patch-fig2dev-dev-gensvg.c b/nixpkgs/pkgs/tools/graphics/transfig/patch-fig2dev-dev-gensvg.c
new file mode 100644
index 000000000000..5bd05c97be8e
--- /dev/null
+++ b/nixpkgs/pkgs/tools/graphics/transfig/patch-fig2dev-dev-gensvg.c
@@ -0,0 +1,21 @@
+--- fig2dev/dev/gensvg.c.orig	Wed Jul 23 16:39:14 2003
++++ fig2dev/dev/gensvg.c	Wed Jul 23 16:39:52 2003
+@@ -692,16 +692,14 @@
+     if (t->angle != 0) {
+ 	fprintf (tfp, "<g transform=\"translate(%d,%d) rotate(%d)\" >\n",
+ 		 (int) (t->base_x * mag), (int) (t->base_y * mag), degrees (t->angle));
+-	fprintf (tfp, "<text x=\"0\" y=\"0\" fill=\"#%6.6x\"  font-family=\"%s\" 
+-		 font-style=\"%s\" font-weight=\"%s\" font-size=\"%d\" text-anchor=\"%s\" >\n",
++	fprintf (tfp, "<text x=\"0\" y=\"0\" fill=\"#%6.6x\"  font-family=\"%s\" font-style=\"%s\" font-weight=\"%s\" font-size=\"%d\" text-anchor=\"%s\" >\n",
+ 		 rgbColorVal (t->color), family[(int) ceil ((t->font + 1) / 4)],
+ 		 (t->font % 2 == 0 ? "normal" : "italic"),
+ 		 (t->font % 4 < 2 ? "normal" : "bold"), (int) (ceil (t->size * 12 * mag)),
+ 		 anchor[t->type]);
+     }
+     else
+-	fprintf (tfp, "<text x=\"%d\" y=\"%d\" fill=\"#%6.6x\"  font-family=\"%s\" 
+-		 font-style=\"%s\" font-weight=\"%s\" font-size=\"%d\" text-anchor=\"%s\" >\n",
++	fprintf (tfp, "<text x=\"%d\" y=\"%d\" fill=\"#%6.6x\"  font-family=\"%s\" font-style=\"%s\" font-weight=\"%s\" font-size=\"%d\" text-anchor=\"%s\" >\n",
+ 		 (int) (t->base_x * mag), (int) (t->base_y * mag), rgbColorVal (t->color),
+ 		 family[(int) ceil ((t->font + 1) / 4)],
+ 		 (t->font % 2 == 0 ? "normal" : "italic"),
diff --git a/nixpkgs/pkgs/tools/graphics/transfig/patch-fig2dev-fig2dev.h b/nixpkgs/pkgs/tools/graphics/transfig/patch-fig2dev-fig2dev.h
new file mode 100644
index 000000000000..3f330c164e7e
--- /dev/null
+++ b/nixpkgs/pkgs/tools/graphics/transfig/patch-fig2dev-fig2dev.h
@@ -0,0 +1,19 @@
+--- fig2dev/fig2dev.h.orig	Thu Dec 19 07:45:28 2002
++++ fig2dev/fig2dev.h	Tue Jan  7 20:08:45 2003
+@@ -22,7 +22,6 @@
+ #include <sys/file.h>
+ #include <signal.h>
+ #include <string.h>
+-#include <varargs.h>
+ #include <pwd.h>
+ #include <errno.h>
+ #include <time.h>
+@@ -210,7 +209,7 @@
+ #endif /* MAXPATHLEN */
+ #endif /* PATH_MAX */
+ 
+-#if ( !defined(__NetBSD__) && !defined(__DARWIN__))
++#if ( !defined(__NetBSD__) && !defined(__FreeBSD__) && !defined(__DARWIN__))
+ extern int		sys_nerr, errno;
+ #endif
+ 
diff --git a/nixpkgs/pkgs/tools/graphics/transfig/patch-transfig-Imakefile b/nixpkgs/pkgs/tools/graphics/transfig/patch-transfig-Imakefile
new file mode 100644
index 000000000000..4639658dccd8
--- /dev/null
+++ b/nixpkgs/pkgs/tools/graphics/transfig/patch-transfig-Imakefile
@@ -0,0 +1,22 @@
+--- transfig/Imakefile.orig	Thu Mar 25 22:10:42 2004
++++ transfig/Imakefile	Thu Mar 25 22:14:04 2004
+@@ -14,11 +14,18 @@
+ XCOMM party to do so, with the only requirement being that this copyright 
+ XCOMM notice remain intact.
+ 
++BINDIR = __PREFIX/bin
++USRLIBDIR = __PREFIX/lib
++DESTDIR = __DESTROOT
++MKDIRHIER = mkdirhier
++MANDIR = __PREFIX/share/man/$(MANSUFFIX)
++INSTALLFLAGS = -c
++
+ XCOMM Uncomment the USELATEX2E flag in the transfig/Imakefile file to use the
+ XCOMM \\usepackage{} command for LaTeX2e. 
+ XCOMM The default is to use \\documentstyle{} for LaTeX209.
+ 
+-XCOMM USELATEX2E = -DLATEX2E
++USELATEX2E = -DLATEX2E
+ 
+ XCOMM ******* DON'T CHANGE ANYTHIN BELOW THIS POINT *******
+ 
diff --git a/nixpkgs/pkgs/tools/graphics/twilight/default.nix b/nixpkgs/pkgs/tools/graphics/twilight/default.nix
new file mode 100644
index 000000000000..3769860d469b
--- /dev/null
+++ b/nixpkgs/pkgs/tools/graphics/twilight/default.nix
@@ -0,0 +1,29 @@
+{ stdenv, fetchFromGitHub
+, libGL, libGLU, freeglut, libX11 }:
+
+let
+  version = "2018-04-19";
+in stdenv.mkDerivation rec {
+  name = "twilight-${version}";
+
+  src = fetchFromGitHub {
+    owner = "tweakoz";
+    repo = "twilight";
+    rev = "43f21d15c2a8923c9d707bdf3789f480bfd4b36d";
+    sha256 = "0mmmi4jj8yd8wnah6kx5na782sjycszgzim33dfalr0ph361m4pz";
+  };
+
+  buildInputs = [ libGL libGLU freeglut libX11 ];
+
+  installPhase = ''
+    install -Dm755 twilight $out/bin/twilight
+  '';
+
+  meta = with stdenv.lib; {
+    description = "Redo of IRIX twilight backdrop in old school OpenGL";
+    homepage = src.meta.homepage;
+    license = licenses.mit;
+    platforms = platforms.linux;
+    maintainers = with maintainers; [ gnidorah ];
+  };
+}
diff --git a/nixpkgs/pkgs/tools/graphics/unpaper/default.nix b/nixpkgs/pkgs/tools/graphics/unpaper/default.nix
new file mode 100644
index 000000000000..b58114a61a5d
--- /dev/null
+++ b/nixpkgs/pkgs/tools/graphics/unpaper/default.nix
@@ -0,0 +1,22 @@
+{ stdenv, fetchurl, pkgconfig, libav, libxslt }:
+
+stdenv.mkDerivation rec {
+  name = "unpaper-${version}";
+  version = "6.1";
+
+  src = fetchurl {
+    url = "https://www.flameeyes.eu/files/${name}.tar.xz";
+    sha256 = "0c5rbkxbmy9k8vxjh4cv0bgnqd3wqc99yzw215vkyjslvbsq8z13";
+  };
+
+  nativeBuildInputs = [ pkgconfig ];
+  buildInputs = [ libav libxslt ];
+
+  meta = with stdenv.lib; {
+    homepage = https://www.flameeyes.eu/projects/unpaper;
+    description = "Post-processing tool for scanned sheets of paper";
+    license = licenses.gpl2;
+    platforms = platforms.all;
+    maintainers = [ maintainers.rycee ];
+  };
+}
diff --git a/nixpkgs/pkgs/tools/graphics/vips/default.nix b/nixpkgs/pkgs/tools/graphics/vips/default.nix
new file mode 100644
index 000000000000..7381238e4acb
--- /dev/null
+++ b/nixpkgs/pkgs/tools/graphics/vips/default.nix
@@ -0,0 +1,39 @@
+{ stdenv, pkgconfig, glib, libxml2, expat,
+  fftw, orc, lcms, imagemagick, openexr, libtiff, libjpeg, libgsf, libexif,
+  ApplicationServices,
+  python27, libpng ? null,
+  fetchFromGitHub,
+  autoreconfHook,
+  gtk-doc,
+  gobject-introspection,
+}:
+
+stdenv.mkDerivation rec {
+  name = "vips-${version}";
+  version = "8.7.0";
+
+  src = fetchFromGitHub {
+    owner = "libvips";
+    repo = "libvips";
+    rev = "v${version}";
+    sha256 = "1dwcpmpqbgb9lkajnqv50mrsn97mxbxpq6b5aya7fgfkgdnrs9sw";
+  };
+
+  nativeBuildInputs = [ pkgconfig autoreconfHook gtk-doc gobject-introspection ];
+  buildInputs = [ glib libxml2 fftw orc lcms
+    imagemagick openexr libtiff libjpeg
+    libgsf libexif python27 libpng expat ]
+    ++ stdenv.lib.optional stdenv.isDarwin ApplicationServices;
+
+  autoreconfPhase = ''
+    ./autogen.sh
+  '';
+
+  meta = with stdenv.lib; {
+    homepage = http://www.vips.ecs.soton.ac.uk;
+    description = "Image processing system for large images";
+    license = licenses.lgpl2Plus;
+    maintainers = with maintainers; [ kovirobi ];
+    platforms = platforms.unix;
+  };
+}
diff --git a/nixpkgs/pkgs/tools/graphics/vulkan-tools/default.nix b/nixpkgs/pkgs/tools/graphics/vulkan-tools/default.nix
new file mode 100644
index 000000000000..7d5283b3133e
--- /dev/null
+++ b/nixpkgs/pkgs/tools/graphics/vulkan-tools/default.nix
@@ -0,0 +1,28 @@
+{ stdenv, fetchFromGitHub, cmake, python3, vulkan-loader,
+  glslang, pkgconfig, xlibsWrapper, libxcb, libXrandr, wayland }:
+
+stdenv.mkDerivation rec {
+  name = "vulkan-tools-${version}";
+  version = "1.1.92";
+
+  src = fetchFromGitHub {
+    owner = "KhronosGroup";
+    repo = "Vulkan-Tools";
+    rev = "sdk-${version}";
+    sha256 = "1khbfxp2mha7h0vqs0fkqscxm76gn3zlia8yya11lkhk7sn3h0d3";
+  };
+
+  nativeBuildInputs = [ cmake pkgconfig ];
+  buildInputs = [ python3 vulkan-loader xlibsWrapper libxcb libXrandr wayland ];
+  enableParallelBuilding = true;
+
+  cmakeFlags = [ "-DBUILD_ICD=OFF" "-DGLSLANG_INSTALL_DIR=${glslang}" ];
+
+  meta = with stdenv.lib; {
+    description = "LunarG Vulkan loader";
+    homepage    = https://www.lunarg.com;
+    platforms   = platforms.linux;
+    license     = licenses.asl20;
+    maintainers = [ maintainers.ralith ];
+  };
+}
diff --git a/nixpkgs/pkgs/tools/graphics/wavefunctioncollapse/default.nix b/nixpkgs/pkgs/tools/graphics/wavefunctioncollapse/default.nix
new file mode 100644
index 000000000000..20d07e52f6c7
--- /dev/null
+++ b/nixpkgs/pkgs/tools/graphics/wavefunctioncollapse/default.nix
@@ -0,0 +1,34 @@
+{stdenv, fetchFromGitHub, mono}:
+stdenv.mkDerivation rec {
+  name = "wavefunctioncollapse-${version}";
+  version = "0.0pre20170130";
+  src = fetchFromGitHub {
+    owner = "mxgmn";
+    repo = "WaveFunctionCollapse";
+    rev = "ef660c037b1d7c4ebce66efc625af2bb2f2111c0";
+    sha256 = "1dr5fvdgn1jqqacby6rrqm951adx3jw0j70r5i8pmrqnnw482l8m";
+  };
+  buildPhase = ''
+    mcs *.cs -out:wavefunctioncollapse.exe -r:System.Drawing
+    grep -m1 -B999 '^[*][/]' Main.cs > COPYING.MIT
+  '';
+  installPhase = ''
+    mkdir -p "$out"/{bin,share/doc/wavefunctioncollapse,share/wavefunctioncollapse}
+    cp README.md COPYING.MIT "$out"/share/doc/wavefunctioncollapse
+    cp wavefunctioncollapse.exe "$out"/bin
+    cp -r [Ss]amples samples.xml "$out/share/wavefunctioncollapse"
+
+    echo "#! ${stdenv.shell}" >> "$out/bin/wavefunctioncollapse"
+    echo "chmod u+w ." >> "$out/bin/wavefunctioncollapse"
+    echo "'${mono}/bin/mono' '$out/bin/wavefunctioncollapse.exe' \"\$@\"" >>  "$out/bin/wavefunctioncollapse"
+    chmod a+x "$out/bin/wavefunctioncollapse"
+  '';
+  buildInputs = [mono];
+  meta = {
+    inherit version;
+    description = ''A generator of bitmaps that are locally similar to the input bitmap'';
+    license = stdenv.lib.licenses.mit;
+    maintainers = [stdenv.lib.maintainers.raskin];
+    platforms = stdenv.lib.platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/tools/graphics/welkin/default.nix b/nixpkgs/pkgs/tools/graphics/welkin/default.nix
new file mode 100644
index 000000000000..2882ae960de1
--- /dev/null
+++ b/nixpkgs/pkgs/tools/graphics/welkin/default.nix
@@ -0,0 +1,36 @@
+{ stdenv, fetchsvn, jre, makeWrapper }:
+
+stdenv.mkDerivation rec {
+  name = "welkin-${version}";
+  version = "1.1";
+
+  src = fetchsvn {
+    url = "http://simile.mit.edu/repository/welkin";
+    rev = "9638";
+    sha256 = "1bqh3vam7y805xrmdw7k0ckcfwjg88wypxgv3njkkwyn7kxnfnqp";
+  };
+
+  sourceRoot = "welkin-r9638/tags/${version}";
+
+  buildInputs = [ jre makeWrapper ];
+
+  installPhase = ''
+    mkdir -p $out/{bin,share}
+    cp -R . $out/share
+    cp $out/share/welkin.sh $out/bin/welkin
+    sed -e 's@\./lib/welkin\.jar@'"$out"'/share/lib/welkin.jar@' -i $out/bin/welkin
+    wrapProgram $out/bin/welkin \
+      --set JAVA_HOME ${jre}
+    chmod a+x $out/bin/welkin
+  '';
+
+  meta = {
+    description = "An RDF visualizer";
+    maintainers = with stdenv.lib.maintainers; [
+      raskin
+    ];
+    hydraPlatforms = [];
+    license = stdenv.lib.licenses.free;
+    platforms = with stdenv.lib.platforms; unix;
+  };
+}
diff --git a/nixpkgs/pkgs/tools/graphics/wkhtmltopdf/default.nix b/nixpkgs/pkgs/tools/graphics/wkhtmltopdf/default.nix
new file mode 100644
index 000000000000..14ba0f8c2a9a
--- /dev/null
+++ b/nixpkgs/pkgs/tools/graphics/wkhtmltopdf/default.nix
@@ -0,0 +1,46 @@
+{ stdenv, fetchFromGitHub, qt5, fontconfig, freetype, libpng, zlib, libjpeg
+, openssl, libX11, libXext, libXrender }:
+
+stdenv.mkDerivation rec {
+  version = "0.12.5";
+  name = "wkhtmltopdf-${version}";
+
+  src = fetchFromGitHub {
+    owner  = "wkhtmltopdf";
+    repo   = "wkhtmltopdf";
+    rev    = version;
+    sha256 = "0i6b6z3f4szspbbi23qr3hv22j9bhmcj7c1jizr7y0ra43mrgws1";
+  };
+
+  buildInputs = [
+    fontconfig freetype libpng zlib libjpeg openssl
+    libX11 libXext libXrender
+    qt5.qtwebkit qt5.qtsvg
+  ];
+
+  prePatch = ''
+    for f in src/image/image.pro src/pdf/pdf.pro ; do
+      substituteInPlace $f --replace '$(INSTALL_ROOT)' ""
+    done
+  '';
+
+  configurePhase = "qmake wkhtmltopdf.pro INSTALLBASE=$out";
+
+  enableParallelBuilding = true;
+
+  meta = with stdenv.lib; {
+    homepage = https://wkhtmltopdf.org/;
+    description = "Tools for rendering web pages to PDF or images";
+    longDescription = ''
+      wkhtmltopdf and wkhtmltoimage are open source (LGPL) command line tools
+      to render HTML into PDF and various image formats using the QT Webkit
+      rendering engine. These run entirely "headless" and do not require a
+      display or display service.
+
+      There is also a C library, if you're into that kind of thing.
+    '';
+    license = licenses.gpl3Plus;
+    maintainers = with maintainers; [ jb55 ];
+    platforms = with platforms; linux;
+  };
+}
diff --git a/nixpkgs/pkgs/tools/graphics/xcftools/default.nix b/nixpkgs/pkgs/tools/graphics/xcftools/default.nix
new file mode 100644
index 000000000000..749631999e49
--- /dev/null
+++ b/nixpkgs/pkgs/tools/graphics/xcftools/default.nix
@@ -0,0 +1,40 @@
+{stdenv, fetchurl, libpng, perl, gettext }:
+
+stdenv.mkDerivation {
+  name = "xcftools-1.0.7";
+
+  src = fetchurl {
+    url = "http://henning.makholm.net/xcftools/xcftools-1.0.7.tar.gz";
+    sha256 = "19i0x7yhlw6hd2gp013884zchg63yzjdj4hpany011il0n26vgqy";
+  };
+
+  buildInputs = [ libpng perl gettext ];
+
+  patchPhase = ''
+    # Required if building with libpng-1.6, innocuous otherwise
+    substituteInPlace xcf2png.c         \
+      --replace png_voidp_NULL NULL     \
+      --replace png_error_ptr_NULL NULL
+
+    # xcfview needs mailcap and isn't that useful anyway
+    sed -i -e '/BINARIES/s/xcfview//' Makefile.in
+  '';
+
+  meta = {
+    homepage = http://henning.makholm.net/software;
+    description = "Command-line tools for converting Gimp XCF files";
+    longDescription = ''
+      A set of fast command-line tools for extracting information from
+      the Gimp's native file format XCF.
+
+      The tools are designed to allow efficient use of layered XCF
+      files as sources in a build system that use 'make' and similar
+      tools to manage automatic processing of the graphics.
+
+      These tools work independently of the Gimp engine and do not
+      require the Gimp to even be installed.
+    '';
+    license = stdenv.lib.licenses.gpl2;
+    platforms = stdenv.lib.platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/tools/graphics/yafaray-core/default.nix b/nixpkgs/pkgs/tools/graphics/yafaray-core/default.nix
new file mode 100644
index 000000000000..7321128a6b5a
--- /dev/null
+++ b/nixpkgs/pkgs/tools/graphics/yafaray-core/default.nix
@@ -0,0 +1,38 @@
+{ stdenv, fetchFromGitHub, cmake, pkgconfig, opencv, zlib
+, libxml2, freetype, libjpeg, libtiff, swig, openexr
+, ilmbase, boost165
+, withPython ? true, python35
+}:
+
+stdenv.mkDerivation rec {
+
+    name = "yafaray-core-${version}";
+    version = "3.3.0";
+
+    src = fetchFromGitHub {
+      owner  = "YafaRay";
+      repo   = "Core";
+      rev    = "v${version}";
+      sha256 = "04p3nlg1rv617qf8v1nzjl6f0w43rvi8w9j6l6ck4bvl77v6cjp6";
+    };
+
+    preConfigure = ''
+      NIX_CFLAGS_COMPILE+=" -isystem ${ilmbase.dev}/include/OpenEXR"
+    '';
+
+    buildInputs = [
+      cmake pkgconfig boost165 opencv zlib libxml2 freetype libjpeg libtiff
+      swig openexr ilmbase
+    ] ++ stdenv.lib.optional withPython python35;
+
+    meta = with stdenv.lib; {
+      description = "A free, open source raytracer";
+      homepage = http://www.yafaray.org;
+      maintainers = with maintainers; [ hodapp ];
+      license = licenses.lgpl21;
+      platforms = platforms.linux;
+    };
+  }
+
+# TODO: Add optional Ruby support
+# TODO: Add Qt support? (CMake looks for it, but what for?)
diff --git a/nixpkgs/pkgs/tools/graphics/yaxg/default.nix b/nixpkgs/pkgs/tools/graphics/yaxg/default.nix
new file mode 100644
index 000000000000..8fbc09a6d82b
--- /dev/null
+++ b/nixpkgs/pkgs/tools/graphics/yaxg/default.nix
@@ -0,0 +1,38 @@
+{ stdenv, fetchFromGitHub, makeWrapper,
+  maim, slop, ffmpeg, byzanz, libnotify, xdpyinfo }:
+
+stdenv.mkDerivation rec {
+  name = "yaxg-${version}";
+  version = "unstable-2018-05-03";
+
+  src = fetchFromGitHub {
+    owner = "DanielFGray";
+    repo = "yaxg";
+    rev = "9d6af75da2ec25dba4b8d784e431064033d67ad2";
+    sha256 = "01p6ghp1vfrlnrm78bgbl9ppqwsdxh761g0qa172dpvsqg91l1p6";
+  };
+
+  nativeBuildInputs = [ makeWrapper ];
+  buildInputs = [ maim slop ffmpeg byzanz libnotify xdpyinfo ];
+
+  installPhase = ''
+    mkdir -p $out/bin/
+    mv yaxg $out/bin/
+    chmod +x $out/bin/yaxg
+    wrapProgram $out/bin/yaxg --prefix PATH : ${ stdenv.lib.makeBinPath [ maim slop ffmpeg byzanz libnotify xdpyinfo ]}
+  '';
+
+  meta = with stdenv.lib; {
+    inherit (src.meta) homepage;
+    description = "Yet Another X Grabber script";
+    longDescription = ''
+      Capture and record your screen with callbacks. Wraps maim, slop, ffmpeg,
+      and byzanz to enable still image, video, or gif recording of part or all
+      of your screen. Similar command-line interface to scrot but is overall
+      more flexible and less buggy.
+    '';
+    platforms = platforms.all;
+    license = licenses.gpl3Plus;
+    maintainers = with maintainers; [ neonfuz ];
+  };
+}
diff --git a/nixpkgs/pkgs/tools/graphics/zbar/default.nix b/nixpkgs/pkgs/tools/graphics/zbar/default.nix
new file mode 100644
index 000000000000..b8bf73fda648
--- /dev/null
+++ b/nixpkgs/pkgs/tools/graphics/zbar/default.nix
@@ -0,0 +1,71 @@
+{ stdenv, fetchurl, imagemagickBig, pkgconfig, python2Packages, perl
+, libX11, libv4l, qt4, lzma, gtk2, fetchpatch, autoreconfHook
+, enableVideo ? stdenv.isLinux
+}:
+
+let
+  inherit (python2Packages) pygtk python;
+in stdenv.mkDerivation rec {
+  name = "${pname}-${version}";
+  pname = "zbar";
+  version = "0.10";
+  src = fetchurl {
+    url = "mirror://sourceforge/project/${pname}/${pname}/${version}/${name}.tar.bz2";
+    sha256 = "1imdvf5k34g1x2zr6975basczkz3zdxg6xnci50yyp5yvcwznki3";
+  };
+
+  patches = [
+    (fetchpatch {
+      name = "0001-Description-Linux-2.6.38-and-later-do-not-support-th.patch";
+      url = "https://git.recluse.de/raw/debian/pkg-zbar.git/35182c3ac2430c986579b25f1826fe1b7dfd15de/debian!patches!0001-Description-Linux-2.6.38-and-later-do-not-support-th.patch";
+      sha256 = "1zy1wdyhmpw877pv6slfhjy0c6dm0gxli0i4zs1akpvh052j4a69";
+    })
+    (fetchpatch {
+      name = "python-zbar-import-fix-am.patch";
+      url = "https://git.recluse.de/raw/debian/pkg-zbar.git/1f15f52e53ee0bf7b4761d673dc859c6b10e6be5/debian!patches!python-zbar-import-fix-am.patch";
+      sha256 = "15xx9ms137hvwpynbgvbc6zgmmzfaf7331rfhls24rgbnywbgirx";
+    })
+    (fetchpatch {
+      name = "new_autotools_build_fix.patch";
+      url = "https://git.recluse.de/raw/debian/pkg-zbar.git/2c641cc94d4f728421ed750d95d6d1c2d06a534d/debian!patches!new_autotools_build_fix.patch";
+      sha256 = "0jhl5jnnjhfdv51xqimkbkdvj8d38z05fhd11yx1sgmw82f965s3";
+    })
+    (fetchpatch {
+      name = "threading-fix.patch";
+      url = "https://git.recluse.de/raw/debian/pkg-zbar.git/d3eba6e2c3acb0758d19519015bf1a53ffb8e645/debian!patches!threading-fix.patch";
+      sha256 = "1jjgrx9nc7788vfriai4z26mm106sg5ylm2w5rdyrwx7420x1wh7";
+    })
+  ];
+
+  buildInputs =
+    [ imagemagickBig pkgconfig python pygtk perl libX11
+      lzma autoreconfHook ] ++
+    stdenv.lib.optionals enableVideo [ libv4l gtk2 qt4 ];
+
+  configureFlags = stdenv.lib.optionals (!enableVideo) [
+    "--disable-video" "--without-gtk" "--without-qt"
+  ];
+
+  hardeningDisable = [ "fortify" ];
+
+  meta = with stdenv.lib; {
+    description = "Bar code reader";
+    longDescription = ''
+      ZBar is an open source software suite for reading bar codes from various
+      sources, such as video streams, image files and raw intensity sensors. It
+      supports many popular symbologies (types of bar codes) including
+      EAN-13/UPC-A, UPC-E, EAN-8, Code 128, Code 39, Interleaved 2 of 5 and QR
+      Code.
+    '';
+    maintainers = with maintainers; [ raskin ];
+    platforms = platforms.unix;
+    license = licenses.lgpl21;
+    homepage = http://zbar.sourceforge.net/;
+  };
+
+  passthru = {
+    updateInfo = {
+      downloadPage = "http://zbar.sourceforge.net/";
+    };
+  };
+}
diff --git a/nixpkgs/pkgs/tools/graphics/zxing/default.nix b/nixpkgs/pkgs/tools/graphics/zxing/default.nix
new file mode 100644
index 000000000000..a760336cfa38
--- /dev/null
+++ b/nixpkgs/pkgs/tools/graphics/zxing/default.nix
@@ -0,0 +1,34 @@
+{ stdenv, fetchurl, jre }:
+stdenv.mkDerivation rec {
+  name = "zxing-${version}";
+  version = "3.1.0";
+  # Maven builds are hard to get right
+  core_jar = fetchurl {
+    url = "http://repo1.maven.org/maven2/com/google/zxing/core/${version}/core-${version}.jar";
+    sha256 = "199l4xvlcpafqn69r3k9qjpqkw9lvkl02hzpm0ackvdhl7vk42zh";
+  };
+  javase_jar = fetchurl {
+    url = "http://repo1.maven.org/maven2/com/google/zxing/javase/${version}/javase-${version}.jar";
+    sha256 = "0fzxvvf5dqyrs5m9rqw4ffm9h1s27bi7q3jb1dam34s80q2rp2zq";
+  };
+  inherit jre;
+  unpackPhase = ''true'';
+  installPhase = ''
+    mkdir -p "$out/lib/java" "$out/bin"
+    cp "${core_jar}" "${javase_jar}" "$out/lib/java"
+    substituteAll "${./java-zxing.sh}" "$out/bin/java-zxing"
+    substituteAll "${./zxing-cmdline-runner.sh}" "$out/bin/zxing-cmdline-runner"
+    substituteAll "${./zxing-cmdline-encoder.sh}" "$out/bin/zxing-cmdline-encoder"
+    substituteAll "${./zxing.sh}" "$out/bin/zxing"
+    chmod a+x "$out/bin"/*
+    cd "$out/lib/java"; for i in *.jar; do mv "$i" "''${i#*-}"; done
+  '';
+  meta = {
+    inherit version;
+    description = ''1D and 2D code reading library'';
+    license = stdenv.lib.licenses.asl20;
+    maintainers = [stdenv.lib.maintainers.raskin];
+    platforms = stdenv.lib.platforms.linux;
+    homepage = https://github.com/zxing/zxing;
+  };
+}
diff --git a/nixpkgs/pkgs/tools/graphics/zxing/java-zxing.sh b/nixpkgs/pkgs/tools/graphics/zxing/java-zxing.sh
new file mode 100644
index 000000000000..bee3ac9e27a6
--- /dev/null
+++ b/nixpkgs/pkgs/tools/graphics/zxing/java-zxing.sh
@@ -0,0 +1,3 @@
+#! /bin/sh
+
+@jre@/bin/java -cp @out@/lib/java/core-@version@.jar:@out@/lib/java/javase-@version@.jar "$@"
diff --git a/nixpkgs/pkgs/tools/graphics/zxing/zxing-cmdline-encoder.sh b/nixpkgs/pkgs/tools/graphics/zxing/zxing-cmdline-encoder.sh
new file mode 100644
index 000000000000..a17ba49cecf0
--- /dev/null
+++ b/nixpkgs/pkgs/tools/graphics/zxing/zxing-cmdline-encoder.sh
@@ -0,0 +1,3 @@
+#! /bin/sh
+
+java-zxing com.google.zxing.client.j2se.CommandLineEncoder "$@"
diff --git a/nixpkgs/pkgs/tools/graphics/zxing/zxing-cmdline-runner.sh b/nixpkgs/pkgs/tools/graphics/zxing/zxing-cmdline-runner.sh
new file mode 100644
index 000000000000..cb2a25dc03f7
--- /dev/null
+++ b/nixpkgs/pkgs/tools/graphics/zxing/zxing-cmdline-runner.sh
@@ -0,0 +1,3 @@
+#! /bin/sh
+
+java-zxing com.google.zxing.client.j2se.CommandLineRunner "$@"
diff --git a/nixpkgs/pkgs/tools/graphics/zxing/zxing.sh b/nixpkgs/pkgs/tools/graphics/zxing/zxing.sh
new file mode 100644
index 000000000000..ca6ac60bab69
--- /dev/null
+++ b/nixpkgs/pkgs/tools/graphics/zxing/zxing.sh
@@ -0,0 +1,18 @@
+#! /bin/sh
+choice="$1";
+shift
+case "$choice" in
+	encode | create | write | CommandLineEncoder)
+		zxing-cmdline-encoder "$@";
+		;;
+	decode | read | run | CommandLineRunner)
+		zxing-cmdline-runner "$@";
+		;;
+	help | usage | --help | --usage | -h)
+		zxing read;
+		zxing write;
+		;;
+	*)
+		zxing read "$choice" "$@"
+		;;
+esac