computer, travel, movies, music, cuisine and more
ImageMagick for iPhone via SnowLeopard
1.5.2010 – UPDATE: for the latest compiled libraries and test project please refer to: Latest ImageMagick
Hi all ImageMagick developers!
It has been a long time since my last update to my script for building ImageMagick and having it running as a statically compiled library so that you can use it in all your iPhone applications! To make up for the delay I have made some improvements:
- Script now working on Snow Leopard (tested on 10.6.2 against iPhone SDK 3.1.3)
- Script better organized (although I want to make it even better!)
- Script available through github, so if you want to help me updating it, know some bash scripting, and willing to help, just contact me!
- Updated libpng to v1.4.0 and libtiff to v1.9.2
As usual I also link you a .zip containing all the .a universal (iPhone + iPhoneSimulator) libraries that you can use right away in your projects! I’ve also updated the test project, just minor changes, and the new libraries!
I hope you are happy with the update, and I would like to thank:
Verdier Christophe for a much better script stub posted in the comments
Cocoawithlove.com for a good guide on understanding why the heck the iPhoneSimulator libraries weren’t working at all!
Don’t be shy and comment, also pointing me to some cool iPhone Apps that you’ve been working on that use ImageMagick!
~C
| Print article | This entry was posted by Cloud on February 10, 2010 at 2:38 am, and is filed under Code, tips & howtos. Follow any responses to this post through RSS 2.0. You can leave a response or trackback from your own site. |



about 4 months ago
While GraphicsMagick does use OpenMP, the design of OpenMP is that it is optional and so it is not required. ImageMagick also uses OpenMP. The effort to port GraphicsMagick to iPhone should be no different than ImageMagick, and in fact much of what was learned from porting ImageMagick should apply.
GraphicsMagick has been tuned to perform well on less-capable CPUs (even 11 years old) so there is a good chance that it will perform better on iPhone than ImageMagick.
Bob (GraphicsMagick maintainer)
about 4 months ago
Hi Bob and thank you for your clarification.
I will then look into porting GraphicsMagick to the iPhone. I thought its main strength was that of using OpenMP, which I know also ImageMagick is using and I’m now turning it off at compile time.
I will have a look at compilation steps for GraphicsMagick in the following days, especially at the compilation of it as a static library. I will contact you directly whenever I will manage or if I stmble over any major problem.
Regards,
C
about 4 months ago
That is good to hear. I think that you will find that the ImageMagick configure script is rather like the one in GraphicsMagick, since I wrote the ImageMagick configure script, and ImageMagick has also borrowed heavily from the GraphicsMagick makefiles. I think that ImageMagick now produces somewhat different libraries.
GraphicsMagick does a static build by default. Depending on what the iPhone prefers, you could disable OpenMP support, and even disable POSIX thread safety (use of mutex locks) in the build.
Someday I hope to add a way to allow the user to use the configure script to remove features from GraphicsMagick so that it can be easily made slimmer. For example, it is unlikely that an iPhone user would want support for the DICOM medical image format, or many of the other formats.
Bob
about 4 months ago
Links are a bit upated, please give me around 4hrs to get back home and prepare an updated version of this post :)
For now everyone can find latest (6.6.1-5, without the infamous bz2) working links at this address: http://www.imagemagick.org/discourse-server/viewtopic.php?f=2&t=16043&p=58221#p58221
Regards
about 4 months ago
Hi,
Can you please build imagemagick with the latest build. They have made some changes to remove the NSGetEnviron and bz2 methods.
I have compiled it on my mac. But I don’t think mine is working properly.
http://imagemagick.org/discourse-server/viewtopic.php?f=2&t=16043
about 4 months ago
Working on it, thank you for the tip.
about 4 months ago
Please find all the links to the updated versions (working) here: http://www.imagemagick.org/discourse-server/viewtopic.php?f=2&t=16043&p=58221#p58221
about 4 months ago
I’ve heard, GraphicsMagick is a interssant altnative and faster as imageMagic, can you
perhaps help to bring GraphicsMagick run on iphone, thtanks.
about 4 months ago
Direct solution is to find which code need use this function , and just use some mock codes to replace it. If ImageMagick community can do this, that will be perfect.
Welcome for further communication via skype : forrest.shi
about 4 months ago
Hi, Do you think you would be able to port Graphicsmagick (http://www.graphicsmagick.org/.) to the iphone. Maybe it will work.
about 4 months ago
Hi, at the moment I cannot look into it as I’m really busy with work and studies. Anyway I see that graphicsmagick is working with OpenMP which doesn’t exist for ARM (to my knowledge) so it would require some work to port it.
It’s weird because I know of other applications on the appstore that have been submitte even using imagemagick…
about 4 months ago
Hey,
Can you give me some pointers where the solution could be. I will try to tinker on my own. Does imagemagick need the bz2 methods. Do you know how to change the method names?
about 4 months ago
Just to let you know.
http://www.imagemagick.org/discourse-server/viewtopic.php?f=2&t=16043
I think this is the fix we have been waiting for.
about 4 months ago
My app was rejected by apple because of these reasons.
The following non-public APIs are included in your application:
_NSGetEnviron
BZ2_bzclose
BZ2_bzCompress
BZ2_bzCompressEnd
BZ2_bzCompressInit
BZ2_bzDecompress
BZ2_bzDecompressEnd
BZ2_bzDecompressInit
BZ2_bzflush
BZ2_bzopen
BZ2_bzread
BZ2_bzwrite
If you have defined methods in your source code with the same names as the above mentioned APIs, we suggest altering your method names so that they no longer collide with Apple’s private APIs to avoid your application being flagged with future submissions.
Can we do anything about this?
about 4 months ago
I would have to look into it. Thank you for the report.
about 4 months ago
Due to think removing -lbz2 from other linker flags would help?
about 4 months ago
I just got rejected for this too. I think the problem is NSGetEnviron
about 4 months ago
:( This does not work. I am totally *******. Do you think there is a workaround to this issue.
about 5 months ago
While we’re waiting for them to release the update, do you have any more information on why the build would fail for the sim with the
“_GOMP_loop_dynamic_start”, referenced from:
errors? Even if you can point me in the right direction, I might be able to get this running on my own. I’d like to get something working in the meantime until they release 6.6.1.
Thanks!
about 5 months ago
Thank you for your hard work. It is very nice indeed.
I found a method called MagickReadImage(magick_wand, image)
Is it possible to read this way and display the images?
I’m sorry this is a strange question. I’m new to image magick.
about 5 months ago
Cool!
about 5 months ago
It looks like this library is missing a few things, like the MagickAutoLevelImage (or any of the Auto methods). Is this using an older version of ImageMagick? Can you run your script on the latest one so we can get all of the new methods in the library?
about 5 months ago
So I’ve been playing with your build script all night, and have been making progress. I’ve got all of the helper libraries (tiff, jpeg and png) compiling for ARM and sim, including the dynamic libraries and everything. The intel IM builds as well, but the ARM IM fails every time. I’m trying to compile 6.6.0-7, and it fails here:
CC magick/magick_libMagickCore_la-random.lo
magick/random.c:111:25: error: crt_externs.h: No such file or directory
make[1]: *** [magick/magick_libMagickCore_la-random.lo] Error 1
make: *** [all] Error 2
Did you run into this? How did you solve it? I’m not sure what to do from here… It took a lot of work to get the other libraries to build properly, but this one won’t build no matter what I do.
about 5 months ago
Look at the script, I’m copying over a file that’s needed for compilation:
sudo cp /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.1.3.sdk/usr/include/crt_externs.h \$SDKROOT/usr/include/crt_externs.h
about 5 months ago
I will pull the newest ImageMagick from SVN and try a compilation. Please stay tuned!
about 5 months ago
I’ve been working to compile 6.6.0-7 (latest) for the iPhone but at the moment there’s an issue. Please wait for a new release of the compiled library as for this version (actually for any version after 6.6.0-1) there’s no possibility of compiling it for the iPhone, yet.
about 5 months ago
I see the copy now, I didn’t notice that it was commented out.
What’s the issue with the newer versions? I noticed another issue with _j0 and _j1, is this the same thing you’re seeing? What is the actual problem with that?
about 5 months ago
Another issue – I tried compiling 6.6.0-0 to see if it would work (and it does, I get the arm and 386 libs for everything and a nice set of libraries to use) but when I add them to my iPhone Xcode project, I get a bunch of build errors when building for the sim. I replaced the old libraries from this original post, which all compiled (and worked) fine. The errors I’m getting are all “referenced from” errors:
“_GOMP_loop_dynamic_start”, referenced from:
Looks like another one of your commenters had a similar problem with the pre-SL script but I’m not sure what the difference was (I’m also on snow leopard). The library compiles perfectly for the device, it’s only not building for the sim.
about 4 months ago
fixed it. Please find in the next days an up to date version of the script and library. Thank you for noticing!
Had to add: –disable-openmp to the i386 parameters.
about 5 months ago
Yes: the problem resides in those functions that are not available on the iPhone math.h implementation. I posted the issue over at the ImageMagick developers forum and they assured me they have a solution about it which is coming out in the next point release (in a few days), so please stay tuned here and I will provide you with a good-to-go sign and a compiled library!
~C
about 4 months ago
They fixed it in the latest svn trunk. I managed to recompile with the newest versions of the softwares. Stay tuned for a new release of script and compiled library
about 5 months ago
Just played with it, very nice. fyi, the png library fails on read/write of files.
Cheers Bill
about 2 months ago
I found out the problem. Now fixed in latest version available