How to build GIMP-CCE
a version of high bit depth GIMP that's patched to allow editing in any well-behaved RGB working space

Default babl/GEGL/GIMP has hard-coded sRGB color space parameters that guarantee wrong results for anyone editing an image that's in a color space other than sRGB. My patched babl/GEGL/GIMP can be used to edit images in any well-behaved RGB working space. My patched GIMP also contains selected additional unclamped layer blend modes.

This article used to be a guide to applying my patches to modify babl/GEGL/GIMP. However, not everyone is comfortable applying patches. So I put the already patched code up on github. And now this page has instructions for building the already patched babl/GEGL/GIMP.

Written June 2015. Updated June 2017.

The github patched babl/GEGL/GIMP code is up-to-date with upstream (default babl/GEGL/GIMP) through June 18, 2017.

Introduction: GIMP patched for high end workflows

Default high bit depth GIMP 2.9/2.10 no doubt will make a lot of current users of the 8-bit GIMP 2.8 very happy. But default high bit depth GIMP won't meet the needs of digital artists and photographers who work in color spaces other than sRGB. For reasons why default GIMP 2.9/.10 won't meet the needs of many potential GIMP users who've long awaited the day GIMP would finally support high bit depth editing, see Hard-coded sRGB parameters in default high bit depth GIMP and Color management and other differences between default GIMP and Elle Stone's patched "GIMP-CCE".

Building Elle Stone's patched babl/GEGL/GIMP

Preliminary notes

Working at the command line is always risky. If you've never compiled source code, please be warned that things can go very wrong, and especially if you enter the wrong command at the wrong place. So here is the requisite warning and disclaimer:

Use the information on this page and my patched babl/GEGL/GIMP code from github at your own risk! The information and code are distributed in the hope that they will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. In other words, if you end up destroying your images or XCF files, wiping out your hard drive, or otherwise generally messing things up, well, you've been warned.

For anyone running 64-bit Windows or MacIntosh, Partha very kindly makes "portable experimental" versions of my patched GIMP (Linux users are not so lucky!).

Building the patched babl/GEGL/GIMP

The code boxes below provide the commands for cloning and building my patched babl/GEGL/GIMP from my github repositories, and does assume that you are familiar with cloning and building software. For a full tutorial on building GIMP (with the corresponding commands for building the default, unpatched babl/GEGL/GIMP from the GNOME git repositories) see Building GIMP for artists and photographers.

# Set up some folders for building and installing 
# the patched babl/GEGL/GIMP :
mkdir $HOME/code
mkdir $HOME/code/gimpcce
mkdir $HOME/code/gimpcce/build
mkdir $HOME/code/gimpcce/install
mkdir $HOME/code/gimpcce/install/share
mkdir $HOME/code/gimpcce/install/share/aclocal
touch $HOME/code/gimpcce/install/share/aclocal/gimp-2.0.m4

# Clone the software from Elle Stone's github repositories
cd $HOME/code/gimpcce/build
git clone https://github.com/ellelstone/babl
git clone https://github.com/ellelstone/gegl
git clone https://github.com/ellelstone/gimp

# Don't forget to also clone libmypaint
git clone git://github.com/mypaint/libmypaint.git

# Set up the prefix by telling gcc where to look for software:
# Don't forget to modify the lines with "lib" and "gio" to match your Linux distribution!
PREFIX=$HOME/code/gimpcce/install
export PATH=$PREFIX/bin:$PATH
# Some Linux distributions use "lib64" instead of "lib"!
export LD_LIBRARY_PATH=$PREFIX/lib:$LD_LIBRARY_PATH
export XDG_DATA_DIRS=$PREFIX/share:$XDG_DATA_DIRS
export ACLOCAL_FLAGS="-I $PREFIX/share/aclocal"
export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig"
export PKG_CONFIG_PATH=$PREFIX/lib/pkgconfig:$PKG_CONFIG_PATH
# Line below is for Gentoo!!!!!!!!!! It won't work on Debian/Ubuntu/etc!
export GIO_EXTRA_MODULES=/usr/lib/gio/modules
export SRC_DIR=$HOME/code/gimpcce/build

# Build and install babl/GEGL/libmypaint/GIMP in the prefix:
cd $SRC_DIR/babl
./autogen.sh --prefix=$PREFIX --enable-mmx=no --enable-sse=no --enable-sse2=no --enable-sse4_1=no --enable-f16c=no --enable-altivec=no --disable-docs && make -j5 && make -j5 install

cd $SRC_DIR/gegl
./autogen.sh --prefix=$PREFIX --disable-docs --enable-gtk-doc=no --enable-gtk-doc-html=no --enable-gtk-doc-pdf=no --enable-workshop --without-libv4l2 --without-libavformat --without-sdl && make -j5 && make -j5 install

cd $SRC_DIR/libmypaint
./autogen.sh --prefix=$PREFIX 
./configure --prefix=$PREFIX
make -j5 && make -j5 install

cd $SRC_DIR/gimp
./autogen.sh --prefix=$PREFIX --disable-gtk-doc --enable-debug=yes --with-gimpdir=$PREFIX/config && make -j5 && make -j5 install

The build process will stop and an error message will be printed to screen if it turns out that you need to install additional software either installed in your prefix or installed from your Linux package manager. See Building GIMP for artists and photographers for details.

Sometimes the build process for GIMP will fail with the following error messge:

gimp/gimp/libgimp/gimp_pdb.c:74:1: error: redefinition of ‘gimp_’
 gimp_ (void)
 ^
gimp/gimp/libgimp/gimp_pdb.c:47:1: note: previous definition of ‘gimp_’ was here
 gimp_ (void) 

This error message indicates that two "auto-generated" files were modified during the initial build process. I haven't figured out why this happens or how to keep it from happening. Until I do, the solution is simple. Just type the following two commands into the terminal:

git checkout libgimp/gimp_pdb.c libgimp/gimp_pdb.h
make -j5 && make -j5 install
# Of course replace "-j5" with whatever "-j" number is appropriate for your system.

And now GIMP should finish building and installing without any problems.

Optional: Build and install PhotoFlow in your prefix

If you want a cutting edge 32-bit floating point raw processor that also provides a GIMP plug-in, I recommend building and installing PhotoFlow in the same prefix as your patched babl/GEGL/GIMP:

Steps to build and install PhotoFlow:

# Just as when installing babl/GEGL/GIMP, the first step is to
#set up the prefix by telling gcc where to look for software:
# Don't forget to modify the lines with "lib" and "gio" to match your Linux distribution!
PREFIX=$HOME/code/gimpcce/install
export PATH=$PREFIX/bin:$PATH
# Some Linux distributions use "lib64" instead of "lib"!
export LD_LIBRARY_PATH=$PREFIX/lib:$LD_LIBRARY_PATH
export XDG_DATA_DIRS=$PREFIX/share:$XDG_DATA_DIRS
export ACLOCAL_FLAGS="-I $PREFIX/share/aclocal"
export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig"
export PKG_CONFIG_PATH=$PREFIX/lib/pkgconfig:$PKG_CONFIG_PATH
# Line below is for Gentoo!!!!!!!!!! It won't work on Debian/Ubuntu/etc!
export GIO_EXTRA_MODULES=/usr/lib/gio/modules
export SRC_DIR=$HOME/code/gimpcce/build

# PhotoFlow requires a recent version of VIPS, 
# which hopefully your Linux package manager provides. 
# Otherwise you'll have to install VIPs yourself.
# I downloaded VIPS and installed it in /usr/local, 
# so as part of setting up the prefix I need to tell PhotoFlow where to find VIPS:
export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig"

# Now that the prefix has been established, 
# the next step is to cd to your prefix's build folder: 
cd $SRC_DIR

PhotoFlow is available in several versions:

 # 1. For the latest code from PhotoFlow git master:
git clone https://github.com/aferrero2707/PhotoFlow

# 2. If you prefer the stable development version, which often works
# better than the latest official release, clone the
# stable branch of PhotoFlow:
git clone https://github.com/aferrero2707/PhotoFlow -b stable 

# 3. If you prefer to try an experimental version with improved
# color management and better support for linear scene-referred
# editing, clone the linear_gamma branch of PhotoFlow
# (this is the branch of PhotoFlow that I use, 
# but be forewarned that experimental code does sometimes fail to work): 
git clone https://github.com/aferrero2707/PhotoFlow -b linear_gamma

# Now it's time to build PhotoFlow. The PhotoFlow code provides its own "build"
# subfolder (not to be confused with the $SRC_DIR, which is also named "build").
# So cd to the PhotoFlow build subfolder:
cd $SRC_DIR/PhotoFlow/build

# Here are the commands for building and installing PhotoFlow.
# Note that these commands install PhotoFlow in its own subfolder named "Release":
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$(pwd)/Release -DBABL_FLIPS_DISABLED=ON -DINSTALL_PREFIX=$(pwd)/Release ../
make VERBOSE=1 install -j3

# Before you can install the PhotoFlow GIMP plug-in, 
# the GIMP config folder needs to be created. 
# So if you haven't yet run your patched GIMP for the first time, 
# you can make the folder at the command line:
mkdir $PREFIX/config
mkdir $PREFIX/config/plug-ins/

# Now copy the PhotoFlow plug-ins over to the GIMP plug-ins folder:
cp $SRC_DIR/PhotoFlow/build/Release/share/photoflow/plug-in/pfgimp $PREFIX/config/plug-ins/
cp $SRC_DIR/PhotoFlow/build/Release/share/photoflow/plug-in/pfgimp-load $PREFIX/config/plug-ins/

Updating Elle Stone's patched babl/GEGL/GIMP

This section is not yet written. In theory the procedure is very similar to updating default babl/GEGl/GIMP, except do NOT try to update from the default babl/GEGL/GIMP repositories on the Gnome servers. Instead pull new code from Elle Stone's github babl/GEGL/GIMP repositories.

Hopefully you noticed the words "in theory". In practice, it's better to start with a clean slate and reinstall from scratch. This means set up your prefix and then "cd" to each of the babl, GEGL, libmypaint, and GIMP folders, and run the following command:

make uninstall && make clean && git clean -xdf

Then delete all the folders in your install folder except your config folder, which holds your personal preferences for setting up GIMP.

Then go back to the terminal where you've already set up the prefix, and type the following commands:

mkdir $PREFIX/share
mkdir $PREFIX/share/aclocal
touch $PREFIX/share/aclocal/gimp-2.0.m4

And then reinstall babl, GEGL, libmypaint, and GIMP, starting from the "./autogen" command.

If you try to mix code from the default GNOME repositories and my patched github repositories, you will create a tangled mess of code that probably won't merge successfully. If it does merge, the resulting code probably won't compile. If the code does compile, it almost certainly won't produce correct editing results. You've been warned!

Starting and using your patched GIMP

Starting your patched GIMP

If all went well, babl/GEGL/GIMP are now patched, and ready to use. And if you built PhotoFlow, PhotoFlow also is ready to use. If you encountered any issues, send me an email and I'll try to help figure out how to fix whatever went wrong.

So assuming the install procedure was successful, the next step is to actually start and use your patched GIMP. The information below was copied almost verbatim from my tutorial on building default GIMP from git, except with appropriate modifications for starting your patched GIMP:

Now you have GIMP installed in your gimpcce prefix. You might also have GIMP installed from your Linux package manager. And you might have other versions of GIMP installed in other prefixes. So the next step is to make it possible to actually run the version of GIMP that you installed in the gimpcce prefix.

With a plain text editor (leafpad, geany, bluefish, etc), make a document with the following lines:

#! /bin/bash
PREFIX=$HOME/code/gimpcce/install
export PATH=$PREFIX/bin:$PATH
export LD_LIBRARY_PATH=$PREFIX/lib:$LD_LIBRARY_PATH
export XDG_DATA_DIRS=$PREFIX/share:$XDG_DATA_DIRS
export ACLOCAL_FLAGS="-I $PREFIX/share/aclocal"
export PKG_CONFIG_PATH=$PREFIX/lib/pkgconfig:$PKG_CONFIG_PATH
export GIO_EXTRA_MODULES=/usr/lib/gio/modules
export SRC_DIR=$HOME/code/gimpcce/build
GEGL_USE_OPENCL=no
export GEGL_USE_OPENCL
$PREFIX/bin/gimp-2.9 -n$@

Don't forget to modify the lines given above to match your Linux distribution! Some Linux distributions use "lib64" instead of "lib". And the path for "GIO_EXTRA_MODULES" also varies between different Linux distributions.

Save the plain text document as "rungimpcce" in some convenient location. I save it in the gimpcce prefix folder "$HOME/code/gimpcce". Then make the "rungimpcce" file executable by cd'ing to the folder where you saved "rungimpcce", and typing the appropriate "chmod" command:

cd $HOME/code/gimpcce
chmod +x rungimpcce

To start your patched GIMP, navigate to the folder with the "rungimpcce" file ("cd $HOME/code/gimpcce") and type "./rungimpcce":

cd $HOME/code/gimpcce
./rungimpcce

Using your patched GIMP

Differences between default high bit depth GIMP 2.9 and Elle Stone's patched "GIMP-CCE" goes over some of the differences between default GIMP and my patched GIMP from a user perspective. You also might find this article useful: Tutorials and notes for using Elle Stone's patched "GIMP-CCE".

For information on using the PhotoFlow plug-in from within your patched GIMP, see How to use the latest version of the PhotoFlow GIMP plug-in and various tutorials on the PhotoFlow Image Editor Blog.

Please note that the latest version of the linear gamma branch of PhotoFlow can't be used as a GIMP plug-in. This is a temporary (and unintended) situation. As a workaround I'm using an earlier version of the linear gamma branch. But the stable branch does still work as a plug-in.