<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>FullFatCode</title>
	<atom:link href="http://fullfatcode.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://fullfatcode.wordpress.com</link>
	<description>The code blog of web developer James Carmichael</description>
	<lastBuildDate>Thu, 27 Aug 2009 00:27:32 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='fullfatcode.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://0.gravatar.com/blavatar/a8e0c5951cac1b75613eb5e38aaaca6f?s=96&#038;d=http%3A%2F%2Fs2.wp.com%2Fi%2Fbuttonw-com.png</url>
		<title>FullFatCode</title>
		<link>http://fullfatcode.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://fullfatcode.wordpress.com/osd.xml" title="FullFatCode" />
	<atom:link rel='hub' href='http://fullfatcode.wordpress.com/?pushpress=hub'/>
		<item>
		<title>New free &#8220;Organica&#8221; HTML and CSS template</title>
		<link>http://fullfatcode.wordpress.com/2009/08/27/new-free-organica-html-and-css-template/</link>
		<comments>http://fullfatcode.wordpress.com/2009/08/27/new-free-organica-html-and-css-template/#comments</comments>
		<pubDate>Thu, 27 Aug 2009 00:27:32 +0000</pubDate>
		<dc:creator>jcarmichael</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://fullfatcode.wordpress.com/?p=73</guid>
		<description><![CDATA[Download free at: www.fullfatcode.com<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=fullfatcode.wordpress.com&amp;blog=8046360&amp;post=73&amp;subd=fullfatcode&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Download free at:</p>
<p><a href="http://www.fullfatcode.com/2009/08/27/organica-a-free-html-css-template/">www.fullfatcode.com</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/fullfatcode.wordpress.com/73/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/fullfatcode.wordpress.com/73/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/fullfatcode.wordpress.com/73/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/fullfatcode.wordpress.com/73/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/fullfatcode.wordpress.com/73/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/fullfatcode.wordpress.com/73/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/fullfatcode.wordpress.com/73/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/fullfatcode.wordpress.com/73/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/fullfatcode.wordpress.com/73/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/fullfatcode.wordpress.com/73/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/fullfatcode.wordpress.com/73/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/fullfatcode.wordpress.com/73/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/fullfatcode.wordpress.com/73/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/fullfatcode.wordpress.com/73/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=fullfatcode.wordpress.com&amp;blog=8046360&amp;post=73&amp;subd=fullfatcode&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://fullfatcode.wordpress.com/2009/08/27/new-free-organica-html-and-css-template/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/11d0d57577758724680050c2f4d0b047?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">jcarmichael</media:title>
		</media:content>
	</item>
		<item>
		<title>Jquey Uploadify &#8211; Simultaneous mulitple file uploads with JQuery</title>
		<link>http://fullfatcode.wordpress.com/2009/08/03/jquey-uploadify-simultaneous-mulitple-file-uploads-with-jquery/</link>
		<comments>http://fullfatcode.wordpress.com/2009/08/03/jquey-uploadify-simultaneous-mulitple-file-uploads-with-jquery/#comments</comments>
		<pubDate>Mon, 03 Aug 2009 17:02:22 +0000</pubDate>
		<dc:creator>jcarmichael</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[JQuery]]></category>
		<category><![CDATA[uploadify]]></category>

		<guid isPermaLink="false">http://fullfatcode.wordpress.com/?p=71</guid>
		<description><![CDATA[Check out my post with integration tips at my blog&#8217;s new permanent home: www.fullfatcode.com<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=fullfatcode.wordpress.com&amp;blog=8046360&amp;post=71&amp;subd=fullfatcode&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Check out my post with integration tips at my blog&#8217;s new permanent home:</p>
<pre><a href="http://www.fullfatcode.com/2009/08/02/jquery-multiple-file-upload/">www.fullfatcode.com</a></pre>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/fullfatcode.wordpress.com/71/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/fullfatcode.wordpress.com/71/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/fullfatcode.wordpress.com/71/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/fullfatcode.wordpress.com/71/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/fullfatcode.wordpress.com/71/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/fullfatcode.wordpress.com/71/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/fullfatcode.wordpress.com/71/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/fullfatcode.wordpress.com/71/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/fullfatcode.wordpress.com/71/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/fullfatcode.wordpress.com/71/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/fullfatcode.wordpress.com/71/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/fullfatcode.wordpress.com/71/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/fullfatcode.wordpress.com/71/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/fullfatcode.wordpress.com/71/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=fullfatcode.wordpress.com&amp;blog=8046360&amp;post=71&amp;subd=fullfatcode&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://fullfatcode.wordpress.com/2009/08/03/jquey-uploadify-simultaneous-mulitple-file-uploads-with-jquery/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/11d0d57577758724680050c2f4d0b047?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">jcarmichael</media:title>
		</media:content>
	</item>
		<item>
		<title>A new home for my blog!</title>
		<link>http://fullfatcode.wordpress.com/2009/06/20/a-new-home-for-my-blog/</link>
		<comments>http://fullfatcode.wordpress.com/2009/06/20/a-new-home-for-my-blog/#comments</comments>
		<pubDate>Sat, 20 Jun 2009 22:37:32 +0000</pubDate>
		<dc:creator>jcarmichael</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://fullfatcode.wordpress.com/2009/06/20/a-new-home-for-my-blog/</guid>
		<description><![CDATA[Please head over to www.fullfatcode.com where my blog now has a new, permanent home. (Oh, and a swanky new theme too!)<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=fullfatcode.wordpress.com&amp;blog=8046360&amp;post=69&amp;subd=fullfatcode&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Please head over to <a href="http://www.fullfatcode.com">www.fullfatcode.com</a> where my blog now has a new, permanent home.</p>
<p>(Oh, and a swanky new theme too!)</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/fullfatcode.wordpress.com/69/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/fullfatcode.wordpress.com/69/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/fullfatcode.wordpress.com/69/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/fullfatcode.wordpress.com/69/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/fullfatcode.wordpress.com/69/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/fullfatcode.wordpress.com/69/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/fullfatcode.wordpress.com/69/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/fullfatcode.wordpress.com/69/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/fullfatcode.wordpress.com/69/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/fullfatcode.wordpress.com/69/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/fullfatcode.wordpress.com/69/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/fullfatcode.wordpress.com/69/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/fullfatcode.wordpress.com/69/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/fullfatcode.wordpress.com/69/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=fullfatcode.wordpress.com&amp;blog=8046360&amp;post=69&amp;subd=fullfatcode&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://fullfatcode.wordpress.com/2009/06/20/a-new-home-for-my-blog/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/11d0d57577758724680050c2f4d0b047?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">jcarmichael</media:title>
		</media:content>
	</item>
		<item>
		<title>JQuery AJAX using XML in Internet Explorer</title>
		<link>http://fullfatcode.wordpress.com/2009/06/17/jquery-ajax-using-xml-in-internet-explorer/</link>
		<comments>http://fullfatcode.wordpress.com/2009/06/17/jquery-ajax-using-xml-in-internet-explorer/#comments</comments>
		<pubDate>Wed, 17 Jun 2009 10:28:44 +0000</pubDate>
		<dc:creator>jcarmichael</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[JQuery]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[header]]></category>
		<category><![CDATA[IE]]></category>
		<category><![CDATA[IE8]]></category>
		<category><![CDATA[mime]]></category>
		<category><![CDATA[xml]]></category>

		<guid isPermaLink="false">http://fullfatcode.wordpress.com/?p=65</guid>
		<description><![CDATA[I spent a while this morning trying to figure out why an JQuery AJAX call wasn&#8217;t working in Internet Explorer 8. The call was being made to a PHP script which was outputting XML. I had checked the XML was valid and (no surprises) it was all working fine in Firefox. Eventually I found this [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=fullfatcode.wordpress.com&amp;blog=8046360&amp;post=65&amp;subd=fullfatcode&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I spent a while this morning trying to figure out why an JQuery AJAX call wasn&#8217;t working in Internet Explorer 8. The call was being made to a PHP script which was outputting XML.</p>
<p>I had checked the XML was valid and (no surprises) it was all working fine in Firefox.</p>
<p>Eventually I found this <a href="http://stackoverflow.com/questions/811672/jquery-get-post-not-working-on-ie-7-or-8-works-fine-in-ff/904586">useful discussion</a>.  It turns out you need to have the following header in your PHP script:</p>
<p><pre class="brush: php;">
header(&quot;content-type:application/xml;charset=utf-8&quot;);
</pre></p>
<p>I was using &#8216;text/xml&#8217; which is perfectly valid but hey.  That&#8217;s IE for you.</p>
<p>While I&#8217;m doing the usual IE bashing, it should be said that version 8 of the browser is much better both from the point of view of standards support and debugging, so at least progress is being made.  Only took 8 versions eh?</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/fullfatcode.wordpress.com/65/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/fullfatcode.wordpress.com/65/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/fullfatcode.wordpress.com/65/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/fullfatcode.wordpress.com/65/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/fullfatcode.wordpress.com/65/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/fullfatcode.wordpress.com/65/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/fullfatcode.wordpress.com/65/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/fullfatcode.wordpress.com/65/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/fullfatcode.wordpress.com/65/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/fullfatcode.wordpress.com/65/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/fullfatcode.wordpress.com/65/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/fullfatcode.wordpress.com/65/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/fullfatcode.wordpress.com/65/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/fullfatcode.wordpress.com/65/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=fullfatcode.wordpress.com&amp;blog=8046360&amp;post=65&amp;subd=fullfatcode&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://fullfatcode.wordpress.com/2009/06/17/jquery-ajax-using-xml-in-internet-explorer/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/11d0d57577758724680050c2f4d0b047?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">jcarmichael</media:title>
		</media:content>
	</item>
		<item>
		<title>Loading XML with JQuery &#8211; an XCAL feed</title>
		<link>http://fullfatcode.wordpress.com/2009/06/16/loading-xml-with-jquery-an-xcal-feed/</link>
		<comments>http://fullfatcode.wordpress.com/2009/06/16/loading-xml-with-jquery-an-xcal-feed/#comments</comments>
		<pubDate>Tue, 16 Jun 2009 19:08:23 +0000</pubDate>
		<dc:creator>jcarmichael</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[JQuery]]></category>
		<category><![CDATA[xcal]]></category>
		<category><![CDATA[xml]]></category>

		<guid isPermaLink="false">http://fullfatcode.wordpress.com/?p=62</guid>
		<description><![CDATA[XCAL is an XML implementation of the iCal format, and as such it can be easily read with JQuery. So, if you&#8217;re implementing some kind of calendaring system online, one way to accomplish it could be to read the events from your database, output them in XCAL format, and display them online using our old [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=fullfatcode.wordpress.com&amp;blog=8046360&amp;post=62&amp;subd=fullfatcode&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><a href="http://tools.ietf.org/html/draft-royer-calsch-xcal-03">XCAL</a> is an XML implementation of the iCal format, and as such it can be easily read with JQuery.</p>
<p>So, if you&#8217;re implementing some kind of calendaring system online, one way to accomplish it could be to read the events from your database, output them in XCAL format, and display them online using our old friend JQuery.</p>
<p>I&#8217;m not sure how widespread XCAL is, but at least it&#8217;s a standard of some sort and that could be useful, for example if you wanted to subscribe to the calendar using an external program.</p>
<p>Anyway &#8211; on with the example:</p>
<p><pre class="brush: jscript;">

/**
 * A function to parse the XCAL format date into an object
 */
function parseDate(xCalDate) {

 // Array of abbreviated month names
 var months = new Array('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December');

 return {
 'year'            :    xCalDate.substr(0,4),
 'month'            :    xCalDate.substr(4,2),
 'monthname'    : months[xCalDate.substr(4,2)-1],
 'day'                :    xCalDate.substr(6,2),
 'hour'            :    xCalDate.substr(9,2),
 'minute'        :    xCalDate.substr(11,2)
 }
}

/**
 * Do this when document is ready
 */
$(document).ready(function() {
 // Load the XML file
 $.get('xcal.xml', null, function(data) {
 // Find each 'vevent' node
 $(data).find('vevent').each(function() {
 // Parse the text string into an object using the above function
 var dateObj = parseDate($(this).children('dtstart').text());
 // Display the event info in the unordered list
 $('#content').append('
	&lt;li&gt;&lt;b&gt;' + dateObj.day + ' ' + dateObj.monthname + ' ' + dateObj.year + '&lt;/b&gt; ' + dateObj.hour + ':' + dateObj.minute + ':&lt;/li&gt;
');
 $('#content li:last').append($(this).children('summary').text());
 $('#content li:last').append(' at ' + $(this).children('location').text());
 })
 }, 'xml');
})

</pre></p>
<p>If you want to see it all in action, you can <a href="http://www.siteclick.co.uk/blog-content/jquery/jquery-xcal-example.zip">download</a> the whole project, including the XCAL document.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/fullfatcode.wordpress.com/62/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/fullfatcode.wordpress.com/62/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/fullfatcode.wordpress.com/62/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/fullfatcode.wordpress.com/62/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/fullfatcode.wordpress.com/62/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/fullfatcode.wordpress.com/62/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/fullfatcode.wordpress.com/62/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/fullfatcode.wordpress.com/62/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/fullfatcode.wordpress.com/62/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/fullfatcode.wordpress.com/62/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/fullfatcode.wordpress.com/62/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/fullfatcode.wordpress.com/62/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/fullfatcode.wordpress.com/62/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/fullfatcode.wordpress.com/62/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=fullfatcode.wordpress.com&amp;blog=8046360&amp;post=62&amp;subd=fullfatcode&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://fullfatcode.wordpress.com/2009/06/16/loading-xml-with-jquery-an-xcal-feed/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/11d0d57577758724680050c2f4d0b047?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">jcarmichael</media:title>
		</media:content>
	</item>
		<item>
		<title>Mosso Cloud Files API with Windows</title>
		<link>http://fullfatcode.wordpress.com/2009/06/15/mosso-cloud-files-api-with-windows/</link>
		<comments>http://fullfatcode.wordpress.com/2009/06/15/mosso-cloud-files-api-with-windows/#comments</comments>
		<pubDate>Mon, 15 Jun 2009 16:31:11 +0000</pubDate>
		<dc:creator>jcarmichael</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[cloud files]]></category>
		<category><![CDATA[curl]]></category>
		<category><![CDATA[mosso]]></category>
		<category><![CDATA[ssl]]></category>

		<guid isPermaLink="false">http://fullfatcode.wordpress.com/?p=56</guid>
		<description><![CDATA[I spent a while tearing my hair out today trying to connect to the Mosso Cloud Files API with PHP.  It seemed to be authenticating OK, but I couldn&#8217;t create a container. The error I got was &#8220;Failed to obtain http response&#8221;. It appears as though this has to do with CURL and SSL on [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=fullfatcode.wordpress.com&amp;blog=8046360&amp;post=56&amp;subd=fullfatcode&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I spent a while tearing my hair out today trying to connect to the Mosso Cloud Files API with PHP.  It seemed to be authenticating OK, but I couldn&#8217;t create a container.</p>
<p>The error I got was &#8220;Failed to obtain http response&#8221;.</p>
<p>It appears as though this has to do with CURL and SSL on Windows machines.  For a quick and dirty fix (not for production use) add:</p>
<p>curl_setopt($this-&gt;connections[$conn_type], CURLOPT_SSL_VERIFYPEER, 0);</p>
<p>To line 1210 of cloudfiles_http.php</p>
<p>To fully solve the problem, see <a href="http://www.vividreflection.com/blog/secret-to-curl-in-php-on-windows/">this great blog post</a>.</p>
<p>For more info on Mosso Cloud Files, soon to become &#8220;The Rackspace Cloud&#8221;, see the link below:<br />
<a href="http://www.rackspacecloud.com"><img src="http://cdn.cloudfiles.mosso.com/c110782/the-rackspace-cloud-125-wide.png" border="0" alt="Cloud Hosting - Formerly Mosso" /></a></p>
<p><a href="http://www.rackspacecloud.com">Cloud Hosting</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/fullfatcode.wordpress.com/56/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/fullfatcode.wordpress.com/56/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/fullfatcode.wordpress.com/56/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/fullfatcode.wordpress.com/56/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/fullfatcode.wordpress.com/56/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/fullfatcode.wordpress.com/56/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/fullfatcode.wordpress.com/56/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/fullfatcode.wordpress.com/56/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/fullfatcode.wordpress.com/56/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/fullfatcode.wordpress.com/56/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/fullfatcode.wordpress.com/56/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/fullfatcode.wordpress.com/56/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/fullfatcode.wordpress.com/56/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/fullfatcode.wordpress.com/56/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=fullfatcode.wordpress.com&amp;blog=8046360&amp;post=56&amp;subd=fullfatcode&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://fullfatcode.wordpress.com/2009/06/15/mosso-cloud-files-api-with-windows/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/11d0d57577758724680050c2f4d0b047?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">jcarmichael</media:title>
		</media:content>

		<media:content url="http://cdn.cloudfiles.mosso.com/c110782/the-rackspace-cloud-125-wide.png" medium="image">
			<media:title type="html">Cloud Hosting - Formerly Mosso</media:title>
		</media:content>
	</item>
		<item>
		<title>Loading XML with JQuery</title>
		<link>http://fullfatcode.wordpress.com/2009/06/14/loading-xml-with-jquery/</link>
		<comments>http://fullfatcode.wordpress.com/2009/06/14/loading-xml-with-jquery/#comments</comments>
		<pubDate>Sun, 14 Jun 2009 22:20:28 +0000</pubDate>
		<dc:creator>jcarmichael</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[JQuery]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[json]]></category>
		<category><![CDATA[rss]]></category>
		<category><![CDATA[xml]]></category>

		<guid isPermaLink="false">http://fullfatcode.wordpress.com/?p=51</guid>
		<description><![CDATA[Thankfully JQuery makes it really easy to load a variety of data formats with AJAX: Text HTML JSON (JavaScript Object Notation) XML Within applications I generally use JSON, as it is less verbose and easier to process than XML.  Check out the PEAR JSON package for a way to easily expose data from PHP as [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=fullfatcode.wordpress.com&amp;blog=8046360&amp;post=51&amp;subd=fullfatcode&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Thankfully JQuery makes it really easy to load a variety of data formats with AJAX:</p>
<ul>
<li>Text</li>
<li>HTML</li>
<li>JSON (JavaScript Object Notation)</li>
<li>XML</li>
</ul>
<p>Within applications I generally use JSON, as it is less verbose and easier to process than XML.  Check out the <a href="http://pear.php.net/package/Services_JSON">PEAR JSON</a> package for a way to easily expose data from PHP as JSON.</p>
<p>I occasionally find it useful to read XML data instead, and JQuery lets us interact with it in exactly the same way as we interact with HTML elements.</p>
<p>Here&#8217;s a rough and ready example to show how easy it is to read an RSS feed (rss.xml) in, and then display the list of article titles as links in a div with id of &#8216;content&#8217;  in just a few lines of code:</p>
<p><pre class="brush: jscript;">

$(document).ready(function() {
 $.get('rss.xml', null, function(data) {
 $(data).find('channel item').each(function() {
 $('div#content').append('&lt;a href=&quot;' + $(this).children('link').text() + '&quot;&gt;' + $(this).children('title').text() + '&lt;/a&gt;
');
 })
 }, 'xml');
})

</pre></p>
<p>Here I&#8217;ve use the text() function to read the text value of a node in the XML, you may sometimes also need to use the attr() function to access a particular attribute.</p>
<p>A word of warning: you can&#8217;t read data using AJAX from domains other than the current domain for security reasons.  To get around this problem, you will need to write a server-side script (eg PHP or ASP) to read the XML feed from the remote server and output it, so it can be accessible by JQuery on your own server.</p>
<p>Updated: you can now download a complete working example <a href="http://www.siteclick.co.uk/blog-content/jquery/jquery-rss-example.zip">here</a>.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/fullfatcode.wordpress.com/51/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/fullfatcode.wordpress.com/51/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/fullfatcode.wordpress.com/51/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/fullfatcode.wordpress.com/51/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/fullfatcode.wordpress.com/51/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/fullfatcode.wordpress.com/51/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/fullfatcode.wordpress.com/51/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/fullfatcode.wordpress.com/51/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/fullfatcode.wordpress.com/51/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/fullfatcode.wordpress.com/51/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/fullfatcode.wordpress.com/51/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/fullfatcode.wordpress.com/51/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/fullfatcode.wordpress.com/51/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/fullfatcode.wordpress.com/51/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=fullfatcode.wordpress.com&amp;blog=8046360&amp;post=51&amp;subd=fullfatcode&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://fullfatcode.wordpress.com/2009/06/14/loading-xml-with-jquery/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/11d0d57577758724680050c2f4d0b047?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">jcarmichael</media:title>
		</media:content>
	</item>
		<item>
		<title>JQuery Search Suggester Plugin</title>
		<link>http://fullfatcode.wordpress.com/2009/06/09/jquery-search-suggester-plugin/</link>
		<comments>http://fullfatcode.wordpress.com/2009/06/09/jquery-search-suggester-plugin/#comments</comments>
		<pubDate>Tue, 09 Jun 2009 10:27:03 +0000</pubDate>
		<dc:creator>jcarmichael</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[JQuery]]></category>
		<category><![CDATA[lookup]]></category>
		<category><![CDATA[search]]></category>
		<category><![CDATA[suggest]]></category>

		<guid isPermaLink="false">http://fullfatcode.wordpress.com/?p=46</guid>
		<description><![CDATA[While writing a simple knowledgebase application for my web company I wanted to create the facility to automatically suggest articles as the user typed in a question. So I came up with the following &#8216;suggester&#8217; plugin.  To get it working, you need to: Attach it to an input field Pass in the backend URL to [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=fullfatcode.wordpress.com&amp;blog=8046360&amp;post=46&amp;subd=fullfatcode&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>While writing a simple knowledgebase application for my <a href="http://www.siteclick.co.uk">web company</a> I wanted to create the facility to automatically suggest articles as the user typed in a question.</p>
<p>So I came up with the following &#8216;suggester&#8217; plugin.  To get it working, you need to:</p>
<ul>
<li>Attach it to an input field</li>
<li>Pass in the backend URL to load via AJAX</li>
<li>Supply a callback function called results_cb where the data gets sent.</li>
</ul>
<p>Typically your results_cb function will be responsible for displaying the returned options to the user.</p>
<p>Your backend script needs to respond to the POST variable unimaginatively named  &#8216;search&#8217;.</p>
<p>The plugin doesn&#8217;t impose any ideas about what sort of data you&#8217;re receiving back, or how to display it, but this makes it more flexible and resusable in my opinion.</p>
<p>Here&#8217;s an example of how it can be used:</p>
<p><pre class="brush: jscript;">

$('input').suggester(

{ url : 'search.php', 

results_cb : function(data) { alert(data); }, 

mode : 'text'}

)

</pre></p>
<p>And here&#8217;s the plugin itself:</p>
<p><pre class="brush: jscript;">

/**
 * JQuery suggester plugin 0.1
 * J A Carmichael
 * www.siteclick.co.cuk
 *
 * License: MIT
 * 
 * If you use this, please consider linking to www.siteclick.co.uk :)
 *
 * 12/5/2009
 * attach this to a field, eg $(input).suggester()
 * options:
 * url                :        The URL to call with the search term
 * results_cb    :        A callback to call when data is loaded via AJAX
 * mode                :        the type of data to send to the callback - default JSON
 */

jQuery.fn.suggester = function(settings) {

 // Set defaults
 var settings = jQuery.extend({
 'url'                    :    '',
 'results_cb'    :    function() {},
 'on_search'        :    function() {},
 'mode'                :    'json'
 }, settings);

 // For each item
 return this.each(function(){

 // The field which the user is typing in
 var inputField = this;

 // A flag to indicate whether typing currently
 var typing = false;

 // Current search term
 var searchTerm = '';

 // The last search
 var currentSearch = '';

 /**
 * Function to do the searching every so often
 */
 var searchFunc = function() {
 if(!typing &amp;&amp; (searchTerm != currentSearch)) {
 currentSearch = searchTerm;
 // Call the function to indicate we're now searching
 settings.on_search(searchTerm);
 // Send post request
 $.post(settings.url, 'search=' + encodeURIComponent(searchTerm), settings.results_cb, settings.mode);
 }
 // Keep calling the search function
 window.setTimeout(searchFunc, 500);
 }

 /**
 * Handler for when a key is depressed on this field
 */
 jQuery(inputField).keyup(function() {
 typing = true;

 // Update the search term
 searchTerm = $(this).val();

 // Reset the typing flag after a certain time
 window.setTimeout(function() {
 typing = false;
 }, 500);
 })

 // Start searching
 searchFunc();

 })
}

</pre></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/fullfatcode.wordpress.com/46/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/fullfatcode.wordpress.com/46/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/fullfatcode.wordpress.com/46/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/fullfatcode.wordpress.com/46/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/fullfatcode.wordpress.com/46/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/fullfatcode.wordpress.com/46/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/fullfatcode.wordpress.com/46/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/fullfatcode.wordpress.com/46/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/fullfatcode.wordpress.com/46/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/fullfatcode.wordpress.com/46/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/fullfatcode.wordpress.com/46/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/fullfatcode.wordpress.com/46/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/fullfatcode.wordpress.com/46/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/fullfatcode.wordpress.com/46/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=fullfatcode.wordpress.com&amp;blog=8046360&amp;post=46&amp;subd=fullfatcode&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://fullfatcode.wordpress.com/2009/06/09/jquery-search-suggester-plugin/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/11d0d57577758724680050c2f4d0b047?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">jcarmichael</media:title>
		</media:content>
	</item>
		<item>
		<title>Simplifying HTML Form CSS with JQuery</title>
		<link>http://fullfatcode.wordpress.com/2009/06/08/simplifying-html-form-css-with-jquery/</link>
		<comments>http://fullfatcode.wordpress.com/2009/06/08/simplifying-html-form-css-with-jquery/#comments</comments>
		<pubDate>Mon, 08 Jun 2009 14:14:37 +0000</pubDate>
		<dc:creator>jcarmichael</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[JQuery]]></category>

		<guid isPermaLink="false">http://fullfatcode.wordpress.com/?p=42</guid>
		<description><![CDATA[Thanks to CSS, it&#8217;s possible to make nicely styled web forms without a table in site.  Often we wish to add CSS styling to our input fields &#8211; but there&#8217;s a snag which is any checkbox or radio field ends up with the same styling.  We end up with ugly borders and wierd gaps everywhere [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=fullfatcode.wordpress.com&amp;blog=8046360&amp;post=42&amp;subd=fullfatcode&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Thanks to CSS, it&#8217;s possible to make nicely styled web forms without a table in site.  Often we wish to add CSS styling to our input fields &#8211; but there&#8217;s a snag which is any checkbox or radio field ends up with the same styling.  We end up with ugly borders and wierd gaps everywhere around checkboxes and radio buttons.</p>
<p>In the future, CSS will provide a solution with &#8220;attribute selectors&#8221; as so:</p>
<p><pre class="brush: css;">

input {

  width:  100px;

  border:  1px solid #cde;

}

input[type=&quot;radio&quot;], input[type=&quot;checkbox&quot;] {

  width:  auto;

  border: 0;

}

</pre></p>
<p>But, as with most things in life, this has not been supported by Internet Explorer until recently.  So, JQuery to the rescue.  We can change our CSS to:</p>
<p><pre class="brush: css;">

input {

  width:  100px;

  border:  1px solid #cde;

}

input[type=&quot;radio&quot;], input.radio, input[type=&quot;checkbox&quot;], input.checkbox {

  width:  auto;

  border: 0;

}

</pre></p>
<p>And add a little JQuery:</p>
<p><pre class="brush: jscript;">

$(document).ready(function() {

  $('input[type=radio]').addClass('radio');

  $('input[type=checkbox]').addClass('checkbox');

})

</pre></p>
<p>We can take advantage of JQuery&#8217;s support for attribute selectors to apply a CSS class to the checkbox and radio button elements, applying the same CSS rules as if attribute selectors had been supported by the browser.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/fullfatcode.wordpress.com/42/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/fullfatcode.wordpress.com/42/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/fullfatcode.wordpress.com/42/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/fullfatcode.wordpress.com/42/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/fullfatcode.wordpress.com/42/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/fullfatcode.wordpress.com/42/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/fullfatcode.wordpress.com/42/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/fullfatcode.wordpress.com/42/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/fullfatcode.wordpress.com/42/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/fullfatcode.wordpress.com/42/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/fullfatcode.wordpress.com/42/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/fullfatcode.wordpress.com/42/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/fullfatcode.wordpress.com/42/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/fullfatcode.wordpress.com/42/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=fullfatcode.wordpress.com&amp;blog=8046360&amp;post=42&amp;subd=fullfatcode&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://fullfatcode.wordpress.com/2009/06/08/simplifying-html-form-css-with-jquery/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/11d0d57577758724680050c2f4d0b047?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">jcarmichael</media:title>
		</media:content>
	</item>
		<item>
		<title>A JPEG to PNG Processor in PHP</title>
		<link>http://fullfatcode.wordpress.com/2009/06/07/a-jpeg-to-png-processor-in-php/</link>
		<comments>http://fullfatcode.wordpress.com/2009/06/07/a-jpeg-to-png-processor-in-php/#comments</comments>
		<pubDate>Sun, 07 Jun 2009 15:27:28 +0000</pubDate>
		<dc:creator>jcarmichael</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[alpha]]></category>
		<category><![CDATA[GD]]></category>
		<category><![CDATA[JPEG]]></category>
		<category><![CDATA[PNG]]></category>
		<category><![CDATA[transparency]]></category>

		<guid isPermaLink="false">http://fullfatcode.wordpress.com/?p=35</guid>
		<description><![CDATA[So for our new CMS project I needed a way to turn a logo as a JPEG on a white background, into a transparent PNG. This didn&#8217;t turn out to be particularly straightforward, as due the JPEG compression, the white part of the image is noisy.  So it was quite tricky to cut out the [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=fullfatcode.wordpress.com&amp;blog=8046360&amp;post=35&amp;subd=fullfatcode&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>So for our new <a href="http://www.siteclick.co.uk">CMS project</a> I needed a way to turn a logo as a JPEG on a white background, into a transparent PNG.</p>
<p>This didn&#8217;t turn out to be particularly straightforward, as due the JPEG compression, the white part of the image is noisy.  So it was quite tricky to cut out the logo and have a smooth edge.</p>
<p>So I came up with the following algorithm, mostly by trial and error.  It works by calculating a cost function, based on the brightness and greyness of a particular pixel.  If a pixel is both very bright, and doesn&#8217;t have much of a hue, it will be made more transparent.  This gives a smooth edge to the cut out logo.</p>
<p>This could be useful for example in an online shop where you might have product images on a white background that you wish were transparent.</p>
<p>Among other things, you will need PHP5 and the GD libraries to get this working.</p>
<p>You use it something like so:</p>
<p><pre class="brush: php;">

$Im = new AutoTransparency();

$Im-&gt;loadFromFile('sourcefile.jpg');

$Im-&gt;process();

$Im-&gt;toFile('destinationfile.png');

</pre></p>
<p>There&#8217;s also a handy &#8216;resample&#8217; function built in so you can apply that method if you&#8217;d like the PNG to be a different size aswell.</p>
<p><pre class="brush: php;">
&lt;?php

/**
 * A class designed to load a JPEG image on a white background
 * and automatically convert to a PNG with a transparent background
 * using an alpha transparency algorithm
 *
 * License: MIT
 *
 * Please link to www.siteclick.co.uk if you use this code in your project - thanks :)
 *
 * (c)    13/5/2009    J A Carmichael
 */

class AutoTransparency {

 /**
 * The maximum possible value for alpha transparency
 * @param int
 */
 var $max_alpha    =    127;

 /**
 * The maximum possible value for RGB values
 * @param unt
 */
 var $max_rgb        = 255;

 /**
 * The image resource loaded
 * @param int
 */
 var    $im;

 /**
 * The newly created image resource
 * @param int
 */
 var $newim;

 /**
 * Original width &amp;height of image
 * @param int
 */
 var $w_orig;
 var $h_orig;

 /**
 * Constructor
 */
 function __construct () {

 }

 /**
 * load source image from JPEG
 */
 function loadFromFile($file) {
 $this-&gt;im = imagecreatefromjpeg($file);
 }

 /**
 * Do the process
 */
 function process() {

 // Get image dimensions
 $this-&gt;w_orig = imagesx($this-&gt;im);
 $this-&gt;h_orig = imagesy($this-&gt;im);

 // Create new image
 $new = imagecreatetruecolor( $this-&gt;w_orig, $this-&gt;h_orig );

 // Turn off alpha blending and set alpha flag
 imagealphablending($new, false);
 imagesavealpha($new, true);

 // Set a White &amp; Transparent Background Color
 $bg = imagecolorallocatealpha($new, 255, 255, 255, 127);
 imagecolortransparent($new, $bg);

 // Go over each pixel
 for($x =0; $x &lt; $this-&gt;w_orig; $x++) {
 for($y = 0; $y &lt; $this-&gt;h_orig; $y++) {

 // Get RGB values of colour at current pixel
 $rgb = imagecolorat($this-&gt;im, $x, $y);
 $r = ($rgb &gt;&gt; 16) &amp; 0xFF;
 $g = ($rgb &gt;&gt; 8) &amp; 0xFF;
 $b = $rgb &amp; 0xFF;

 // Brightness defined 0-1
 $brightness = ($r + $g + $b) / (3 * $this-&gt;max_rgb);

 // Greyness by measuring difference between channels defined 0-1
 $rg = 255 - abs($r - $g);        //     Range 0-255
 $rb = 255 - abs($r - $b);     //     Range 0-255
 $gb = 255 - abs($g - $b);     //     Range 0-255
 $greyness   = ($rg + $rb + $gb) / (3 * $this-&gt;max_rgb);

 // Alpha value - combines the brightness and greyness of the image using power laws so they drop off rapidly
 $alpha = $this-&gt;max_alpha * pow($brightness, 2) * pow($greyness, 3);

 // Create new partially transparent colour
 $new_colour = imagecolorallocatealpha( $new , $r , $g  , $b  , $alpha);

 // Set pixel with new partially transparent colour in new image
 imagesetpixel ($new  , $x, $y , $new_colour );

 }
 }

 $this-&gt;newim = $new;

 }

 /**
 * Save the new PNG to the specified file
 */
 function toFile($file) {
 imagepng($this-&gt;newim, $file);
 }

 /**
 * Resample
 */
 function resample($iNewWidth = 100) {
 settype($iNewWidth, 'int');

 // Aspect ratio
 $r  = $this-&gt;w_orig / $this-&gt;h_orig;           // Aspect ratio

 // Calculate new height
 $iNewHeight = floor($iNewWidth/$r);

 $newim           = imagecreatetruecolor($iNewWidth, $iNewHeight);        // Create new image

 // Turn off alpha blending and set alpha flag
 imagealphablending($newim, false);
 imagesavealpha($newim, true);

 $success         = ImageCopyResampled($newim, $this-&gt;newim, 0, 0, 0, 0, $iNewWidth, $iNewHeight, $this-&gt;w_orig, $this-&gt;h_orig);

 $this-&gt;newim = $newim;
 }

 /**
 * Stream to output
 */
 function stream() {
 header('content-type: image/png');
 imagepng($this-&gt;newim, null);
 }

}

?&gt;
</pre></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/fullfatcode.wordpress.com/35/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/fullfatcode.wordpress.com/35/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/fullfatcode.wordpress.com/35/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/fullfatcode.wordpress.com/35/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/fullfatcode.wordpress.com/35/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/fullfatcode.wordpress.com/35/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/fullfatcode.wordpress.com/35/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/fullfatcode.wordpress.com/35/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/fullfatcode.wordpress.com/35/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/fullfatcode.wordpress.com/35/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/fullfatcode.wordpress.com/35/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/fullfatcode.wordpress.com/35/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/fullfatcode.wordpress.com/35/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/fullfatcode.wordpress.com/35/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=fullfatcode.wordpress.com&amp;blog=8046360&amp;post=35&amp;subd=fullfatcode&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://fullfatcode.wordpress.com/2009/06/07/a-jpeg-to-png-processor-in-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/11d0d57577758724680050c2f4d0b047?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">jcarmichael</media:title>
		</media:content>
	</item>
	</channel>
</rss>
