7 Replies Latest reply on Feb 10, 2013 9:28 AM by johnrellis

    How to package ImageMagick binaries?

    DFBurns

      My plugin uses ImageMagick's convert and, rather than hassle users with downloading it themselves, I'd like to package it with the plugin. This seems straightforward for Windows since IM provides builds of convert.exe. OSX is not so clear since IM suggests building that from source. I'm not going to ask users to use Homebrew if I can avoid it and I don't want to provide my own build. Any tips from people here about what they've done to package IM tools?

       

      db

        • 1. Re: How to package ImageMagick binaries?
          areohbee Level 5

          Dunno, but I am interested in the answer if anybody else knows. Perhaps Tim Armes knows (he wrote LR/Mogrify) which depends on Image Magick and I *think* does not require pre-installation by Mac users.

          • 2. Re: How to package ImageMagick binaries?
            johnrellis Most Valuable Participant

            My Any File plugin uses ImageMagick's "composite" program, and it is bundled in the plugin distribution, for precisely the reasons you describe.  It was pretty painful for me, not being a Mac programmer, to figure out how to build ImageMagick without shared libraries, so that "composite" was completely self-contained.  Here are my notes on how to do that:

             

             

            1. Download ImageMagick.tar.gz distribution to /Users/John.  Unpack it by
            doing:
                cd /Users/John
                tar xvfz ImageMagick.tar.gz
            See http://www.imagemagick.org/script/advanced-unix-installation.php
            2. Download the jpegsrc.tar.gz library from:
                http://www.imagemagick.org/download/delegates/
            to /Users/John/ImageMagick and unpack it with:
                cd /Users/John/ImageMagick
                tar xvfz jpegsrc.tar.gz
                mv jpegsrc<version> jpeg
            3. Configure and build the jpeg library:
                cd jpeg
                ./configure --disable-shared
                make clean; make
            4. Download the libpng.tar.gz library from:
                http://www.imagemagick.org/download/delegates/
            to /Users/John/ImageMagick and unpack it with:
                cd /Users/John/ImageMagick
                tar xvfz libpng.tar.gz
                mv libpng<verszion> png
            5. Configure and build the png library:
                cd png
                ./configure --disable-shared
                make clean; make
            6. Configure and build ImageMagick; copy configure.sh to ImageMagick 
            folder and do:
                cd /Users/John/ImageMagick
                sh configure.sh
                make clean; make
            7. Verify that composite is only loading dynamic libraries from /System and /usr/lib:
                otool -L utilities/composite
            7. Copy utilities/composite and config/delegates.xml to anyfile.lrdevplugin.
            
            

             

            And here's the contents of the "configure.sh" script referenced above:

             

             

            # Image-magick configure script for configuring with Any File
            # --disable-opencl \
            ./configure \
            --disable-installed \
            --disable-shared \
            --enable-delegate-build \
            --prefix=/ImageMagick-6.7.3-7 \
            --disable-dependency-tracking \
            --with-x=no \
            --without-perl \
            --with-freetype=no \
            --with-jp2=no \
            --with-tiff=no \
            --with-magick-plus-plus=no \
            --with-bzlib=no 
            
            
            
            • 3. Re: How to package ImageMagick binaries?
              DFBurns Level 1

              Thanks, John.

               

              Did you find any issues with OSX versions or will this produce a binary that works for a few versions back as well?

              • 4. Re: How to package ImageMagick binaries?
                johnrellis Most Valuable Participant

                There was a mysterious problem when OS X Lion came out in 2011, which was fixed by rebuilding the program:

                 

                http://forums.adobe.com/message/4037469#4037469

                 

                It appeared to be backward compatible with previous versions of Mac OS.  I haven't been able to do disciplined testing, so I rely solely on user reports. 

                • 5. Re: How to package ImageMagick binaries?
                  jarnoh Level 1

                  I've been through the same process for Focus Mask and I have pretty much same options. 

                   

                  At first release, I made the error of using "builtin" libpng (/usr/X11/lib/libpng.dylib) but that is actually just a stub if the user hasn't installed X11 runtime and it only displays X11 error dialog.

                  • 6. Re: How to package ImageMagick binaries?
                    DFBurns Level 1

                    Following up on this, this was great info and went pretty smoothly. The hiccup was when I wanted to include TIFF support since I need that. It wasn't as trivial as the jpeg or png delegates and also required tweaks to the main IM build. Here are my supplemental notes:

                     

                    - Using the same pattern of commands as for the jpeg and png libraries above, download the latest tiff library from the IM site, unzip/untar it, and rename the directory to tiff/

                    - cd to tiff

                    - Config the TIFF build using "./configure --disable-shared --disable-lzma"

                    - run the build: "make"

                     

                    - cd .. to the IM directory

                    - Use John's configure.sh file as above but add the following:

                        --disable-opencl --with-tiff=yes --without-lzma CFLAGS="-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0"

                    - run the build: "make"

                    - as with John's notes, run otool to verify no non-core dependencies.

                     

                    If it matters, I was using Xcode 4.6 and gcc version 4.2.1.

                     

                    db

                    1 person found this helpful
                    • 7. Re: How to package ImageMagick binaries?
                      johnrellis Most Valuable Participant

                      Good, thanks for the additional notes.