Update ImageMagick on Travis-CI

I have an open source software project called Imbo that I have hooked up to Travis-CI for testing of pull requests and pushes on GitHub. I recently came across an issue that made some tests fail on Travis-CI that passed on all other machines I run tests on. The issue seemed to be because of an old version of ImageMagick (6.6.9-7). Travis-CI use this version since they base their VM’s on Ubuntu-12.04-LTS, and that version of ImageMagick is the one currently available on 12.04.

I solved it by compiling my own version of ImageMagick via the .travis.yml file:

  - wget http://www.imagemagick.org/download/ImageMagick.tar.gz
  - tar xf ImageMagick.tar.gz
  - cd ImageMagick*
  - ./configure --prefix=/usr
  - make
  - sudo make install
  - cd ..
  - printf "\n" | pecl install imagick-beta

This made the tests pass, but the build went from taking about 2 minutes to 10, so it was not really a good fix. After asking around on the #travis-ci channel on IRC (freenode) @henrikhodne said that they might upgrade the package if they found a decent PPA. I looked around myself and found a PPA for Ubuntu-12.04 that had a newer version of ImageMagick available, so I decided to try and use that instead of compiling my own to see if that might speed up the build. I replaced the above snippet with the following in the .travis.yml file:

  - sudo add-apt-repository -y ppa:moti-p/cc
  - sudo apt-get update
  - sudo apt-get -y --reinstall install imagemagick
  - printf "\n" | pecl install imagick-beta

This reduced the build time to around 3 minutes, and all tests are passing! Travis-CI, I LOVE YOU!

This entry was posted in PHP, Technology and tagged , , , , , , , , . Bookmark the permalink.

5 Responses to Update ImageMagick on Travis-CI

  1. beherca says:

    Imbo is a great project and thank you very much.
    May I ask that is it possible to use imbo as a file storage server mainly serves files like docs, excels etc only? I see its potential to do that and would like to know if there is a easy way to do that?

  2. Los mios quedaron en Venezuela, los extrao un montn, sobre todo al llegar en las noches y no tener que pelear con nadie para que no entren al carro y me den un lametazo.nAhora te pongo en mis enlaces. Come on http://tropaadet.dk/langblack91767081845

  3. Bruce says:

    4 years later and Google got me here with the same insidious problem – Travis tests failing, while locally run ones were fine. Eventually turned out to be Travis’ old ImageMagick was the cause. In my case the sha1 hashes of a cropped image didn’t match with my development run – using exactly the same image! Was starting to lose my mind thinking sha1 algorithm was different in Travis-CI.. I guess ImageMagick must have subtly changed how images are cropped between (Travis Trusty distro) & version I have locally ( on Zesty).

    I haven’t found a repo for Trusty pre-built binaries above what Travis has, so complied from source (time-consuming, as you say). Nevertheless your script allowed me to fix the problem & retain my sanity, so thanks for the post.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s