<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>cloud goes social &#187; coding</title>
	<atom:link href="http://www.cloudgoessocial.net/tag/coding/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.cloudgoessocial.net</link>
	<description>computer, travel, movies, music, cuisine and more</description>
	<lastBuildDate>Mon, 21 Mar 2011 21:58:30 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
		<item>
		<title>ImageMagick on iPhone (with jpeg + png)</title>
		<link>http://www.cloudgoessocial.net/2009/06/09/imagemagick-on-iphone-with-jpeg-png/</link>
		<comments>http://www.cloudgoessocial.net/2009/06/09/imagemagick-on-iphone-with-jpeg-png/#comments</comments>
		<pubDate>Tue, 09 Jun 2009 21:37:13 +0000</pubDate>
		<dc:creator>Cloud</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[tips & howtos]]></category>
		<category><![CDATA[coding]]></category>
		<category><![CDATA[imagemagick]]></category>
		<category><![CDATA[iphone]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://www.cloudgoessocial.net/?p=165</guid>
		<description><![CDATA[UPDATE: iOS4.3 and Xcode4 PLEASE READ THE UPDATE I&#8217;m working on some iPhone applications, which need some image filtering. For now, I won&#8217;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 [...]]]></description>
			<content:encoded><![CDATA[<h2>UPDATE: <a href="http://www.cloudgoessocial.net/2011/03/21/im-xcode4-ios4-3/">iOS4.3 and Xcode4</a></h2>
<h2><a href="http://www.cloudgoessocial.net/2010/02/10/imagemagick-for-iphone-via-snowleopard/">PLEASE READ THE UPDATE</a> </h2>
<p>I&#8217;m working on some iPhone applications, which need some <em>image filtering</em>. For now, I won&#8217;t say more! Stay tuned for the news when it comes out!</p>
<p>Long story short, I soon found the need (ant the challenge was a good one) to get <a href="http://www.imagemagick.org">ImageMagick</a> static libraries so that I can use it on the iPhone. Not only that, but with <a href="http://www.ijg.org/">jpeg</a> and <a href="http://www.libpng.org/pub/png/libpng.html">png</a> support. That&#8217;s what I need.</p>
<p>After a fast search through the net, I couldn&#8217;t find a single <strong>_GOOD_</strong> post on how to do that. Just some <a href="http://www.modmyi.com/forums/iphone-ipod-touch-sdk-development-discussion/30788-imagemagick-ipod-touch.html">bits</a> and <a href="http://latenitesoft.blogspot.com/2008/10/iphone-programming-tips-building-unix.html">bytes</a> &#8211; Nothing complete.</p>
<p>I soon set on a mission to get ImageMagick to work on the iPhone, as a library. And here&#8217;s<a href="http://www.cloudgoessocial.net/im_iphone/compile_im.sh"> the result</a> of my quest (around 1 day of search, trials and errors, and at last some light!)</p>
<h3>Setting</h3>
<p>I&#8217;m running MacOSX 10.5.7, with the latest <a href="http://www.macports.org/">MacPorts</a> installed. If you don&#8217;t, get it! I have many <em>ports</em> installed, the ones I <em>&#8220;think&#8221;</em> are important are:</p>
<ul>
<li>jpeg</li>
<li>libpng</li>
</ul>
<p>Also, I&#8217;m testing everything with the latest beta of the iPhoneOS 3.0 &#8211; It should be working also for 2.2.1 and the final 3.0 when it comes out.</p>
<h3>The Script</h3>
<p>I now provide you with a <a href="http://www.cloudgoessocial.net/im_iphone/compile_im.sh">shell script</a> that should do the whole trick of creating the static libraries needed in Xcode for iPhone development.</p>
<p>Just <a href="http://www.cloudgoessocial.net/im_iphone/compile_im.sh">download it</a>, give it run permission (<code>chmod +x ./compile_im.sh</code>), and launch it. It will ask for your password because it needs to copy a file that is not owned by you, the user.</p>
<p>Before complaining that it&#8217;s not working, open it, and look at the <em>required</em> directory structure for it to work.<br />
In particular you will need:</p>
<ul>
<li>a Desktop folder named cross_compile</li>
<li>ImageMagick source: <a href="ftp://ftp.imagemagick.org/pub/ImageMagick/ImageMagick.tar.gz">ImageMagick</a></li>
<li>jpeg source: <a href="http://www.cloudgoessocial.net/im_iphone/jpeg6b.zip">jpeg</a></li>
<p> &#8211; to which I&#8217;ve added the MacPorts patches</p>
<li>libpng source: <a href="http://ftp.fifi.org/ImageMagick/delegates/libpng-1.2.37.tar.gz">libpng</a></li>
<li>Untar ImageMagick source and place it into ~/Desktop/cross_compile/i_m</li>
<li>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</li>
</ul>
<p>Now you can run the script :)</p>
<h3>Result</h3>
<p>The result will be stored under: <strong>~/Desktop/tmp_target</strong>. In particular you can find all the header files needed while developing your application under: <strong>~/Desktop/tmp_target/im_libs/includes</strong> (divided by library). While all the static libraries are inside <strong>~/Desktop/tmp_target/im_libs/</strong>:</p>
<ul>
<li>libjpeg.a</li>
<li>libpng.a</li>
<li>libMagickCore.a</li>
<li>libMagickWand.a</li>
</ul>
<p>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.</p>
<h3>XCode configuration</h3>
<h2>Step 1</h2>
<p>To work with your libraries you need to put some easy adjustments to your Project in XCode. I&#8217;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:</p>
<ul>
<li>Project->Add To Project->Select all the .a libraries->Click &#8216;ADD&#8217;</li>
<li>Project->Add To Project->Select the folders inside the ~/Desktop/tmp_target/im_libs/include->Click &#8216;ADD&#8217;</li>
</ul>
<h2>Step 2</h2>
<p>Click on <strong>Project->Edit Project Settings</strong> and edit (in the <strong>Build</strong>:</p>
<ul>
<li>Other Linker Flags: -lMagickCore -lMagickWand -lz -lbz2 -ljpeg -lpng</li>
<li>Header Search Paths: $(SRCROOT) &#8211; make it Recursive</li>
<li>Library Search Paths: $(SRCROOT) &#8211; make it Recursive</li>
<li>On the lower left click on the small-wheel and select: Add User-Defined Setting</li>
<ul>
<li>Key: OTHER_CFLAGS</li>
<li>Value: -Dmacinsoth=1</li>
</ul>
</ul>
<p>This should be enough to make you start.</p>
<h3>For the Lazy</h3>
<p>If you&#8217;re lazy, don&#8217;t manage or for whatever other reason you can just download the whole <a href="http://www.cloudgoessocial.net/im_iphone/ImageMagick_compiled.zip">compiled package</a></p>
<h3>Last note</h3>
<p>In case the script doesn&#8217;t work, you have questions/suggestions/support please don&#8217;t hesitate to contact me, and in case you need help with the script please send me the FULL output in a file.<br />
<code>./compile_im.sh > file_to_send.txt</code></p>
]]></content:encoded>
			<wfw:commentRss>http://www.cloudgoessocial.net/2009/06/09/imagemagick-on-iphone-with-jpeg-png/feed/</wfw:commentRss>
		<slash:comments>40</slash:comments>
		</item>
	</channel>
</rss>

