<?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>SAOB &#124; Senseless Acts of Beauty</title>
	<atom:link href="http://www.saobart.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.saobart.com</link>
	<description>The Work, Blog, and Art of Christopher Beaven</description>
	<lastBuildDate>Sat, 30 Jan 2010 07:47:31 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>What is Model-View-Controller?</title>
		<link>http://www.saobart.com/what-is-model-view-controller/</link>
		<comments>http://www.saobart.com/what-is-model-view-controller/#comments</comments>
		<pubDate>Sat, 30 Jan 2010 07:46:02 +0000</pubDate>
		<dc:creator>Gravityone</dc:creator>
				<category><![CDATA[iPhone Development]]></category>

		<guid isPermaLink="false">http://www.saobart.com/?p=464</guid>
		<description><![CDATA[At first for me this concept was a bit hard to grasp, hopefully i can break it down to basics here.
The Model-View-Controller is basically a design theory and a very logical organization of the parts or an iPhone application.
Model is basically the classes that hold your application&#8217;s data. For example if you created an application [...]]]></description>
			<content:encoded><![CDATA[<p>At first for me this concept was a bit hard to grasp, hopefully i can break it down to basics here.</p>
<p>The Model-View-Controller is basically a design theory and a very logical organization of the parts or an iPhone application.</p>
<p><strong>Model</strong> is basically the classes that hold your application&#8217;s data. For example if you created an application that when a button was pressed would take the name of that button (a string) then output that string to a label or a text field, then in this instance the Model object would be the string itself, the actual data that was used and transferred. This is a very loose example actually but, its simplicity I think makes the Model object more understandable. Most application that use a Model object will be storing or preserving data like when using Core Data classes.<span id="more-464"></span></p>
<p><strong>View</strong> is fairly easy, if you can see it then its place in the MVC theory is <strong>View</strong>.  Although in some application there is a necessity for View objects to be hidden or invisible, these are still considered to be View objects. A view object can be windows, buttons, labels, etc&#8230;</p>
<p><strong>Controller</strong> is the mediator between the Model and View. A controller object interprets user actions made in view objects and communicates new or changed data to the model layer. When model objects change, a controller object communicates that new model data to the view objects so that they can display it. Simply, the Controller object looks at changes from either the Model or View and Tell them how to behave.</p>
<p><a href="http://saob-wp-plugin.s3.amazonaws.com/wp-content/uploads/2010/01/model_view_controller.jpg"><img class="aligncenter size-full wp-image-465" title="model_view_controller" src="http://saob-wp-plugin.s3.amazonaws.com/wp-content/uploads/2010/01/model_view_controller.jpg" alt="" width="440" height="125" /></a></p>
<p>The main reason for MVC theory is very similar to Object Oriented theory, where any object that is written should be easily identifiable as belonging to one of these three categories and no functionality within that object could be classified as belonging to any of the other two categories. Its all about abstraction and portability! An object that implements a button (View) should contain code that processes data (Controller) when it is tapped.  A class that implements a button can be used in any application but, a class that implements a button that processes a specific action or calculation can only be used in that one particular application.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.saobart.com/what-is-model-view-controller/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>What are Actions?</title>
		<link>http://www.saobart.com/what-are-actions/</link>
		<comments>http://www.saobart.com/what-are-actions/#comments</comments>
		<pubDate>Sat, 30 Jan 2010 07:01:15 +0000</pubDate>
		<dc:creator>Gravityone</dc:creator>
				<category><![CDATA[iPhone Development]]></category>

		<guid isPermaLink="false">http://www.saobart.com/?p=461</guid>
		<description><![CDATA[Actions are methods that are part of your controller class and are declared with a special keyword, IBAction.  This keyword tells Interface Builder that this is an action and can be triggered by a control.  In short if you want to have interface objects in the nib (like buttons) trigger methods in the controller class [...]]]></description>
			<content:encoded><![CDATA[<p>Actions are methods that are part of your controller class and are declared with a special keyword, <strong>IBAction</strong>.  This keyword tells Interface Builder that this is an action and can be triggered by a control.  In short if you want to have interface objects in the nib (like buttons) trigger methods in the controller class then you would use special methods called Actions.<span id="more-461"></span></p>
<p>Example declaration of an action method:</p>
<p><code>- (IBAction)doSomething:(id)sender;</code></p>
<ul>
<li>-(IBAction) = the return type</li>
<li>doSomething: = name of the action</li>
<li>(id) = argument</li>
<li>sender; = argument name</li>
</ul>
<p>The name of the action can be anything you want but must have a return type of <strong>IBAction</strong>, which is the same as declaring a return type of -(void).  It just says that action methods do not return a value.</p>
<p>Usually an action method will take one argument and is typically defined as id and given a name of sender.  (id)sender; is not always necessary when declaring an action method but is typically used all the time.  The purpose of (id)sender; is to contain a reference to the control that has triggered the action method.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.saobart.com/what-are-actions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>What are Outlets?</title>
		<link>http://www.saobart.com/what-are-outlets/</link>
		<comments>http://www.saobart.com/what-are-outlets/#comments</comments>
		<pubDate>Fri, 29 Jan 2010 02:49:17 +0000</pubDate>
		<dc:creator>Gravityone</dc:creator>
				<category><![CDATA[iPhone Development]]></category>
		<category><![CDATA[basics]]></category>
		<category><![CDATA[iPhone]]></category>

		<guid isPermaLink="false">http://www.saobart.com/?p=446</guid>
		<description><![CDATA[When building an iPhone app there comes a need for the code you write to interact with the elements you create in Interface Builder, this is called an Outlet.
The Outlet is and instance variable, and our controller class can refer to objects in the nib by using Outlets.  Outlets are used to effect objects in [...]]]></description>
			<content:encoded><![CDATA[<p>When building an iPhone app there comes a need for the code you write to interact with the elements you create in Interface Builder, this is called an Outlet.</p>
<p>The Outlet is and instance variable, and our controller class can refer to objects in the nib by using Outlets.  Outlets are used to effect objects in your nib such as text labels, buttons and so on.  By declaring an outlet and connecting that outlet to an object in the nib, you could use the outlet from within your code to change any object in your nib.<span id="more-446"></span></p>
<p>The Outlet is declared using (IBoutlet)</p>
<p>Example:</p>
<pre>@property (nonatomic, retain) <strong>IBOutlet</strong> UILabel *statusText;</pre>
<p>The IBOutlet keyword is defined like this:</p>
<p>#ifndef IBOutlet<br />
#define IBOutlet<br />
#endif</p>
<p><strong>IBOutlet</strong> does nothing as far as the compiler is concerned. Its purpose is to act as an indicator or hint to tell Interface Builder that this is an instance variable that were going to use to connect to an object in the nib. At any time if you want an instance variable to connect to an object in the nib then it must be preceded by the <strong>IBOutlet</strong> keyword.</p>
<p>Connections made from your code to the nib must use these instance variables.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.saobart.com/what-are-outlets/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Jquery and WordPress, the 6 Million Dollar upgrade</title>
		<link>http://www.saobart.com/jquery-and-wordpress-the-6-million-dollar-upgrade/</link>
		<comments>http://www.saobart.com/jquery-and-wordpress-the-6-million-dollar-upgrade/#comments</comments>
		<pubDate>Sat, 26 Sep 2009 21:35:51 +0000</pubDate>
		<dc:creator>Gravityone</dc:creator>
				<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://www.saobart.com/?p=384</guid>
		<description><![CDATA[The combination of WordPress and Jquery fits together just like Steve Austin and the 6 Million Dollar Man. Imagine your website as the meaty parts of Steve Austin that didn&#8217;t get turned into hamburger after his horrendous crash, and Jquery as the bionic upgrades stitched to his body by the OSI. Your blog may look [...]]]></description>
			<content:encoded><![CDATA[<p>The combination of WordPress and <a title="The super awesome Jquery library" href="http://jquery.com/" target="_blank">Jquery</a> fits together just like Steve Austin and the <a title="Wiki on the 6 Million Dollar Man" href="http://en.wikipedia.org/wiki/The_Six_Million_Dollar_Man" target="_blank">6 Million Dollar Man</a>. Imagine your website as the meaty parts of Steve Austin that didn&#8217;t get turned into hamburger after his horrendous crash, and Jquery as the bionic upgrades stitched to his body by the OSI. Your blog may look great and get the ladies like Lee Majors but, what really makes the chicks drool are the bionic enhancements.</p>
<p><span id="more-384"></span></p>
<p>I wonder where Google will index that last statement..?</p>
<p>Anyway, If I was making a 6 million dollar man I would really make sure that I stitched the bionic parts on correctly to avoid any conflicts with current body structure. The same is true with Jquery and Wordpress. You don&#8217;t want your awesome bionic enhancements to fail after uploading the latest super awesome plugin that uses <a title="This Js library rocks" href="http://mootools.net/" target="_blank">MooTools</a> or <a title="The prototype library" href="http://www.prototypejs.org/" target="_blank">Prototype</a>. The main reason why Jquery would conflict with other libraries like Prototype is the &#8220;$&#8221;, which is used to replace getElementById(), Prototype uses the same symbol but in different ways, Its as if Jquery and Prototype are fighting for control over that id. Or, comparatively its like the 6 Million Dollar Man battling it out with the 6 Million Dollar woman. The resulting barrage of bell-bottoms, hairspray and bionic sound effects may just rip your face off!</p>
<p>None of us want to see that happen so read on.</p>
<h3>Jquery loaded correctly</h3>
<p>After reading several posts on the subject, listed at end of post,  I came up with the ultimate way of calling Jquery into WordPress. Here is what the following code will do for you.</p>
<ul>
<li>Deregister the local copy of Jquery used by wordpress</li>
<li>Call Jquery hosted from Google</li>
<li>Register Jquery from Google and place it in the footer</li>
<li>Register your other external js files and place them after Jquery</li>
</ul>
<p>[php]<br />
&lt;?php<br />
// Footer scripts<br />
function jquery_init() {<br />
	if (!is_admin()) {//load scripts for non admin pages<br />
		wp_deregister_script(&#8216;jquery&#8217;);//deregister current jquery<br />
		wp_register_script(&#8216;jquery&#8217;, &#8216;http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js&#8217;, false, &#8216;1.3.2&#8242;, true);//load jquery from google api, and place in footer<br />
		wp_enqueue_script(&#8216;jquery&#8217;);</p>
<p>		// load a additional js files<br />
		wp_enqueue_script(&#8216;my_script&#8217;, get_bloginfo(&#8216;template_url&#8217;) . &#8216;/js/my-script.js&#8217;, array(&#8216;jquery&#8217;), &#8216;1.0&#8242;, true);<br />
		wp_enqueue_script(&#8216;my_script2&#8242;, get_bloginfo(&#8216;template_url&#8217;) . &#8216;/js/my-script2.js&#8217;, array(&#8216;jquery&#8217;), &#8216;1.0&#8242;, true);<br />
	}elseif (is_admin()){//load scripts for admin page<br />
		wp_enqueue_script(&#8216;my_admin_script&#8217;, get_bloginfo(&#8216;template_url&#8217;) . &#8216;/js/my-admin-script.js&#8217;, array(&#8216;jquery&#8217;), &#8216;1.0&#8242;, true);<br />
		wp_enqueue_script(&#8216;my_admin_script2&#8242;, get_bloginfo(&#8216;template_url&#8217;) . &#8216;/js/my-admin-script2.js&#8217;, array(&#8216;jquery&#8217;), &#8216;1.0&#8242;, true);<br />
	}<br />
}<br />
add_action(&#8216;init&#8217;, &#8216;jquery_init&#8217;);<br />
// END :Footer scripts<br />
?&gt;<br />
[/php]</p>
<div class="highlight">Please Note: I do not recommend using two javascript libraries on one page. Its better, faster, and stronger to just stick with one library.</div>
<p>Ok, there area  couple of things I want to go over here.</p>
<ol>
<li><strong>You should always always put all of your scripts in the footer.</strong> Why? Because, when a web page loads the markup it loads from top to bottom. So, if you have several scripts at the top of the page your users have to wait for all that stuff to load in the background before any of the lower content will load. That&#8217;s almost as unbearable as Steve Austin running in slow-mo. Also, most of your javascript is no good unless it has content to play with, so just put the scripts at the bottom of the page and it will load faster with every thing working correctly. If you don&#8217;t believe me just view the source on my website and see, all the scripts in the footer.</li>
<li><strong>Let google host it, its faster. </strong>Google provides <a title="Google ajax hosting" href="http://code.google.com/apis/ajaxlibs/documentation/" target="_blank">AJAX Libraries API</a> hosting for most well known javascript libraries and we can definitely take advantage of this CDN.</li>
<li><strong>Have WordPress place your external scripts according to their javascript library</strong>. The <a title="Wordpress speck on wp_engueue_script" href="http://codex.wordpress.org/Function_Reference/wp_enqueue_script" target="_blank">wp_engueue_ascript()</a> function allows for an argument called <strong>$deps, </strong>which you can use to attach any other external scripts to its library and then WordPress will place it on the page accordingly.</li>
</ol>
<h3>Loading inline scripts</h3>
<p>One of my scripts needs to be loaded from another external file and it needs to go below the previous scripts on the page. Here is how you can do that.</p>
<p>[php]<br />
&lt;?php // Banner Footer scripts<br />
function alt_footer_files(){ ?&gt;<br />
    &lt;script type=&quot;text/javascript&quot;&gt;<br />
    jQuery(document).ready(function($) {<br />
		//my javascript here using $<br />
	});<br />
	&lt;/script&gt;</p>
<p>&lt;?php }	}<br />
add_action(&#8216;wp_footer&#8217;, &#8216;alt_footer_files&#8217;, 10);<br />
// END :Footer scripts<br />
?&gt;<br />
[/php]</p>
<p>Here I use add_action() to load scripts into the wordpress footer at position 10, which will be below all of the previous script links. You should also notice that I am calling Jquery using <strong>&#8220;jQuery(document).ready(function($)&#8221;</strong>. This replaces the normal &#8220;$(document).ready(function()&#8221; and allows jquery to function in a no conflict mode but still being able to use the $ in your markup.</p>
<h3>Awesome posts about the subject</h3>
<ul>
<li>Eric Martin, most of the information comes from <a title="EricMartin.com" href="http://www.ericmmartin.com/5-tips-for-using-jquery-with-wordpress/" target="_blank">this</a> great post.</li>
<li>The Wordpress Codex on <a title="wordpress codex" href="http://codex.wordpress.org/Function_Reference/wp_enqueue_script" target="_blank">this subject</a>.</li>
<li>Using Jquery with other libraries, from the <a title="using jquery with other libraries" href="http://docs.jquery.com/Using_jQuery_with_Other_Libraries" target="_blank">jquery site</a>.</li>
<li>Including Jquery the right way from the <a title="very cool site" href="http://digwp.com/2009/06/including-jquery-in-wordpress-the-right-way/" target="_blank">diggwp site</a>.</li>
<li>Wow the <a href="http://www.youtube.com/watch?v=HofoK_QQxGc" target="_blank">original TV intro</a> of 6 Million Dollar man brings back memories of my childhood</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.saobart.com/jquery-and-wordpress-the-6-million-dollar-upgrade/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>ImageMagick usage and examples with PHP: #2</title>
		<link>http://www.saobart.com/imagemagick-usage-and-examples-with-php-2/</link>
		<comments>http://www.saobart.com/imagemagick-usage-and-examples-with-php-2/#comments</comments>
		<pubDate>Sun, 13 Sep 2009 22:20:27 +0000</pubDate>
		<dc:creator>Gravityone</dc:creator>
				<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://www.saobart.com/?p=358</guid>
		<description><![CDATA[Continuing my series on working with ImageMagic here is an example on how to annotate an image with text and using fonts already on the server. There are so many ImageMagick annotate options that I can&#8217;t list them all here!

Annotate and image with ImageMagic and PHP
How its done
Here is the code used for the above [...]]]></description>
			<content:encoded><![CDATA[<p>Continuing my series on working with ImageMagic here is an example on how to annotate an image with text and using fonts already on the server. There are so many ImageMagick annotate options that I can&#8217;t list them all here!</p>
<p><span id="more-358"></span></p>
<h3>Annotate and image with ImageMagic and PHP</h3>
<div class="wp-caption alignleft" style="width: 210px"><img title="ImageMagick test image" src="/wp-content/themes/saob/magick/saob.jpg" alt="Original test saob image" width="200" height="200" /><p class="wp-caption-text">Original test image</p></div>
<div class="wp-caption alignleft" style="width: 210px"><img title="ImageMagick test image" src="/wp-content/themes/saob/magick/annotate.php" alt="Original test saob image" width="200" height="200" /><p class="wp-caption-text">Simple annotate</p></div>
<h3 style="clear:both;">How its done</h3>
<p>Here is the code used for the above image annotation.</p>
<p>[php]<br />
&lt;?php<br />
header( &#8216;Content-Type: image/jpg&#8217; );<br />
system(&quot;convert saob.jpg -font AvantGarde-Book -fill black -pointsize 20 -gravity center -annotate +0+0 &#8216;Senseless Acts of Beauty&#8217; jpg:-&quot;);<br />
?&gt;<br />
[/php]</p>
<h3>Code Breakdown</h3>
<ul>
<li><span style="color: #000000;">saob.jpg</span> (The location of the original test image)</li>
<li><span style="color: #000000;">-font AvantGarde-Book</span> (The font command sets the font family, I chose AvantGarde-Book which is already used by my server)</li>
<li><span style="color: #000000;">-fill black</span> (fill is the command that sets the fill for the font, I set the color to black)</li>
<li><span style="color: #000000;">-pointsize 20</span> (set the size of the font to 20)</li>
<li><span style="color: #000000;">-gravity center</span> (tells the font to be placed in absolute center of the image, vertically and horizontally)</li>
<li><span style="color: #000000;">-annotate +0+0 &#8216;Senseless Acts of Beauty&#8217;</span> (command to apply text to image, you can use the +0+0 as x and y coordinates)</li>
<li><span style="color: #000000;">jpg:-</span> (output a jpg file)</li>
</ul>
<p>See reference and tons of example <a title="reference to imagemagick" href="http://www.imagemagick.org/Usage/text/#annotate" target="_blank">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.saobart.com/imagemagick-usage-and-examples-with-php-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ImageMagick usage and examples with PHP: #1</title>
		<link>http://www.saobart.com/imagemagick-usage-and-examples-with-php-1/</link>
		<comments>http://www.saobart.com/imagemagick-usage-and-examples-with-php-1/#comments</comments>
		<pubDate>Sun, 13 Sep 2009 21:27:03 +0000</pubDate>
		<dc:creator>Gravityone</dc:creator>
				<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://www.saobart.com/?p=331</guid>
		<description><![CDATA[Several times in my career i have played around with ImageMagick and have always found the documentation of its usage with PHP to be severely lacking.  Or in most cases though the problem originates with the server.
Why can&#8217;t I get ImageMagick to work?
Either its not installed on your shared host, or its installed and crippled [...]]]></description>
			<content:encoded><![CDATA[<p>Several times in my career i have played around with ImageMagick and have always found the documentation of its usage with PHP to be severely lacking.  Or in most cases though the problem originates with the server.<span id="more-331"></span></p>
<h3>Why can&#8217;t I get ImageMagick to work?</h3>
<p>Either its not installed on your shared host, or its installed and crippled so you can&#8217;t use php functions like &#8220;exec(), or system()&#8221;. Its good to mention that if you are running into this problem you may want to check out some API&#8217;s that hook into ImageMagick like <a title="Imagick api for php, working with imagemagick" href="http://us.php.net/imagick" target="_blank">Imagick</a> for PHP, or <a title="MagickWand and api for imagemagick" href="http://www.imagemagick.org/script/magick-wand.php" target="_blank">MagickWand</a>.  Both are very good API&#8217;s but, you will find less examples working with them then the original <a title="ImageMagick.org all the usage you will need to learn imagemagick" href="http://www.imagemagick.org/Usage/" target="_blank">ImageMagick documentation</a>.</p>
<p>Now, before we get into an example, I would like to point out that most of the examples around the net are using personal installs of ImageMagick, or from a person that has root access to a dedicated server. This allows these code guru&#8217;s to edit the Apache server to accept functions that most shared hosting has turned off.</p>
<p>The first time I tried ImageMagick I installed a virtual machine on my computer running Linux(Umbuntu) and I used and SSH connection to run bash commands on the local server that had the perfect install of ImageMagick that let me do whatever I wanted. Here the bad thing about that, It took FOREVER! And not only was I unsure about the security of my server but I also didn&#8217;t know how it would effect and actual server CPU, of even if all my code would work on the server that I moved it to.</p>
<p>So, the perfect solution came to me the other day when I ran phpinfo() on my current host <a title="In my opinion the best hosting out there, HostGator" href="http://www.hostgator.com/" target="_blank">HostGator</a>, and found that ImageMagick was installed. Within minutes I was running ImageMagick commands on my development domain, AWESOME!</p>
<p>So, Long story short, don&#8217;t try installing ImageMagick unless you have all the time in the world and your an Apache guru, just use <a title="HostGator has imagemagick installed automatically" href="http://www.hostgator.com/" target="_blank">HostGator</a>!</p>
<h3>Is ImageMagick installed on my current host?</h3>
<p>The first thing you want to do before you begin working with ImageMagick is make sure that its installed on your host&#8217;s server, along with what font&#8217;s you can use and what convert commands are installed on the server.</p>
<p><span style="font-size: small;"><span style="color: #993300;">note: The following code will assume that you have FTP access to your server and have basic knowledge of PHP.</span></span></p>
<p>Just create a page called magicktest.php and paste in the following code</p>
<p>[php]<br />
&lt;?php<br />
  header(&#8216;Content-Type: text/plain&#8217;);<br />
  system(&quot;exec 2&gt;&amp;1; type convert&quot;);<br />
  system(&quot;exec 2&gt;&amp;1; locate */convert&quot;);<br />
  system(&quot;exec 2&gt;&amp;1; convert -version&quot;);<br />
  system(&quot;exec 2&gt;&amp;1; convert -list type&quot;); // &lt;&lt; before IM v6.3.5-7<br />
  system(&quot;exec 2&gt;&amp;1; convert -list font&quot;);<br />
?&gt;<br />
[/php]</p>
<p>This will run a few of commands on your server to see what is present.</p>
<ul>
<li>header (tells the browser what type of content will be displayed, nothing before this or you will get a header error)</li>
<li><code>type</code> (Tells you if <code>convert</code> is available on the command PATH and where it is)</li>
<li><code>locate</code> (finds all convert commands that exist on the server, including ones that are NOT ImageMagick commands)</li>
<li><code>convert -version</code> (prints the version number of convert)</li>
<li><code>convert -list type</code> (lists fonts for an older version of ImageMagick)</li>
<li><code>convert -list font</code> (lists the fonts that ImageMagick has access to)</li>
</ul>
<p>If all you see ar errors, then &#8220;<code>convert</code>&#8221; is not on the command line path,  and your ISP provider did not initialize the web server PATH properly to include it.   If this is the case you will need to find out exactly where it is located and use something like this for you PHP scripts, which makes your script less portable.   For example suppose the &#8220;<code>convert</code>&#8221; command is in &#8220;<code>/opt/php5extras/ImageMagick/bin</code>&#8220;, then you can set that in a variable at the top (for quick changes for different ISP hosts), and directly specify its location. For more explanation on this see the master of all things ImageMagick <a href="http://www.cit.gu.edu.au/%7Eanthony/anthony.html" target="_blank">Anthony Thyssen</a> and <a title="Api ImageMagick examples with php" href="http://www.imagemagick.org/Usage/api/" target="_blank">this post</a>.</p>
<p>Now once you have all that information save it somewhere, you will always need to reference the convert path or fonts installed.</p>
<h3>Can I use exec() to run commands on my host?</h3>
<p>An easy way to test and see if exec() is available and working on your server is to run the following code provided by php.net.</p>
<p>[php]<br />
// outputs the username that owns the running php/httpd process<br />
// (on a system with the &quot;whoami&quot; executable in the path)<br />
echo exec(&quot;whoami&quot;);<br />
?&gt;<br />
[/php]</p>
<p>If you see your user name then its all working fine. If not, you may want to try system(), and/or passthru(). Actually in most cases if your code doesn&#8217;t work try system() or passthru(), I will be using a combination of the three in my post examples.</p>
<h3>Difference between ImageMagick images and normal image files</h3>
<p>The basic idea of ImageMagick is that you want the server to adjust your images just like you could do in photoshop. But, you won&#8217;t be referencing your images the same as <code> &lt;img src="myimage.jpg" /&gt;</code>. With photoshop you edit and image then save it as a file then reference the file, src=&#8221;myfile.jpg&#8221;.  With ImageMagick, you ask the server to do the image edits and then it returns code that builds the image in the browser, this is the main reason why we need header() at the top of your php file. If you didn&#8217;t specify headers before your code you would get a bunch of crazy characters all over the page.</p>
<p>Here is how its done. You create a file called rotateImage.php, then you reference it just like and image, &lt;img src=&#8221;rotateImage.php&#8221; /&gt;. So you pull the php file in through the image tag and it displays your image as if the php file WAS an image file. Very cool right!!</p>
<h3>Examples!! Rotate</h3>
<div class="wp-caption alignleft" style="width: 210px"><img title="ImageMagick test image" src="/wp-content/themes/saob/magick/saob.jpg" alt="Original test saob image" width="200" height="200" /><p class="wp-caption-text">Original test image</p></div>
<div class="wp-caption alignleft" style="width: 292px"><img title="ImageMagick rotate with php" src="/wp-content/themes/saob/magick/rotate.php" alt="ImageMagick rotate with php" width="282" height="282" /><p class="wp-caption-text">Rotate image 45 degrees</p></div>
<p style="clear:both;">The magick! Rotate and image with just two lines of code!</p>
<p>[php]<br />
&lt;?php<br />
header( &#8216;Content-Type: image/jpg&#8217; );<br />
system(&quot;convert saob.jpg -rotate 45 jpg:-&quot;);<br />
?&gt;<br />
[/php]</p>
<h3>Example:  Annotate, negate, resize&#8230;</h3>
<div class="wp-caption alignnone" style="width: 410px"><img title="ImageMagick annotate with php" src="/wp-content/themes/saob/magick/negateAnnotate.php" alt="ImageMagick annotate with php" width="400" height="400" /><p class="wp-caption-text">Several commands in one!</p></div>
<p style="clear:both;">The magick! Annotate, Negate, Resize, swap, composite</p>
<p>[php]<br />
&lt;?php<br />
header( &#8216;Content-Type: image/jpg&#8217; );<br />
$color=&quot;white&quot;;<br />
  $image=&quot;saob.jpg&quot;;<br />
  $scale=&quot;200%&quot;;<br />
  $size=&quot;140&#215;96&quot;;<br />
  $string=&quot;Senseless Acts of Beauty&quot;;<br />
  passthru(&quot;convert -background none -fill &#8216;$color&#8217; -gravity center&quot; .<br />
            &quot; -font AvantGarde-Book -size &#8216;$size&#8217; caption:&#8217;$string&#8217;&quot; .<br />
            &quot; \\( &#8216;$image&#8217; -negate -resize &#8216;$scale&#8217; \\) -swap -2,-1 -composite&quot; .<br />
            &quot; jpg:-&quot; );<br />
?&gt;<br />
[/php]</p>
<p>Its almost limitless of what you can do with ImageMagick so, that being said, I plan on making a bunch of short posts just showing examples of ImageMagick usage along with the code on how you can do the same. As always if you have any questions just post a comment. THANKS!!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.saobart.com/imagemagick-usage-and-examples-with-php-1/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Speed up Wordpress plugins</title>
		<link>http://www.saobart.com/speed-up-wordpress-plugins/</link>
		<comments>http://www.saobart.com/speed-up-wordpress-plugins/#comments</comments>
		<pubDate>Sat, 29 Aug 2009 04:55:23 +0000</pubDate>
		<dc:creator>Gravityone</dc:creator>
				<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://www.saobart.com/?p=165</guid>
		<description><![CDATA[One of the biggest problems with a Wordpress site is optimizing its speed.  If you use the popular plug-in for FireFox Yslow, or Google&#8217;s page speed they will always tell you to move the JavaScript to the footer in order to make your page load faster. Or, you have too many style sheets and scripts [...]]]></description>
			<content:encoded><![CDATA[<p>One of the biggest problems with a Wordpress site is optimizing its speed.  If you use the popular plug-in for FireFox <a title="Yslow plugin download page" href="https://addons.mozilla.org/en-US/firefox/addon/5369" target="_blank">Yslow</a>, or<a title="Page speed download page" href="http://code.google.com/speed/page-speed/download.html" target="_blank"> Google&#8217;s page speed</a> they will always tell you to move the JavaScript to the footer in order to make your page load faster.<span id="more-165"></span> Or, you have too many style sheets and scripts on one page and it wants you to combine them. I have a pretty simple solutions that you can use to tell any plug-in your using to only be displayed on the page it is being used AND put the JavaScript in the footer.</p>
<h3>Optimize: Contact Form 7</h3>
<p>One of the top Wordpress plug-ins to download is <a title="Contact Form 7 Plugin Home page" href="http://ideasilo.wordpress.com/2007/04/30/contact-form-7/" target="_blank">Contact Form 7</a> (best form plug-in in my opinion). One great thing about this plug-in is that it automatically moves its JavaScript to the footer of your site. But, the JavaScript is still used on every page as well as the style sheets. Now, if your like me you just need these styles and scripts to run on one page, not throughout the entire site. Here is how to fix this.</p>
<p><span style="color: #993300;"><em>First things first, make sure you set up Contact Form 7 and its working 100% correctly out of the box before you begin editing its current functionality.</em></span></p>
<h3>Step 1</h3>
<p>Open the main PHP file for the plug-in, in this case its <em>wp-contact-form-7.php </em>located in the plug-in&#8217;s root folder. What I usually do is search for any reference to the scripts or styles that I want to move. If you do a search for <em>.js</em> you will come to several lines of code seen in the image below.<br />
<a href="http://www.saobart.com/wp-content/uploads/2009/08/cf7php.jpg"><img class="alignnone size-full wp-image-167" title="Contact Form 7 php code, to find the function we need" src="http://www.saobart.com/wp-content/uploads/2009/08/cf7php.jpg" alt="Contact Form 7 php code, to find the function we need" width="660" height="212" /></a></p>
<p>As you can see above <em>wp_enqueue_script()</em> is being used to queue the JavaScript into the Wordpress loop. The most important part of this function is the name of the script that is being queued, &#8220;contact-form-7&#8243;. Make note of this.</p>
<h3>Step 2</h3>
<p>Now one of the most important parts of moving this code around, so we can speed up our page, is to do it without editing any of the original plug-in files. And you ask &#8220;WHY?&#8221;.</p>
<p>Well, lets say you do all kinds of edits to this plug-in&#8217;s php files and you get your page to humm like a top and your all super happy eating ice-cream and smiling. Then the next time you open up your Wordpress dashboard you see a warning to update your plug-in because it has a security bug or something, put down the ice-cream, update your plug-in and watch all your awesome work go away&#8230;</p>
<p>Yeah sucks doesn&#8217;t it?</p>
<p>So, how can you edit what a plug-in does without touching it? MAGIC!! No, just kidding, all you need is your <em>functions.php</em> file in your child theme, or if you don&#8217;t have one just create it and add the code below.</p>
<p>[php]<br />
&lt;?php<br />
function my_deregister_javascript() {<br />
 if (!is_page(&#8216;contact&#8217;)){<br />
 wp_deregister_script( &#8216;contact-form-7&#8242; );<br />
 }<br />
}<br />
add_action( &#8216;wp_print_scripts&#8217;, &#8216;my_deregister_javascript&#8217;, 100 );<br />
?&gt;<br />
[/php]</p>
<h3>Step 3</h3>
<p><span style="color: #993300;">Now you can paste that code in your functions.php file and wonder why its not working or you can continue reading.</span> Here is what this function is doing.</p>
<pre><strong><span style="color: #333333;">function my_deregister_javascript() {</span></strong></pre>
<p style="padding-left: 30px;">The above line begins your function and names it, you can make it say whatever you want, as long as it is unique, but I like <em>my_deregister_javascript().</em></p>
<pre><strong><span style="color: #333333;">if (!is_page('contact')){</span></strong></pre>
<p style="padding-left: 30px;">This is very important! The above line looks for the pages that ARE NOT! named &#8220;contact&#8221;. So, if you have Contact Form 7 on a page called &#8220;snuffalupagus&#8221; then this line should read,</p>
<p style="padding-left: 30px;">if (!is_page( &#8217;snuffalupagus&#8217; )){</p>
<p style="padding-left: 30px;">If you have multiple forms on different pages then it would change to,</p>
<p style="padding-left: 30px;">if(!is_page(array(&#8216;page1&#8242;,&#8217;page2&#8242;,&#8217;page3&#8242;)){</p>
<pre><strong><span style="color: #333333;">wp_deregister_script( 'contact-form-7' );</span></strong></pre>
<p style="padding-left: 30px;">The above line is the action line. It de-registers the script from the loop, kills it, stops it from running, EXTERMINATE! Sorry, was just watching some Doctor Who&#8230;.</p>
<pre><strong><span style="color: #333333;">add_action( 'wp_print_scripts', 'my_deregister_javascript', 100 );</span></strong></pre>
<p style="padding-left: 30px;">The above last line just ads our new function into the queue at position 100.</p>
<h3>Step 4</h3>
<p>Check to make sure that the scripts used for Contact Form 7 are no longer in the footer for every page except for the page/pages where your forms are being used, and pick up your ice-cream again.</p>
<h3>Step 5</h3>
<p>Paste the code below into your <em>functions.php</em> file. This will remove the Contact Form 7 style sheets from the head of all your pages except for the page named &#8220;contact&#8221;. Essentially, this is the same code as above, and you should adjust accordingly.</p>
<p>[php]<br />
&lt;?php<br />
function remove_contact_style(){<br />
 if (!is_page(&#8216;contact&#8217;)){<br />
 remove_action( &#8216;wp_head&#8217;, &#8216;wpcf7_wp_head&#8217; );<br />
 }<br />
}<br />
add_action(&#8216;wp_head&#8217;, &#8216;remove_contact_style&#8217;, 9);<br />
?&gt;<br />
[/php]</p>
<h3>Your Done!</h3>
<p>Hopefully that wasn&#8217;t too hard <img src='http://www.saobart.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> .</p>
<h3>Optimize: WP-Cufon</h3>
<p><a title="Wp-Cufon download page" href="http://wordpress.org/extend/plugins/wp-cufon/" target="_blank">WP-Cufon</a> is a great plug-in that i use on my site to turn all heading into a no web safe font. The JavaScript used for this plug-in is needed on every page but, using the code below you can remove the JavaScript from the head and put it in the footer where it belongs.</p>
<p>[php]<br />
&lt;?php<br />
function remove_scripts() {<br />
 remove_action(&#8216;wp_head&#8217;, &#8216;wpcufon_init&#8217;);<br />
 add_action(&#8216;wp_footer&#8217;, &#8216;wpcufon_init&#8217;, 9);<br />
}<br />
add_action(&#8216;init&#8217;, &#8216;remove_scripts&#8217;);<br />
?&gt;<br />
[/php]</p>
<p>That&#8217;s all for now, more to come later&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.saobart.com/speed-up-wordpress-plugins/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Script to help diagnose Wordpress speed</title>
		<link>http://www.saobart.com/script-to-help-diagnose-wordpress-speed/</link>
		<comments>http://www.saobart.com/script-to-help-diagnose-wordpress-speed/#comments</comments>
		<pubDate>Thu, 13 Aug 2009 00:23:24 +0000</pubDate>
		<dc:creator>Gravityone</dc:creator>
				<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://www.saobart.com/?p=29</guid>
		<description><![CDATA[Ever wanted to know exactly how many times your browser is querying the server? Or how long it takes for you page to load? Even Yslow cannot detect these queries!

Just add the script below to your functions.php file in your Wordpress installation and the queries will appear in the bottom left or your browser as [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">Ever wanted to know exactly how many times your browser is querying the server? Or how long it takes for you page to load? Even Yslow cannot detect these queries!</p>
<p><span id="more-29"></span></p>
<p style="text-align: justify;">Just add the script below to your functions.php file in your Wordpress installation and the queries will appear in the bottom left or your browser as long as your logged in (<em>and only if you logged in</em>).</p>
<p>[php]<br />
&lt;?<br />
php if (is_user_logged_in()) {<br />
?&gt;<br />
   &lt;div id=&quot;speed-test&quot; style=&quot;padding:10px;background:#F66;color:#fff;font-weight:bold; position:fixed;bottom:0;&quot;&gt;<br />
      &lt;?php echo get_num_queries(); ?&gt; queries in &lt;?php timer_stop(1); ?&gt; seconds.<br />
   &lt;/div&gt;<br />
&lt;?php } ?&gt;<br />
[/php]</p>
<p style="text-align: justify;">If you like this script or need help installing it please leave a comment.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.saobart.com/script-to-help-diagnose-wordpress-speed/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Speeding up wordpress with .htaccess and Wp Super Cache</title>
		<link>http://www.saobart.com/speeding-up-wordpress-with-htaccess-and-wp-super-cache/</link>
		<comments>http://www.saobart.com/speeding-up-wordpress-with-htaccess-and-wp-super-cache/#comments</comments>
		<pubDate>Thu, 13 Aug 2009 00:12:14 +0000</pubDate>
		<dc:creator>Gravityone</dc:creator>
				<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://www.saobart.com/?p=12</guid>
		<description><![CDATA[One of the problems that it seems I am always faced with when building a Wordpress site is speed.  Previously all my speed problems were directly related to my old host (Network Solutions), the latency for their shared hosting was atrocious.

So after building my site locally and testing it on a development domain I consistently [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">One of the problems that it seems I am always faced with when building a Wordpress site is speed.  Previously all my speed problems were directly related to my old host (Network Solutions), the latency for their shared hosting was atrocious.</p>
<p><span id="more-12"></span></p>
<p style="text-align: justify;">So after building my site locally and testing it on a development domain I consistently find that multiple plugins, tons of server queries, and large content size will slow my site to a crawl, and as we all know, load time is disastrous to traffic. Hell, I wouldn&#8217;t even visit my old site because it took way too long to load.</p>
<p style="text-align: justify;">Now, there are a ton of tutorials online that talk about different ways to speed up your Wordpress site but as I like to keep my posts short and sweet I will just focus on two. Using .htaccess to add expires headers to content, and using Wp Super Cache to cache up pages.</p>
<p style="text-align: justify;">Just in case though here is a list of ways that you can speed up your site, you will have to search for tutorials on these, or maybe I will cover some info on them later.</p>
<h2>Short list of Wordpress speed tips</h2>
<ul>
<li>Use Css sprites for images (cuts down on http requests)</li>
<li>Use a CDN (content delivery network) like Amazon S3</li>
<li>Add expires headers to page content</li>
<li>Gzip components (Just found out that Host Gator only does Gzip on dedicated servers&#8230;crap!)</li>
<li>Move all javascript to the footer (wow this helps out a ton, unfortunately most plugins don&#8217;t do it.)</li>
<li>Minify Javascript and Css (if you want to reduce the size of your css i love <a title="Best css optimizer tool out there, to help minify your css" href="http://floele.flyspray.org/csstidy/css_optimiser.php" target="_blank">this</a> tool)</li>
<li>Delete any Plugins your not using</li>
<li>Replace the header.php file with static elements removing PHP functions (controversial see <a title="Why replacing functions in wordpress may be a bad idea" href="http://dan-cole.com/a-bad-tip-for-speeding-up-your-site/" target="_blank">here</a> )</li>
<li>Optimize database with phpmyadmin (super easy to do)</li>
<li>Keep your images small or optimize them</li>
<li>Reference your script libraries, like Jquery, through google source (<a title="Information about using google to host your javascript libraries" href="http://code.google.com/apis/ajaxlibs/" target="_blank">more info</a>)</li>
</ul>
<h4 style="text-align: justify;">Super Tip</h4>
<p style="text-align: justify;">Here is a great tip. If you want to see how may queries your site is making to the server and how long it takes for you site to load just paste  my super awesome script into your functions.php file and when your logged in (and only when your logged in) you will see a count at the bottom left of your site.</p>
<p>[php]&lt;br /&gt;<br />
&lt;?php&lt;br /&gt;<br />
if (is_user_logged_in()) {&lt;br /&gt;<br />
?&gt;&lt;br /&gt;<br />
   &lt;div id=&amp;quot;speed-test&amp;quot; style=&amp;quot;padding:10px;background:#F66;color:#fff;font-weight:bold; position:fixed;bottom:0;&amp;quot;&gt;&lt;br /&gt;<br />
      &lt;?php echo get_num_queries(); ?&gt; queries in &lt;?php timer_stop(1); ?&gt; seconds.&lt;br /&gt;<br />
   &lt;/div&gt;&lt;br /&gt;<br />
&lt;?php } ?&gt;[/php]</p>
<h2>Now on to the .htaccess and Wp Super Cache</h2>
<p style="text-align: justify;">So i did a bunch of research on how to insert expires headers in side of you .htaccess file and the only thing that i found that would work with my host and on word press was the following.</p>
<p>[text]&lt;br /&gt;<br />
# Expire images header&lt;br /&gt;<br />
ExpiresActive On&lt;br /&gt;<br />
ExpiresDefault A0&lt;br /&gt;<br />
ExpiresByType image/gif A2592000&lt;br /&gt;<br />
ExpiresByType image/png A2592000&lt;br /&gt;<br />
ExpiresByType image/jpg A2592000&lt;br /&gt;<br />
ExpiresByType image/jpeg A2592000&lt;br /&gt;<br />
ExpiresByType image/ico A2592000&lt;br /&gt;<br />
ExpiresByType text/css A2592000&lt;br /&gt;<br />
ExpiresByType text/javascript A2592000[/text]</p>
<p style="text-align: justify;">Just upload the .htaccess file to the website directory where Wordpress is installed and you should see that items now have expires headers by using a firefox plugin called <a title="Yslow plugin for firefox" href="https://addons.mozilla.org/en-US/firefox/addon/5369" target="_blank">Yslow</a>.</p>
<p style="text-align: justify;">That was the hard part, the easy part is just installing <a title="Wp super cache, best caching tool for Wordpress" href="http://wordpress.org/extend/plugins/wp-super-cache/" target="_blank">Wp Super Cache</a> and configuring some settings. Wp super cache will do the rest and you should see results on Yslow right away!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.saobart.com/speeding-up-wordpress-with-htaccess-and-wp-super-cache/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>New Site Re-Design!</title>
		<link>http://www.saobart.com/new-site-re-design/</link>
		<comments>http://www.saobart.com/new-site-re-design/#comments</comments>
		<pubDate>Mon, 10 Aug 2009 20:10:11 +0000</pubDate>
		<dc:creator>Gravityone</dc:creator>
				<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://www.saobart.com/?p=6</guid>
		<description><![CDATA[Ok first post for my new redesign, yes it looks really sparse and broken but, the idea here is to finish all of the more advanced features of my site while blogging about the process.  Cool right? Ok maybe not that cool, but at least you get to see exactly what is happening behind [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">Ok first post for my new redesign, yes it looks really sparse and broken but, the idea here is to finish all of the more advanced features of my site while blogging about the process.  Cool right? Ok maybe not that cool, but at least you get to see exactly what is happening behind the curtain as I build.</p>
<p><span id="more-6"></span></p>
<p style="text-align: justify;">I am sure that there will be places on my site that will looked trashed while I write the backend code but I&#8217;m fine with that.  I really feel like stripping off the exterior and showing everyone whats under the hood.  Also, I&#8217;m going to use this as a repository/tracking for my code process.  Hope you enjoy it, if you have any questions just use my contact form&#8230; er, when I build it that is, which should be soon.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.saobart.com/new-site-re-design/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
