cloud goes social


computer, travel, movies, music, cuisine and more

ImageMagick on iPhone (with jpeg + png)

UPDATE: iOS4.3 and Xcode4


I’m working on some iPhone applications, which need some image filtering. For now, I won’t say more! Stay tuned for the news when it comes out!

Long story short, I soon found the need (ant the challenge was a good one) to get ImageMagick static libraries so that I can use it on the iPhone. Not only that, but with jpeg and png support. That’s what I need.

After a fast search through the net, I couldn’t find a single _GOOD_ post on how to do that. Just some bits and bytes – Nothing complete.

I soon set on a mission to get ImageMagick to work on the iPhone, as a library. And here’s the result of my quest (around 1 day of search, trials and errors, and at last some light!)


I’m running MacOSX 10.5.7, with the latest MacPorts installed. If you don’t, get it! I have many ports installed, the ones I “think” are important are:

  • jpeg
  • libpng

Also, I’m testing everything with the latest beta of the iPhoneOS 3.0 – It should be working also for 2.2.1 and the final 3.0 when it comes out.

The Script

I now provide you with a shell script that should do the whole trick of creating the static libraries needed in Xcode for iPhone development.

Just download it, give it run permission (chmod +x ./, and launch it. It will ask for your password because it needs to copy a file that is not owned by you, the user.

Before complaining that it’s not working, open it, and look at the required directory structure for it to work.
In particular you will need:

  • a Desktop folder named cross_compile
  • ImageMagick source: ImageMagick
  • jpeg source: jpeg
  • – to which I’ve added the MacPorts patches

  • libpng source: libpng
  • Untar ImageMagick source and place it into ~/Desktop/cross_compile/i_m
  • Untar/Unzip jpeg/libpng source and place it into: ~/Desktop/cross_compile/i_m/IMDelegates/jpeg-6b and ~/Desktop/cross_compile/i_m/IMDelegates/libpng-1.2.37

Now you can run the script :)


The result will be stored under: ~/Desktop/tmp_target. In particular you can find all the header files needed while developing your application under: ~/Desktop/tmp_target/im_libs/includes (divided by library). While all the static libraries are inside ~/Desktop/tmp_target/im_libs/:

  • libjpeg.a
  • libpng.a
  • libMagickCore.a
  • libMagickWand.a

Please note that the script joins both the i386 and the arm build inside one single .a static library to ease up developing (for testing both on the Simulator and on the device itself. When finishing up the application you may want to put only the arm library to make the overall application lighter.

XCode configuration

Step 1

To work with your libraries you need to put some easy adjustments to your Project in XCode. I’ve found that the best thing to do, especially in a shared environment with multiple developers, to just put everything inside the XCode project. To do so do:

  • Project->Add To Project->Select all the .a libraries->Click ‘ADD’
  • Project->Add To Project->Select the folders inside the ~/Desktop/tmp_target/im_libs/include->Click ‘ADD’

Step 2

Click on Project->Edit Project Settings and edit (in the Build:

  • Other Linker Flags: -lMagickCore -lMagickWand -lz -lbz2 -ljpeg -lpng
  • Header Search Paths: $(SRCROOT) – make it Recursive
  • Library Search Paths: $(SRCROOT) – make it Recursive
  • On the lower left click on the small-wheel and select: Add User-Defined Setting
    • Value: -Dmacinsoth=1

This should be enough to make you start.

For the Lazy

If you’re lazy, don’t manage or for whatever other reason you can just download the whole compiled package

Last note

In case the script doesn’t work, you have questions/suggestions/support please don’t hesitate to contact me, and in case you need help with the script please send me the FULL output in a file.
./ > file_to_send.txt

ROR on Xampp on Win

For those who don’t understand the title don’t worry, this is a “technical” post: installing Ruby on Rails (ROR) over an existing XAMPP (Apache, PHP, MySQL, …) installation in Windows. For all of those who have somehow a Windows “server” used to test websites and want to install Ruby and the fantastic Ruby on Rails framework.

Prerequisites: a working installation of XAMPP, in my example installed under: C:\xampp.

  1. Install ROR via the “one click installer” which can be found on the ROR site: installers list. To have everything in one “web-development directory” when prompted by the installer choose C:\xampp\ruby
  2. Open the dreaded DOS-prompt or cmd: Start->Run->cmd
  3. First off update gem, The version installed will stop whenever an update fails, to solve this update gem first. Let’s navigate to the ruby bin directory:
    cd C:\xampp\ruby\bin
    and then the command:
    gem update --system
  4. Now all the gems are updated, install rails with this command:
    gem install rails --include-dependencies
    This will take a while especially for generating the whole documentation, don’t worry, everything is going all right, wait and be patient
  5. Create a test application with the command:
    rails C:/xampp/htdocs/testapp
    If all went fine you will see some output saying that some files have been created. Rails is installed all fine
  6. Now it’s time to create a Virtual Host in apache to test out our installation. Edit the file: C:xamppapacheconfextrahttpd-vhosts.conf with your favourite good editor. I always have installed Notepad++ and at the end add the following lines:
    ## ROR
    Listen 3000
    <VirtualHost *:3000>
    	ServerName ROR
    	DocumentRoot "C:\xampp\htdocs"
    	<Directory "C:\xampp\htdocs">
    		Options ExecCGI FollowSymLinks
    		AllowOverride all
    		Allow from all
    		Order allow,deny
    		AddHandler cgi-script .cgi
    		AddHandler fastcgi-script .fcgi
    ## END-ROR
  7. Restart apache from the XAMPP control panel and then go, on your favorite browser to:
    To see if everything went fine, the page should look like this screenshot
    ROR installed on XAMPP in Windows

    ROR installed on XAMPP in Windows


At the moment of this writing this is the list of version numbers for the installed applications running and working as configured in this post:

  • XAMPP: 1.6.6a
  • ruby -v: ruby 1.8.6 <2008-08-11 patchlevel 287> [i386-mswin32]
  • gem -v: 1.3.3
  • rails -v: Rails 2.3.2

I would like to thank the author of this post which is the starting point of my post. I just did some minor changes to remove some errors, especially when updating gems. Also I changed the file to edit to add the Virtual Host to keep things more clean in the http.conf file.

For any trouble don’t hesitate to contact me!


CLOUD GOES SOCIAL is the personal blog of Claudio Marforio.
He holds a MSc in Computer Science with focus on Information Security granted by ETH Zurich. He is currently a PhD Student in the System Security Group of ETH Zurich



If you appreciate my work, my applications, this blog in general or you simply feel like rewarding me for something please consider donate.
Any amount will motivate me in keeping up with the blog and the applications.

Thank you!


F. Olsen, W. Chang, W. Edmondson, C. Sharff, M. Brown, G. Helton, J. de Ruiter, K. Langner, K. Smith, T. OHalloran, B. Zabarauskas

Listening to ...