Alfresco and ImageMagick on OSX

Blog Post created by wabson Employee on Aug 2, 2012
Since I migrated away from Windows on my development machine a couple of months back, I've not looked back. One of the main benefits I've found is being able to build software packages locally, and Homebrew makes that easy. Now I can easily grab the latest version of various dependencies such as MySQL and ImageMagick and install them in seconds, just as if I was using yum or apt-get.

However, one problem has plagued me since I started using the Homebrew-installed version of ImageMagick in conjunction with my local Alfresco installs, with errors such as this in the logs

 2012-08-02 10:20:10,547  DEBUG [transform.magick.AbstractImageMagickContentTransformerWorker] [main] org.alfresco.service.cmr.repository.ContentIOException: 07020000 Failed to perform ImageMagick transformation: 

Execution result:

   os:         Mac OS X

   command:    [/usr/local/bin/convert, /Users/wabson/Development/projects/share-extras-2/software/tomcat/temp/Alfresco/ImageMagickContentTransformerWorker_init_source_4067880520213204197.gif[0], /Users/wabson/Development/projects/share-extras-2/software/tomcat/temp/Alfresco/ImageMagickContentTransformerWorker_init_target_7684811633126657147.png]

   succeeded:  true

   exit code:  133


   err:        dyld: Symbol not found: __cg_jpeg_resync_to_restart

  Referenced from: /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ImageIO.framework/Versions/A/ImageIO

  Expected in: /usr/local/lib/libjpeg.8.dylib

 in /System/Libra

This frustrated me for a while. It happened every time Alfresco tried to call convert in order to effect an image transform - for instance generating doclib thumbnails - but running the exact same command at a bash prompt worked fine.

Various internet posts all pointed to the environment in which ImageMagick is run as being the cause for such problems. It seemed the environment variable DYLD_LIBRARY_PATH in particular was known to cause problems on OS X, but checking /etc/profile, /etc/bashrc and the custom alfresco.sh script I use to start up Alfresco (included in my Tomcat packages) did not yield any trace of such a variable.

Finally I found a comment in ALF-13452, which led me to check the Spring config within the thirdparty subsystem, responsible for starting up ImageMagick.

   <bean id='transformer.worker.ImageMagick'>

      <property name='mimetypeService'>

         <ref bean='mimetypeService' />


      <property name='executer'>

         <bean name='transformer.ImageMagick.Command'>

            <property name='commandsAndArguments'>


                  <entry key='.*'>










            <property name='processProperties'>


                  <entry key='MAGICK_HOME'>



                  <entry key='DYLD_LIBRARY_PATH'>



                  <entry key='LD_LIBRARY_PATH'>





            <property name='defaultProperties'>


                  <prop key='options'></prop>






There it was. The subsystem itself was setting up a few environment variables before firing up the external process, and these were defined in processProperties. One was the DYLD_LIBRARY_PATH variable.

The solution was trivial. I copied the Spring config in tomcat/webapps/alfresco/WEB-INF/classes/alfresco/subsystems/thirdparty/default/imagemagick-transform-context.xml into tomcat/shared/classes/alfresco/extension/subsystems/thirdparty/default/default/imagemagick-transform-context.xml as per the subsystems docs on overriding beans, and commented out the offending <entry> element.

mkdir -p tomcat/shared/classes/alfresco/extension/subsystems/thirdparty/default/default/

cp tomcat/webapps/alfresco/WEB-INF/classes/alfresco/subsystems/thirdparty/default/imagemagick-transform-context.xml tomcat/shared/classes/alfresco/extension/subsystems/thirdparty/default/default/

vim tomcat/shared/classes/alfresco/extension/subsystems/thirdparty/default/default/imagemagick-transform-context.xml

The result - image conversions now work perfectly in my local dev environment using the Homebrew-installed version of ImageMagick.