Homebrew: Share thumbnails and previews on OS X

Showing results for 
Search instead for 
Did you mean: 

Homebrew: Share thumbnails and previews on OS X

Active Member II
0 2 3,658

Homebrew. The missing package manager for OS X

As part of some recent testing for Alfresco Mobile 1.4 (1.4.1 is currently being reviewed by Apple), I noticed that my thumbnails and document previews had stopped working. All this probably coincided with an upgrade to OS X 10.8.2, JDK 7 and/or the phases of the moon - whatever it was it's time to fix it!

Previously I'd tried both MacPorts and Fink to install command line utilities, but these two projects seem to either be far too complex, or rarely up-to-date. Fortunately there's a new kid on the block, namely Homebrew. Built upon Ruby and git and some very sensible deployment choices (binaries are linked into your path, rather than installed there) it sounds like exactly what I needed to fix my development setup.

The first step is to ensure there's a good GCC compiler installed locally. If you happen to be running Xcode already, that's just a matter of choosing the optional 'Command Line Tools' component in Preferences / Downloads. There are probably many different ways of getting GCC installed, but Xcode would be the simplest, if perhaps not the most efficient disk space-wise. Anyway, now you've got Xcode installed there's nothing stopping you modifying and contributing to the Alfresco iOS Mobile source code -- so that's the option I'm going to recommend!

The next step is to install Homebrew itself; very simple by copy & pasting the command line:

$ ruby -e '$(curl -fsSkL raw.github.com/mxcl/homebrew/go)'‍

There's then a quick diagnostic check to confirm everything's copacetic:

$ brew update && brew doctor‍

In my case this showed I was running an old version of XQuartz (X.11 for OS X), so a quick download and install fixed that.

Homebrew packages are simply installed using 'brew install <package>'. Each package is scripted in such a way to download and install any mandatory dependencies. The Homebrew ethos is to not install any unnecessary cruft, so we'll have to bear that in mind when installing the packages Alfresco needs for transformations.

I've already got a local install of Apache OpenOffice, so just need to install: ImageMagick, Ghostscript and swftools. Ghostscript can be installed as an optional submodule of ImageMagick, so that's the first package:

$ brew install imagemagick --with-ghostscript‍

Let's check the installation:

$ gs --version

$ convert --version
Version: ImageMagick 6.7.7-6 2012-12-05 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2012 ImageMagick Studio LLC
Features: OpenCL

That all looks fine, so next comes swftools.

$ brew install swftools‍

Check the installation...

$ pdf2swf --version
-bash: pdf2swf: command not found‍‍

Hmmm.. what's going on here? A little Googling concludes that I'll need to manually install a few dependencies, as pdf2swf is actually an optional component within the swftools suite, so let's uninstall swftools and install the dependencies:

$ brew uninstall swftools
$ brew install lame
$ brew install giflib
$ brew install fftw‍‍‍‍

Now we're good to go with swftools again, and this time should get pdf2swf too:

$ brew install swftools‍

And check:

$ pdf2swf --version
pdf2swf - part of swftools 0.9.2

OK, so that was a little long-winded, but pretty easy overall.

But we're not quite done yet. OS X has its own version of the infamous Windows so-called 'DLL Hell' regarding .dylib files. The problem here involves the ImageIO system framework located at /System/Library/Frameworks/ImageIO.framework. It's evident when firing up the Alfresco Repository, as we'll start to see some transformation errors during bootstrap:

err: dyld: Symbol not found: __cg_jpeg_resync_to_restart
Referenced from: /System/Library/Frameworks/ImageIO.framework/Versions/A/Resources/libTIFF.dylib
Expected in: /usr/local/lib/libjpeg.8.dylib

Fortunately it's simple to fix, helped in part by the fact that Homebrew links binaries and libraries. We'll just need to re-link some image dylib files back to the ImageIO framework package, remembering to remove the problematic links first:

$ cd /usr/local/lib
$ rm libgif.dylib
$ ln -s /System/Library/Frameworks/ImageIO.framework/Resources/libGIF.dylib libGIF.dylib
$ rm libjpeg.dylib
$ ln -s /System/Library/Frameworks/ImageIO.framework/Resources/libJPEG.dylib libJPEG.dylib
$ rm libtiff.dylib
$ ln -s /System/Library/Frameworks/ImageIO.framework/Resources/libTIFF.dylib libTIFF.dylib
$ rm libpng.dylib
$ ln -s /System/Library/Frameworks/ImageIO.framework/Resources/libPng.dylib libPng.dylib

‍‍‍‍‍‍‍‍‍We'll also double-check that tomcat/shared/classes/alfresco-global.properties contains the right configuration for our new tools:


That should be it. Testing with Google Chrome (so I don't need a system-wide installation of Adobe Flash!) shows that thumbnails and previews are all working well within Share.

Share Document Library - Browse view

Share Document Library - Details Page

Hope this is of use to you.

-- Mike