Feb 10, 2010
ImageMagick for iPhone via SnowLeopard
UPDATE: iOS4.3 and Xcode4
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

Hi:
Thanks for a nice sample project, but as I never been into image editing/processing thing, so I am having a lil problem in understanding the logic. Anyways, I just need to know that is there any good documentation available for imagemajick that I can use to generate some effects for my next app, like instagram do in their app. If that documentation is for iphone than it’ll be more helpful.
You can see all documentation on IM website, for example here: http://imagemagick.org/script/magick-wand.php?ImageMagick=lvbo3786pk8tb3jfgj1ld8i7f5 – And look around in Google!
~C
Hey ,
Please Help me . I am stuck at this point from last 4 days ….
Thanks ,
Ashish Sudra
You can get it here: http://www.cloudgoessocial.net/im_iphone/IM_Test.zip
Hello ,
Thanks a lot for this code .But its not converting array of PNG files in to GIF file . I want to make something like that . Any idea??? Thanks in advance
Thanks
Ashish Sudra
Hello ,
Finally I have done it …Thanks a lot for nice code dude !!!!!!
Happy Coding :)
Hey ,
I have try to download source code but its not available . Please give me sample code .
Thanks ,
Ashish Sudra
Hi,
I downloaded the sample project but when I run it I get this error on the console:
2010-10-22 22:01:48.492 IM_Test[80066:207] we’re using JPEG compression
Detected an attempt to call a symbol in system libraries that is not present on the iPhone:
pthread_mutexattr_destroy$UNIX2003 called from function AllocateSemaphoreInfo in image IM_Test.
Detected an attempt to call a symbol in system libraries that is not present on the iPhone:
open$UNIX2003 called from function ConfigureFileToStringInfo in image IM_Test.
Detected an attempt to call a symbol in system libraries that is not present on the iPhone:
mmap$UNIX2003 called from function MapBlob in image IM_Test.
Detected an attempt to call a symbol in system libraries that is not present on the iPhone:
munmap$UNIX2003 called from function UnmapBlob in image IM_Test.
Detected an attempt to call a symbol in system libraries that is not present on the iPhone:
close$UNIX2003 called from function ConfigureFileToStringInfo in image IM_Test.
Detected an attempt to call a symbol in system libraries that is not present on the iPhone:
strtod$UNIX2003 called from function GetMagickToken in image IM_Test.
any ideas?
thanks
the iphone library is compiled properly. so you don’t have to worry about those warnings that happen only on the simulator.
Regards,
~C
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)
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
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
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
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
Working on it, thank you for the tip.
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
I’ve heard, GraphicsMagick is a interssant altnative and faster as imageMagic, can you
perhaps help to bring GraphicsMagick run on iphone, thtanks.
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
Hi, Do you think you would be able to port Graphicsmagick (http://www.graphicsmagick.org/.) to the iphone. Maybe it will work.
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…
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?
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.
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?
I would have to look into it. Thank you for the report.
Due to think removing -lbz2 from other linker flags would help?
I just got rejected for this too. I think the problem is NSGetEnviron
:( This does not work. I am totally *******. Do you think there is a workaround to this issue.
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!
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.
Cool!
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?
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.
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
I will pull the newest ImageMagick from SVN and try a compilation. Please stay tuned!
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.
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?
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.
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.
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
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
Just played with it, very nice. fyi, the png library fails on read/write of files.
Cheers Bill
I found out the problem. Now fixed in latest version available
[...] PLEASE READ THE UPDATE Select all the .a libraries->Click [...]
[...] PLEASE READ THE UPDATE [...]
[...] LinkedIn [...]
[...] LinkedIn [...]