Imagemagic OSX static relocatable build

After long frustration, let's do this.
We want:

  • A relocatable binary (just the binary, nothing else)
  • Static plugins (delegates) such as png
  • Static freetype support so we can annotate images

Homebrew seems to be the most straightforward solution. See paragraph for the manual approach.

# Check available homebrew options
brew options imagemagick
# ok, looks like we need --without-modules --with-zero-configuration later

brew edit imagemagick
# in def install:
# --disable-shared to disallow shared libs

# now build. optionally uninstall:
brew uninstall imagemagick
brew install imagemagick --without-modules --with-zero-configuration

# your binaries are here:
echo `which convert montage compare`

A note on using freetype fonts:
because we built --with-zero-configuration, you might not be able to see any fonts to choose from. Using an absolute path to a font file as an argument to -font made this work for me, as in montage -font /path/to/arial.ttf -label ....


The hard way (works, but no freetype)
I'll try to stay fuzzy for future compatibility.

mkdir $IMBUILD

# get IM (Version 7 at the moment)
mkdir im_download && cd im_download
curl -O
for file in *.gz ; do tar zxf $file; done
rm *.tar.gz
cd ImageM*

# get delegates
# png
curl -O
tar zxf libpng*.gz && rm libpng*.gz && mv libpng* png && cd png
./configure --disable-shared --disable-dependency-tracking
cd ..

# freetype
curl -O
tar zxf freetype*.gz && rm freetype*.gz && mv freetype* freetype && cd freetype
./configure --disable-shared --disable-dependency-tracking
cd ..

# tiff
curl -O
tar zxf tiff*.gz && rm tiff*.gz && mv tiff* tiff && cd tiff
./configure --disable-shared --disable-dependency-tracking
cd ..

#build imagemagick (YMMV)
./configure --disable-shared --disable-dependency-tracking --enable-delegate-build --disable-installed --without-frozenpaths --prefix $IMBUILD --with-openexr=no --disable-docs --without-lcms --without-x --without-webp --without-jpeg --without-pango --enable-hdri=no --without-gvc
make install

ls $IMBUILD/bin