<?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>puremango.co.uk &#187; PHP</title>
	<atom:link href="http://www.puremango.co.uk/category/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.puremango.co.uk</link>
	<description>innovative coding, tutorials, web stuff.</description>
	<lastBuildDate>Wed, 17 Feb 2010 17:28:12 +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>allRGB Entry &#8211; PHP Image Manipulation</title>
		<link>http://www.puremango.co.uk/2010/02/allrgb-entry-php-image-manipulation/</link>
		<comments>http://www.puremango.co.uk/2010/02/allrgb-entry-php-image-manipulation/#comments</comments>
		<pubDate>Wed, 10 Feb 2010 08:38:44 +0000</pubDate>
		<dc:creator>Howard Yeend</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[allrgb]]></category>
		<category><![CDATA[colours]]></category>
		<category><![CDATA[geek]]></category>
		<category><![CDATA[imagecreate]]></category>
		<category><![CDATA[images]]></category>
		<category><![CDATA[phpdemoscene]]></category>
		<category><![CDATA[rgb]]></category>

		<guid isPermaLink="false">http://www.puremango.co.uk/?p=773</guid>
		<description><![CDATA[The objective of allRGB is simple: To create images with one pixel for every rgb-color (16777216 to be exact); not one color missing, and not one color twice.
What a cool project! As regular readers will know, I love messing about with image manipulation in PHP, so when I heard about the allRGB project I knew [...]]]></description>
			<content:encoded><![CDATA[<blockquote><p>The objective of <a href="http://allrgb.com/" target="_blank">allRGB</a> is simple: To create images with one pixel for every <abbr>rgb</abbr>-color (16777216 to be exact); not one color missing, and not one color twice.</p></blockquote>
<p>What a cool project! As regular readers will know, I love messing about with <a href="http://www.puremango.co.uk/tag/imagecreate/" target="_self">image manipulation in PHP</a>, so when I heard about the allRGB project I knew I had to make an entry for it. A few false starts and about half an hour later, I proudly submitted my first entry, a 4096&#215;4096 PNG image containing every single possible RGB colour. As one redditor put it, &#8220;It&#8217;s like poetry, just without words.&#8221;</p>
<p><center><a href="http://www.puremango.co.uk/allrgb/one.png" target="_blank"><img title="All possible colours" src="http://www.puremango.co.uk/allrgb/sm_one.jpg" alt="" width="400" height="400" /></center></a></p>
<p style="text-align: center;"><a href="http://www.puremango.co.uk/allrgb/one.png" target="_blank"><em>Click for the high resolution (only 173Kb)</em></a></p>
<p>And now on to the code:<br />
<span id="more-773"></span><br />
The authors of the allRGB project state that;</p>
<blockquote><p>The most obvious example is a series of 16 by 16 squares, each of which consists of a gradient.</p></blockquote>
<p>But to me the most obvious approach was to simply loop over red (0-255), green (0-255) and blue (0-255) adding a pixel for each colour; as the PHP code below illustrates:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?</span>
&nbsp;
<span style="color: #000088;">$w</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">4096</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$h</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">4096</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$x</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$y</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$im</span> <span style="color: #339933;">=</span> <span style="color: #990000;">ImageCreateTrueColor</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$w</span><span style="color: #339933;">,</span> <span style="color: #000088;">$h</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">for</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$r</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">0</span> <span style="color: #339933;">;</span> <span style="color: #000088;">$r</span><span style="color: #339933;">&lt;=</span><span style="color: #cc66cc;">255</span> <span style="color: #339933;">;</span> <span style="color: #000088;">$r</span><span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">for</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$g</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">0</span> <span style="color: #339933;">;</span> <span style="color: #000088;">$g</span><span style="color: #339933;">&lt;=</span><span style="color: #cc66cc;">255</span> <span style="color: #339933;">;</span> <span style="color: #000088;">$g</span><span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">for</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$b</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">0</span> <span style="color: #339933;">;</span> <span style="color: #000088;">$b</span><span style="color: #339933;">&lt;=</span><span style="color: #cc66cc;">255</span> <span style="color: #339933;">;</span> <span style="color: #000088;">$b</span><span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$col</span> <span style="color: #339933;">=</span> <span style="color: #990000;">ImageColorAllocate</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$im</span><span style="color: #339933;">,</span><span style="color: #000088;">$r</span><span style="color: #339933;">,</span><span style="color: #000088;">$g</span><span style="color: #339933;">,</span><span style="color: #000088;">$b</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #990000;">ImageSetPixel</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$im</span><span style="color: #339933;">,</span> <span style="color: #000088;">$x</span><span style="color: #339933;">,</span> <span style="color: #000088;">$y</span><span style="color: #339933;">,</span> <span style="color: #000088;">$col</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
			<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$x</span><span style="color: #339933;">&lt;</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$w</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				<span style="color: #000088;">$x</span><span style="color: #339933;">++;</span>
			<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
				<span style="color: #000088;">$x</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
				<span style="color: #000088;">$y</span><span style="color: #339933;">++;</span>
			<span style="color: #009900;">&#125;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #990000;">header</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Content-type: image/png&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">ImagePng</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$im</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">ImageDestroy</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$im</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>You&#8217;ll need to up max_execution_time and memory_limit, but it&#8217;s not as hungry as you might imagine; under a minute of processing time on my meager home server.</p>
<p>My entry, which I&#8217;ve imaginatively entitled &#8220;Grid One&#8221;, is still undergoing review with the folks at allRGB, but I hope to be listed in their hall of fame shortly (<a href="http://allrgb.com/grid-one">now listed</a>) :0) It&#8217;s similar to the existing &#8220;<a href="http://allrgb.com/suave">suave</a>&#8221; and &#8220;<a href="http://allrgb.com/tvlines">tvlines</a>&#8221; entries.</p>
<p>And for my next trick? I&#8217;m working on a script to convert any arbitrary image into an allRGB entry. But loops with 16 million iterations need to be carefully optimised. It&#8217;s a fun challenge, especially in PHP.</p>
<p><strong>Update</strong>: Many thanks to Alexander for pointing out that my first attempt didn&#8217;t actually contain all the colours (*blush*) &#8211; code and images updated now :D</p>
]]></content:encoded>
			<wfw:commentRss>http://www.puremango.co.uk/2010/02/allrgb-entry-php-image-manipulation/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Textpad PHP manual lookup tool</title>
		<link>http://www.puremango.co.uk/2010/02/textpad-php-manual-lookup-tool/</link>
		<comments>http://www.puremango.co.uk/2010/02/textpad-php-manual-lookup-tool/#comments</comments>
		<pubDate>Mon, 01 Feb 2010 19:11:40 +0000</pubDate>
		<dc:creator>Howard Yeend</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Productivity]]></category>
		<category><![CDATA[guide]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[software]]></category>
		<category><![CDATA[windows]]></category>

		<guid isPermaLink="false">http://www.puremango.co.uk/?p=743</guid>
		<description><![CDATA[A little tip for those of us using textpad to develop in PHP. How often do you find yourself having to go back to PHP.net to check up on a function &#8211; is it ($needle, $haystack) or ($haystack, $needle)? I can never remember! With this tool I just need to highlight the function in textpad, [...]]]></description>
			<content:encoded><![CDATA[<p>A little tip for those of us using <a href="http://www.textpad.com">textpad</a> to develop in PHP. How often do you find yourself having to go back to PHP.net to check up on a function &#8211; is it ($needle, $haystack) or ($haystack, $needle)? I can never remember! With this tool I just need to highlight the function in textpad, press Ctrl-1 and up pops php.net in a new tab, opened on that function&#8217;s manual entry. Neat huh?</p>
<p>Here&#8217;s how:</p>
<p><span id="more-743"></span><strong>1) Go to Configure-&gt;Preferences-&gt;Tools-&gt;Add-&gt;DOS Command:</strong></p>
<p><img class="aligncenter" title="Textpad Tools Menu" src="http://www.puremango.co.uk/images/textpad_tool1.png" alt="" width="632" height="372" /></p>
<p><strong>2) Then enter the following in the popup dialog:</strong></p>
<h3 style="padding-left: 30px;"><strong>start http://php.net/manual-lookup.php?pattern=$Sel</strong></h3>
<p><strong> </strong></p>
<p><strong>3) Then </strong><strong>in the tool&#8217;s preferences, </strong><strong>untick &#8220;Capture Output&#8221; and tick &#8220;Close DOS window on exit&#8221;:</strong></p>
<p><img class="aligncenter" title="Textpad Tools Options" src="http://www.puremango.co.uk/images/textpad_tool2.png" alt="" width="632" height="372" /></p>
<p>Now any time you want to lookup a function in your code, simply highlight or double-click it and press Ctrl-1 to be taken to that function&#8217;s manual page on PHP.net, in a new tab in your default web browser.</p>
<p>While we&#8217;re on the topic of textpad tweaks, did you know you can jump to the matching brace by pressing Ctrl-M? Very handy for spaghetti code. Share your textpad PHP IDE tips below! And if you haven&#8217;t already, why not take this opportunity to, you know, actually buy textpad after all this time? &lt;grin&gt;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.puremango.co.uk/2010/02/textpad-php-manual-lookup-tool/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>GIFexplode &#8211; community powered web development</title>
		<link>http://www.puremango.co.uk/2009/08/gifexplode-community-powered-web-development/</link>
		<comments>http://www.puremango.co.uk/2009/08/gifexplode-community-powered-web-development/#comments</comments>
		<pubDate>Sun, 02 Aug 2009 18:35:00 +0000</pubDate>
		<dc:creator>Howard Yeend</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[web]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[geek]]></category>
		<category><![CDATA[images]]></category>
		<category><![CDATA[tech]]></category>
		<category><![CDATA[tools]]></category>

		<guid isPermaLink="false">http://www.puremango.co.uk/?p=573</guid>
		<description><![CDATA[Let me share with you a very cool story about strangers coming together and building something.
I was browsing reddit yesterday, and I saw a thread entitled &#8220;Someone needs to make a Firefox add-on that lets you step through animated gifs frame by frame&#8220;. I thought &#8220;hey that&#8217;s a nice well defined simple idea&#8221; &#8211; just [...]]]></description>
			<content:encoded><![CDATA[<p>Let me share with you a very cool story about strangers coming together and building something.</p>
<p><a href="http://www.gifexplode.com/c" target="_blank"><img class="alignright" title="I am a tiger" src="http://www.puremango.co.uk/gifexplode/619504tiger.gif" alt="" width="100" height="100" /></a>I was browsing reddit yesterday, and I saw a thread entitled &#8220;<a href="http://www.reddit.com/r/programming/comments/96iok/someone_needs_to_make_a_firefox_addon_that_lets/">Someone needs to make a Firefox add-on that lets you step through animated gifs frame by frame</a>&#8220;. I thought &#8220;hey that&#8217;s a nice well defined simple idea&#8221; &#8211; just the kind of thing I love, so I registered a nice-sounding domain name and started looking at how to use PHP to split an animated gif into its component frames &#8211; I figured it couldn&#8217;t be too hard.<span id="more-573"></span></p>
<p><a href="http://www.gifexplode.com/q" target="_blank"><img class="alignleft" title="Ralph" src="http://www.puremango.co.uk/gifexplode/545934ralph_eats_glue_e0.gif" alt="" width="160" height="120" /></a>It wasn&#8217;t. Less than an hour later, <a href="http://www.gifexplode.com/" target="_blank">GIFexplode.com</a> was up and running with some bare-bones functionality based around some freeware code I&#8217;d found. I posted the link to reddit and thought &#8220;well it&#8217;s not quite a firefox extension but it&#8217;s close enough&#8221; (by the way, click any of the gifs on this page to see how GIFexplode processed them).</p>
<p>Within ten hours, other members of the reddit community had produced a working Firefox extension for GIFexplode, two bookmarklets, a logo, a front-end design and a <a href="http://www.reddit.com/r/programming/comments/96n1x/someone_needs_to_make_a_firefox_addon_that_will/" target="_blank">spoof thread</a>&#8230;</p>
<p>not to mention the <strong>700+ animated gif files</strong> that were uploaded in that first day.</p>
<p><a href="http://www.gifexplode.com/e" target="_blank"><img class="alignright" title="Chimp is not impressed" src="http://www.puremango.co.uk/gifexplode/102664chimpanzee.gif" alt="" /></a>Why did everyone pitch in like that? Well I can&#8217;t speak for anyone else, but I started working on it because I thought it would be an interesting challenge.</p>
<p><strong>Fame?</strong> A little &#8211; but while I got a few upvotes on reddit and earned a little respect, that really doesn&#8217;t go too far online. <strong>Fortune?</strong> Unlikely &#8211; even if GIFexplode became as popular as imageshack or tinyurl (which it won&#8217;t), I&#8217;d still have to work out a good enough revenue model to cover the hosting and bandwidth charges. <strong>Over 1.5GB was uploaded</strong> on that first day, and if GIFexplode carried on at that rate I&#8217;m sure I&#8217;d be asked to upgrade to a private server pretty quickly. <a href="http://www.dreamhost.com/r.cgi?492537" target="_blank">Dreamhost </a>coped excellently with the traffic though.</p>
<p><a href="http://www.gifexplode.com/endless.htm" target="_blank"><img class="alignleft" title="Endless. This one isn't actually processed correctly by GIFexplode.. yet." src="http://www.puremango.co.uk/gifexplode/794844one_1.gif" alt="" width="160" height="120" /></a>So that&#8217;s the story of how GIFexplode was born and, as one commenter aptly phrased it, put in front of &#8220;a live firing squad challenge&#8221;!</p>
<p>As to the future? Well there are a few extra features I want to implement, but I really have <a href="http://www.puremango.co.uk/2009/06/adaptive-web-sites/" target="_blank">more important work</a> to be doing this month. I expect the traffic to drop very sharply and hit around 10 visits per day by the end of September. Perhaps I&#8217;ll post another followup in a few months once we have some more features and the code is a bit more robust.</p>
<p>But in the meantime, <strong>a sincere thankyou</strong> to everyone who chipped in &#8211; if I ever do become a millionaire from this I&#8217;ll make sure you get your slice.</p>
<p><a href="http://www.gifexplode.com/d" target="_blank"><img class="alignright" title="Picard" src="http://www.puremango.co.uk/gifexplode/4290711237976746_picard2.gif" alt="" width="150" height="200" /></a><strong>Some random stats:</strong></p>
<ul>
<li>Around one third of the uploaded files were porn. I am amazed it wasn&#8217;t a higher proportion.</li>
<li>The bouncing gif (you know the one I mean) was uploaded at least 200 times &#8211; at one point I was considering making a static page just for that gif (I still may do)</li>
<li>The largest file uploaded was a 5.14Mb file of a <a href="http://commons.wikimedia.org/wiki/File:Cicada_molting_animated-2.gif" target="_blank">cicada molting</a></li>
<li>The non-porn files consisted mainly of people jumping around, trippy stuff, cartoon clips, cats and other animal antics ;0)</li>
</ul>
<p>I&#8217;ve archived everything that was uploaded to my local machine. Is there anything you&#8217;d like to know? Any ideas or suggested features?</p>
<p>update: For the moment, you can <a href="http://www.gifexplode.com/uploads/" target="_blank">browse what&#8217;s being uploaded</a> (lots NSFW). I will clear the contents of that directory every day or so, so don&#8217;t bother linking to the files there. A better way of sharing these gifs will come in a few months.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.puremango.co.uk/2009/08/gifexplode-community-powered-web-development/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>PHP CV &#8211; Howard Yeend &#8211; UK Web Developer</title>
		<link>http://www.puremango.co.uk/2009/08/php-cv/</link>
		<comments>http://www.puremango.co.uk/2009/08/php-cv/#comments</comments>
		<pubDate>Sat, 01 Aug 2009 13:40:52 +0000</pubDate>
		<dc:creator>Howard Yeend</dc:creator>
				<category><![CDATA[(misc)]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[cv]]></category>
		<category><![CDATA[developer]]></category>
		<category><![CDATA[howard]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[programmer]]></category>
		<category><![CDATA[resumé]]></category>

		<guid isPermaLink="false">http://www.puremango.co.uk/?p=217</guid>
		<description><![CDATA[howard.yeend@gmail.com &#8211; 07790 816291

Availability
Not currently seeking work. Sorry!
Qualifications

Oxford University 2008-2009
Subject: Computer Science MSc
Result: Pass, distinction in dissertation.
My dissertation focused on implementing Adaptive Web Sites using machine learning and Ajax. I passed modules including Object Oriented Programming with JAVA, Information Retrieval, Computational Linguistics and Compilers.
University of Wales Lampeter 2004-2007
Subject: Information Technology and Philosophical Studies BA
Result: First [...]]]></description>
			<content:encoded><![CDATA[<h6><a href="mailto:howard.yeend@gmail.com" target="_self">howard.yeend@gmail.com</a> &#8211; 07790 816291</h6>
<hr />
<p style="margin-top:30px;"><span style="text-decoration: underline;"><strong>Availability</strong></span></p>
<p style="padding-left: 30px;">Not currently seeking work. Sorry!</p>
<p style="margin-top:20px;"><strong><span style="text-decoration: underline;"><span id="more-217"></span>Qualifications</span><br />
</strong></p>
<p style="padding-left: 30px;"><strong>Oxford University <em>2008-2009</em></strong></p>
<p style="padding-left: 60px;"><strong>Subject:</strong><em> Computer Science MSc</em></p>
<p style="padding-left: 60px;"><strong>Result:</strong> <em>Pass, distinction in dissertation.</em></p>
<p style="padding-left: 60px;">My dissertation focused on implementing <a href="http://www.puremango.co.uk/2009/06/adaptive-web-sites/" target="_self">Adaptive Web Sites</a> using machine learning and Ajax. I passed modules including Object Oriented Programming with JAVA, Information Retrieval, Computational Linguistics and Compilers.</p>
<p style="padding-left: 30px;"><strong>University of Wales Lampeter <em>2004-2007</em></strong></p>
<p style="padding-left: 60px;"><strong>Subject:</strong> <em>Information Technology and Philosophical Studies BA</em></p>
<p style="padding-left: 60px;"><strong>Result:</strong> <em>First Class Honours, awarded Lampeter Society Prize for IT</em></p>
<p style="padding-left: 60px;">I undertook modules in Databases, Computer Modelling, Robotics and Ethics. My final project, a game, was written in VB.NET and MSSQL.</p>
<p style="padding-left: 30px;"><strong>Northampton College<em> 1999-2001</em></strong></p>
<p style="padding-left: 60px;">Distinction: City and Guilds &#8220;Computer Programming &#8211; Games &amp; Quizzes&#8221;</p>
<p style="padding-left: 60px;">Pass: City and Guilds &#8220;Computer Programming &#8211; Business Applications&#8221;</p>
<p style="padding-left: 30px;"><strong>Pitsford Independent School<em> 1995-1998</em></strong></p>
<p style="padding-left: 60px;">9 GCSEs: Physics (B), English Lit (B), English Lang (B), German (B), French (B), Maths (C), Chemistry (C), Biology (C), Geography (C).</p>
<p><strong><span style="text-decoration: underline;">Commercial Experience</span></strong></p>
<p style="padding-left: 30px;"><strong>GG.com / Twist Digital Media: <em>Feb 2010-current</em></strong></p>
<p style="padding-left: 60px;"><strong>Job Title:</strong> Web Developer</p>
<p style="padding-left: 60px;">Returning to my previous role as a web developer, I am developing new products in javascript/json/xul, object oriented PHP 5 and mySQL.</p>
<p style="padding-left: 30px;"><strong>Web Office Systems: <em>Oct 2009-Feb 2010</em></strong></p>
<p style="padding-left: 60px;"><strong>Job Title:</strong> Web Developer</p>
<p style="padding-left: 60px;">Here I was responsible for developing and maintaining business oriented web applications and web services (SaaS) using PHP, mySQL, XML-RPC and Ajax, as well as performing routine linux server maintenance.</p>
<p style="padding-left: 30px;"><strong>GG.com / Twist Digital Media: </strong><strong><em>2007-2008 </em><br />
</strong></p>
<p style="padding-left: 60px;"><strong> Job Title:</strong> Web Developer</p>
<p style="padding-left: 60px;">Primarily developing in PHP5/mySQL, this role was split 70/30 between maintaining existing systems and R&amp;D for new business directions. The company was looking to expand its web offerings with new in-browser betting games. I provided extensive input on technical feasibility for new projects, as well as being actively sought for my ideas for new business directions. During my time at GG, I redeveloped a javascript bet calculator which was deemed worthy of spinning off to a standalone website in its own right. I wrote a Firefox extension and Internet Explorer plugin for this calculator which allows people to use their sidebar to calculate bets while on other websites.</p>
<p style="padding-left: 30px;"><strong>Freetimers Ltd / Poulson Enterprises Group: </strong><em><strong>2001-2005</strong></em></p>
<p style="padding-left: 60px;"><strong> Job Titles:</strong> Internet Programmer, Senior Database Programmer</p>
<p style="padding-left: 60px;"><strong> </strong></p>
<p style="padding-left: 60px;">My role at Freetimers progressed rapidly from a junior technical role to being the primary designer and maintainer of the flagship product, Freedom<sup>TM</sup>. At Freetimers, I was instrumental in the design and continued development of all technical products now offered to clients. These products include a multi-lingual, multi-website content management system, a web-managed stock control system including ecommerce, and web-based bulk email software, as well as the multi-user admin shell.</p>
<p style="padding-left: 60px;">When I first started, Freetimers websites were produced from scratch on a per-client basis. My ideas and technical expertise allowed me to create standard, re-usable and upgradable modules that enabled Freetimers to massively reduce development time and continually improve the products offered to clients. I also managed a small number of junior developers, and brought their skill level forwards; under my supervision, a web graphics designer also became a html developer, and a html/PHP developer became a PHP/mySQL developer.</p>
<p><strong><span style="text-decoration: underline;">General IT Skills</span></strong></p>
<ul style="padding-left: 30px;">
<li>Standards-Compliant HTML / JavaScript / jQuery / dHTML / Ajax / JSON / &#8220;web2.0 technologies&#8221;</li>
<li>Object Oriented PHP5, PHP4</li>
<li>MySQL</li>
<li>VBA, VB6, VB.NET</li>
<li>Excellent SEO ability; this PHP resumé is ranked in the top results for &#8220;<a href="http://www.google.com/search?q=php+cv" target="_blank">php CV</a>&#8221; and &#8220;<a href="http://www.google.com/search?q=programmer+cv" target="_blank">programmer CV</a>&#8220;.</li>
<li>Firefox extensions, greasemonkey scripts, MSIE plugins</li>
<li>Apache administration under both Windows and Linux</li>
<li>My work on CAPTCHA security has been cited by <a href="http://www.w3.org/TR/turingtest/" target="_blank">w3.org</a></li>
<li>My GPL PHP CAPTCHA script was used by Apple and Mozilla, among others.</li>
<li>One of my PHP scripts has an average rating of 4½/5 from 100+ reviewers on <a href="http://www.hotscripts.com/listing/easygraph/#PublisherInfo" target="_blank">hotscripts.net</a>.</li>
<li>I have some experience with MSSQL/SQL Server and Linux server administration using putty/SSH.</li>
</ul>
<p><strong><span style="text-decoration: underline;">Personal Statement</span></strong></p>
<p style="padding-left: 30px;">I am a highly motivated individual who thrives on interesting challenges and works best under pressure. I enjoy varied work and am deeply interested in all aspects of computer technology.</p>
<p style="padding-left: 30px;">My interests include machine learning, responsive UI design, and programming involving images. I also enjoy photography and science fiction. I am also a keen swimmer and collect robots and swiss army knives.</p>
<p style="padding-left: 30px;">In addition to <a href="http://www.puremango.co.uk" target="_self">puremango.co.uk</a>, I also maintain <a href="http://www.thingsinbooks.com" target="_self">thingsinbooks.com</a> and <a href="http://www.gifexplode.com" target="_blank">gifexplode.com</a>.</p>
<p><em>References available on request.</em></p>
]]></content:encoded>
			<wfw:commentRss>http://www.puremango.co.uk/2009/08/php-cv/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP error handling</title>
		<link>http://www.puremango.co.uk/2009/07/php-error-handling/</link>
		<comments>http://www.puremango.co.uk/2009/07/php-error-handling/#comments</comments>
		<pubDate>Sun, 05 Jul 2009 11:59:44 +0000</pubDate>
		<dc:creator>Howard Yeend</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[debug_backtrace]]></category>
		<category><![CDATA[error]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[trigger_error]]></category>

		<guid isPermaLink="false">http://www.puremango.co.uk/?p=548</guid>
		<description><![CDATA[Does this type of error handling code look familiar?

function doFunction&#40;$var&#41; &#123;
	if&#40;is_numeric&#40;$var&#41;&#41; &#123;
		/* do some stuff*/
	&#125; else &#123;
		return -1;
	&#125;
&#125;

BLEH. How ugly is that? There&#8217;s no indication whether -1 is actually an error or a valid return value, or what it means. And other functions might use false to indicate errors so there&#8217;s inconsistency. So I&#8217;ve written [...]]]></description>
			<content:encoded><![CDATA[<p>Does this type of error handling code look familiar?</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> doFunction<span style="color: #009900;">&#40;</span><span style="color: #000088;">$var</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">is_numeric</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$var</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #666666; font-style: italic;">/* do some stuff*/</span>
	<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">return</span> <span style="color: #339933;">-</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>BLEH. How ugly is that? There&#8217;s no indication whether -1 is actually an error or a valid return value, or what it means. And other functions might use false to indicate errors so there&#8217;s inconsistency. So I&#8217;ve written a very simple function to help you give meaningful PHP error messages.<br />
<span id="more-548"></span></p>
<p>Now, PHP already comes with a built-in function for reporting errors, called <a href="http://uk.php.net/manual/en/function.trigger-error.php" target="_blank">&#8220;trigger_error&#8221;</a>. But trigger_error always reports the line and file that trigger_error was called on. Which isn&#8217;t very useful.</p>
<p>For example:</p>
<p>main.php:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">include</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'functions.php'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$x</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'test'</span><span style="color: #339933;">;</span>
doFunction<span style="color: #009900;">&#40;</span><span style="color: #000088;">$x</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// line 3</span></pre></div></div>

<p>functions.php:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> doFunction<span style="color: #009900;">&#40;</span><span style="color: #000088;">$var</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">is_numeric</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$var</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #666666; font-style: italic;">/* do some stuff*/</span>
	<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #990000;">trigger_error</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'var must be numeric'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// line 5</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Because we&#8217;re using trigger_error, this will output something like this:</p>
<blockquote>
<p style="padding-left: 60px;"><strong>Notice</strong>:  var must be numeric in <strong></strong><strong>functions.php</strong> on line <strong>5</strong></p>
</blockquote>
<p>Which isn&#8217;t very useful, because really we&#8217;d want to know that main.php:3 was where the error was actually caused.</p>
<p>We&#8217;d really rather see something like this:</p>
<blockquote>
<p style="padding-left: 60px;"><strong>Notice</strong>:  var must be numeric in <strong>doFunction</strong> called from <strong>main.php</strong> on line <strong>3</strong></p>
</blockquote>
<p>Here&#8217;s a function to do just that:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> error<span style="color: #009900;">&#40;</span><span style="color: #000088;">$message</span><span style="color: #339933;">,</span> <span style="color: #000088;">$level</span><span style="color: #339933;">=</span><span style="color: #009900; font-weight: bold;">E_USER_NOTICE</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$caller</span> <span style="color: #339933;">=</span> <span style="color: #990000;">next</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">debug_backtrace</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #990000;">trigger_error</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$message</span><span style="color: #339933;">.</span><span style="color: #0000ff;">' in &lt;strong&gt;'</span><span style="color: #339933;">.</span><span style="color: #000088;">$caller</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'function'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&lt;/strong&gt; called from &lt;strong&gt;'</span><span style="color: #339933;">.</span><span style="color: #000088;">$caller</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'file'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&lt;/strong&gt; on line &lt;strong&gt;'</span><span style="color: #339933;">.</span><span style="color: #000088;">$caller</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'line'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&lt;/strong&gt;'</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&lt;br /&gt;error handler&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$level</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>So now in our example:</p>
<p>main.php:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">include</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'functions.php'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$x</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'test'</span><span style="color: #339933;">;</span>
doFunction<span style="color: #009900;">&#40;</span><span style="color: #000088;">$x</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// line 3</span></pre></div></div>

<p>functions.php:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> doFunction<span style="color: #009900;">&#40;</span><span style="color: #000088;">$var</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">is_numeric</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$var</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #666666; font-style: italic;">/* do some stuff*/</span>
	<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
		error<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'var must be numeric'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// line 5</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> error<span style="color: #009900;">&#40;</span><span style="color: #000088;">$message</span><span style="color: #339933;">,</span> <span style="color: #000088;">$level</span><span style="color: #339933;">=</span><span style="color: #009900; font-weight: bold;">E_USER_NOTICE</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$caller</span> <span style="color: #339933;">=</span> <span style="color: #990000;">next</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">debug_backtrace</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #990000;">trigger_error</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$message</span><span style="color: #339933;">.</span><span style="color: #0000ff;">' in &lt;strong&gt;'</span><span style="color: #339933;">.</span><span style="color: #000088;">$caller</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'function'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&lt;/strong&gt; called from &lt;strong&gt;'</span><span style="color: #339933;">.</span><span style="color: #000088;">$caller</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'file'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&lt;/strong&gt; on line &lt;strong&gt;'</span><span style="color: #339933;">.</span><span style="color: #000088;">$caller</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'line'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&lt;/strong&gt;'</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&lt;br /&gt;error handler&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$level</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// line 11</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>now outputs:</p>
<blockquote>
<p style="padding-left: 60px;"><strong>Notice</strong>:  var must be numeric in <strong>doFunction</strong> called from <strong>main.php</strong> on line <strong>3</strong><br />
error handler in <strong>functions.php</strong> on line <strong>11</strong></p></blockquote>
<p>Isn&#8217;t that much nicer. Why yes, yes it is!</p>
<p>By the way, if you&#8217;re having trouble getting PHP to display error messages, try setting your php.ini&#8217;s error_reporting to E_STRICT (which you should be trying to adhere to anyway), or change $level to E_USER_WARNING</p>
<p>You can also use the E_USER_ERROR constant to halt the PHP interpreter.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.puremango.co.uk/2009/07/php-error-handling/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>PHP 5.3.0 Released!</title>
		<link>http://www.puremango.co.uk/2009/07/php-5-3-0-released/</link>
		<comments>http://www.puremango.co.uk/2009/07/php-5-3-0-released/#comments</comments>
		<pubDate>Wed, 01 Jul 2009 11:38:34 +0000</pubDate>
		<dc:creator>Howard Yeend</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[news]]></category>
		<category><![CDATA[oop]]></category>

		<guid isPermaLink="false">http://www.puremango.co.uk/?p=543</guid>
		<description><![CDATA[If you&#8217;re still stuck in the old PHP 4 days, please please please take today&#8217;s release of PHP 5.3.0 as your cue to start learning about the wonderful world of object oriented PHP 5.
5.3.0 isn&#8217;t a hugely interesting release, but getting your PHP4 code compatible with 5 will ease the process when PHP 6 comes [...]]]></description>
			<content:encoded><![CDATA[<p>If you&#8217;re still stuck in the old PHP 4 days, <em>please please please</em> take today&#8217;s release of PHP 5.3.0 as your cue to start learning about the wonderful world of object oriented PHP 5.</p>
<p>5.3.0 isn&#8217;t a hugely interesting release, but getting your PHP4 code compatible with 5 will ease the process when PHP 6 comes along. <strong>PHP6</strong> is really where it&#8217;s at:</p>
<p><strong>What&#8217;s out:</strong><br />
No more <strong>register_globals</strong> (finally)<br />
No more <strong>magic_quotes</strong> (you kinda liked magic quotes? Admittedly it was handy, but when you think about it, having code that <em>may or may not</em> be sanitised depending on a php.ini setting is a Bad Idea™)<br />
No more <strong>HTTP_GET_VARS</strong> and cousins. Just change to $_GET etc and you&#8217;re fine.</p>
<p><strong>What&#8217;s in:</strong><br />
A bunch of minor fixes aaand:<br />
Namespaces &#8211; so we can section off bits of code properly. Woohoo! <a href="http://php100.wordpress.com/2007/08/17/namespaces-faq/" target="_blank">more info here</a>.</p>
<p>Short post today I know, but I&#8217;ve got some real coding to do :) If you&#8217;re not doing anything better, go download PHP and have a play with it.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.puremango.co.uk/2009/07/php-5-3-0-released/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Google Images Link Improver Wordpress Plugin</title>
		<link>http://www.puremango.co.uk/2009/05/google-images-link-improver-wordpress-plugin/</link>
		<comments>http://www.puremango.co.uk/2009/05/google-images-link-improver-wordpress-plugin/#comments</comments>
		<pubDate>Fri, 01 May 2009 14:24:03 +0000</pubDate>
		<dc:creator>Howard Yeend</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[images]]></category>
		<category><![CDATA[plugins]]></category>
		<category><![CDATA[software]]></category>

		<guid isPermaLink="false">http://www.puremango.co.uk/?p=329</guid>
		<description><![CDATA[Google Images Link Improver improves the way visitors find your site by redirecting hits from google images to more relevant content on your blog.
Here&#8217;s an example of how it works on an actual google images result for &#8220;earthrise&#8221;. The user clicks the following images result:
&#8230; and here&#8217;s how the clickthrough page looks:




 Before Plugin Installation

After [...]]]></description>
			<content:encoded><![CDATA[<p>Google Images Link Improver improves the way visitors find your site by redirecting hits from google images to more relevant content on your blog.</p>
<p>Here&#8217;s an example of how it works on an actual <a href="http://images.google.com/imgres?imgurl=http://aseattlephotographer.files.wordpress.com/2008/11/earthmoon_nasa.jpg&amp;imgrefurl=http://eyeshotjazz.wordpress.com/2008/11/&amp;usg=__zbFN50Ka7vO2i_YiAXP0v5bNe_A=&amp;h=600&amp;w=1267&amp;sz=117&amp;hl=en&amp;start=1&amp;um=1&amp;tbnid=T1cQr4c6em6jrM:&amp;tbnh=71&amp;tbnw=150&amp;prev=/images%3Fq%3Dearthrise%26hl%3Den%26sa%3DG%26um%3D1" target="_blank">google images result</a> for &#8220;earthrise&#8221;. The user clicks the following images result:<img class="aligncenter" src="/earthrise_gi.png" alt="" /><br />
&#8230; and here&#8217;s how the clickthrough page looks:</p>
<table border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td style="text-align: center;"><img src="/earth_before.png" alt="" /><br />
<strong> Before Plugin Installation</strong></td>
<td style="text-align: center;"><img src="/earth_after.png" alt="" /><br />
<strong>After Plugin Installation</strong></td>
</tr>
</tbody>
</table>
<p><span id="more-329"></span></p>
<p>Without the wordpress plugin installed, the user has to scroll through miles of content before they find the image they&#8217;re looking for &#8211; it&#8217;s very likely they&#8217;ll just leave in disgust.</p>
<p>With Google Images Link Improver, the user is shown the relevant image straight away, without ever even knowing they&#8217;ve been redirected!  Improve your search engine optimisation on google images, lower your bounce rate, connect searchers with your content :)</p>
<p><span style="font-size: 12pt;"><strong>Download the <a href="http://www.puremango.co.uk/google_images_link_improver.zip" target="_blank">Google Images Link Improver wordpress plugin.</a></strong></span></p>
<p><strong>Installation</strong></p>
<ol>
<li>Simply extract the zip file<sup> <a href="http://www.7-zip.org/" target="_blank">(how?)</a></sup> and upload the files to your wordpress blog<sup> <a href="http://fireftp.mozdev.org/" target="_blank">(how?)</a></sup>, in the following folder: /wp-content/plugins/<br />
<span style="color: white;">.</span></li>
<li>Now log in to your wordpress admin dashboard, and navigate to the plugins menu (yourdomain.com/wp-admin/plugins.php).<span style="color: white;">.</span><br />
Under &#8220;Inactive Plugins&#8221;, you&#8217;ll see an entry for &#8220;Google Images Link Improver&#8221;, something like this:<br />
<span style="color: white;">.</span><br />
<img src="/gili_plugin.png" alt="" /></li>
<li>Click &#8220;Activate&#8221;</li>
</ol>
<p><strong>That&#8217;s IT!</strong></p>
<p>Now when your blog recieves a hit from google images, the Google Images Link Improver wordpress plugin will examine the keywords and image filename from google images and redirect the user to the search page with those terms as the query, thus ensuring that the user is taken to the most relevant page on your blog.</p>
<p>There are some settings you can use to change the way Google Images Link Improver redirects users:</p>
<p>If the user searched Google Images for &#8220;cute puppy pictures&#8221; and found &#8220;bobby_the_wonder_dog_231.jpg&#8221; from your site, then:</p>
<ul style="list-style-type: disc;">
<li>Using <em>Original Google Query</em> &#8211; The user is taken to your search page with the query &#8220;cute puppy pictures&#8221;.</li>
<li>Using <em>Filename (exact)</em> &#8211; The user is taken to your search page with the query &#8220;bobby_the_wonder_dog_231&#8243;.</li>
<li>Using <em>Filename (as query)</em> &#8211; The user is taken to your search page with the query &#8220;bobby the wonder dog&#8221;.</li>
</ul>
<p>I recommend using <em>Filename (exact)<em>, </em></em>but you can adjust it to better suit your own blog.</p>
<p>If you find the plugin useful, why not write up a quick post about it, links are always appreciated! :D</p>
]]></content:encoded>
			<wfw:commentRss>http://www.puremango.co.uk/2009/05/google-images-link-improver-wordpress-plugin/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP ImageStringRight / Center / Italic</title>
		<link>http://www.puremango.co.uk/2009/04/php-imagestringright-center-italic/</link>
		<comments>http://www.puremango.co.uk/2009/04/php-imagestringright-center-italic/#comments</comments>
		<pubDate>Fri, 24 Apr 2009 13:35:26 +0000</pubDate>
		<dc:creator>Howard Yeend</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[dropshadow]]></category>
		<category><![CDATA[effects]]></category>
		<category><![CDATA[imagecreate]]></category>
		<category><![CDATA[images]]></category>
		<category><![CDATA[imagestring]]></category>
		<category><![CDATA[italic]]></category>
		<category><![CDATA[right]]></category>
		<category><![CDATA[underline]]></category>

		<guid isPermaLink="false">http://www.puremango.co.uk/?p=310</guid>
		<description><![CDATA[PHP&#8217;s built-in ImageString function is OK, but I often find it lacking some of the basic features you&#8217;d expect. So I&#8217;ve created ImageStringRight, ImageStringCenter, ImageStringItalic, and a few other goodies for writing text to images in PHP.
Demo and source code after the break!

Live Demo: PHP ImageString Demo
ImageString Source Code
The source contains code and usage examples [...]]]></description>
			<content:encoded><![CDATA[<p>PHP&#8217;s built-in <a href="http://www.php.net/imagestring" target="_blank">ImageString</a> function is OK, but I often find it lacking some of the basic features you&#8217;d expect. So I&#8217;ve created ImageStringRight, ImageStringCenter, ImageStringItalic, and a few other goodies for writing text to images in PHP.</p>
<div class="wp-caption alignnone" style="width: 460px"><img title="Image String Enhanced!" src="http://www.puremango.co.uk/imagestring.png" alt="PHP ImageString Enhanced!" width="450" height="400" /><p class="wp-caption-text">Image String Enhanced!</p></div>
<p>Demo and source code after the break!<br />
<span id="more-310"></span></p>
<p>Live Demo: <a href="http://www.puremango.co.uk/imagestring.php" target="_blank">PHP ImageString Demo</a></p>
<p><a href="http://www.puremango.co.uk/imagestring.phps" target="_blank">ImageString Source Code</a></p>
<p>The source contains code and usage examples for the following enhanced PHP Image String functions:</p>
<ul>
<li><strong>ImageStringRight</strong>: Creates a right-aligned string</li>
<li><strong>ImageStringCenter</strong>: Creates a string centered on the x-axis</li>
<li><strong>ImageStringUnderlined</strong>: Underlines ImageString!</li>
<li><strong>ImageStringItalic</strong>: Write a string in italics onto an image</li>
<li><strong>ImageStringShadow</strong>: Write a string with a dropshadow onto an image</li>
</ul>
<p>They even work with fonts you load via <a href="http://www.php.net/imageloadfont" target="_blank">ImageLoadFont</a>, which is pretty awesome!</p>
<p>You can <em>even</em> nest effects, to create for instance, right-aligned italic strings with a drop shadow!</p>
<p>There&#8217;s an optional final parameter on each function, $ImageString, which contains a string representing the function to use to write the string. So for instance, if we want to write a right-aligned string in italics, we can use the following code:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">ImageStringRight<span style="color: #009900;">&#40;</span><span style="color: #000088;">$image</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">5</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">25</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'Right + Italic'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$col</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">5</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'ImageStringItalic'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Where:</p>
<ul>
<li>$image is the result of an ImageCreate or ImageCreateTrueColor call</li>
<li>5 is the font to use</li>
<li>25 is the y-offset (i.e. how far down the image the string is to be written)</li>
<li>$col is the color to write the text in</li>
<li>5 is an offset from the right (otherwise the string will be right up against the edge of the image)</li>
<li>and finally we send &#8220;ImageStringItalic&#8221; as the ImageString function, so that ImageStringRight creates a right-aligned string using ImageStringItalic.</li>
</ul>
<p>To nest more than two effects (eg right-aligned, italic and underlined), you&#8217;ll need to create a &#8220;helper&#8221; function, for instance like so:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> ImageStringItalicUnderlined<span style="color: #009900;">&#40;</span><span style="color: #000088;">$image</span><span style="color: #339933;">,</span> <span style="color: #000088;">$font</span><span style="color: #339933;">,</span> <span style="color: #000088;">$x</span><span style="color: #339933;">,</span> <span style="color: #000088;">$y</span><span style="color: #339933;">,</span> <span style="color: #000088;">$str</span><span style="color: #339933;">,</span> <span style="color: #000088;">$col</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	ImageStringItalic<span style="color: #009900;">&#40;</span><span style="color: #000088;">$image</span><span style="color: #339933;">,</span> <span style="color: #000088;">$font</span><span style="color: #339933;">,</span> <span style="color: #000088;">$x</span><span style="color: #339933;">,</span> <span style="color: #000088;">$y</span><span style="color: #339933;">,</span> <span style="color: #000088;">$str</span><span style="color: #339933;">,</span> <span style="color: #000088;">$col</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">2</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'ImageStringUnderlined'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Then you can use that helper function as the &#8220;$ImageString&#8221; parameter to ImageStringRight, like so:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">ImageStringRight<span style="color: #009900;">&#40;</span><span style="color: #000088;">$image</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">5</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">10</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'Nested Effects'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$red</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'ImageStringItalicUnderlined'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>The PHP source code contains quite a few examples, but if you can&#8217;t get the effect you&#8217;re looking for just drop a comment here and I&#8217;ll help you out :D</p>
]]></content:encoded>
			<wfw:commentRss>http://www.puremango.co.uk/2009/04/php-imagestringright-center-italic/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>PHP 4/5 Image Blur</title>
		<link>http://www.puremango.co.uk/2009/04/php-4-and-5-image-blur/</link>
		<comments>http://www.puremango.co.uk/2009/04/php-4-and-5-image-blur/#comments</comments>
		<pubDate>Tue, 21 Apr 2009 18:39:34 +0000</pubDate>
		<dc:creator>Howard Yeend</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[blur]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[ImageConvolution]]></category>
		<category><![CDATA[ImageCopyMerge]]></category>
		<category><![CDATA[imagecreate]]></category>
		<category><![CDATA[images]]></category>

		<guid isPermaLink="false">http://www.puremango.co.uk/?p=290</guid>
		<description><![CDATA[It&#8217;s not something that people require very often, but occasionally the need does arise and you have to ask: how do I blur an image in PHP? Here is some PHP ImageBlur code that works on PHP4 and 5.
What we end up with is a small fast function that can take a source image and [...]]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s not something that people require very often, but occasionally the need does arise and you have to ask: how do I blur an image in PHP? Here is some <strong>PHP ImageBlur</strong> code that works on PHP4 and 5.</p>
<p>What we end up with is a small fast function that can take a source image and create something like the following:</p>
<table border="0">
<tbody>
<tr>
<td><img src="/blur_before.png" alt="" /><br />
No Blur</td>
<td><img src="/blur_php5.png" alt="" /><br />
PHP5 ImageConvolution</td>
</tr>
<tr>
<td><img src="/blur_before.png" alt="" /><br />
No Blur</td>
<td><img src="/blur_php4.png" alt="" /><br />
PHP4 myImageBlur</td>
</tr>
</tbody>
</table>
<p>In PHP 5 you can just use <a href="http://www.php.net/function.imageconvolution" target="_blank">ImageConvolution</a> and the code example right out of the manual:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$gaussian</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color:#800080;">1.0</span><span style="color: #339933;">,</span> <span style="color:#800080;">2.0</span><span style="color: #339933;">,</span> <span style="color:#800080;">1.0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color:#800080;">2.0</span><span style="color: #339933;">,</span> <span style="color:#800080;">4.0</span><span style="color: #339933;">,</span> <span style="color:#800080;">2.0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color:#800080;">1.0</span><span style="color: #339933;">,</span> <span style="color:#800080;">2.0</span><span style="color: #339933;">,</span> <span style="color:#800080;">1.0</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">ImageConvolution</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$image</span><span style="color: #339933;">,</span> <span style="color: #000088;">$gaussian</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">16</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>That&#8217;s a nice Gaussian blur in PHP5 for you. But what about your nasty old PHP4 servers? I have the answer. Actually the answer is probably &#8220;use ImageMagick and a system call&#8221;, but if you want a pure PHP/GD solution, read on.</p>
<p>Using a crafty mix of voodoo and <a href="http://uk3.php.net/function.ImageCopyMerge" target="_blank">ImageCopyMerge</a>, you can create a PHP 4 blur effect that is virtually identical to the PHP5 method, as you can see by comparing the results of myImageBlur with ImageConvolution above. In tests on my local server, my method takes on average 0.43 seconds to blur a 1024*768 image, while ImageConvolution takes 0.40 &#8211; so it&#8217;s basically the same, and half a second to blur a desktop sized image is pretty decent &#8211; on a live server it&#8217;ll be even faster!</p>
<p>There&#8217;s some more comparisons and the source code after the break:<br />
<span id="more-290"></span></p>
<p>On the PHP ImageConvolution manual page, there&#8217;s a nice example of how it looks with text, so here&#8217;s a comparison of the two techniques:</p>
<table>
<tr>
<td><img src="/blur_text_1.png"><br />ImageConvolution</td>
<td><img src="/blur_text_2.png"><br />myImageBlur</td>
</tr>
</table>
<p>And here&#8217;s how it looks with a hedgehog :)</p>
<table border="0">
<tbody>
<tr>
<td><img src="/blur_before2.png" alt="" /><br />
No Blur</td>
<td><img src="/blur_php5_2.png" alt="" /><br />
PHP5 ImageConvolution</td>
</tr>
<tr>
<td><img src="/blur_before2.png" alt="" /><br />
No Blur</td>
<td><img src="/blur_php4_2.png" alt="" /><br />
PHP4 myImageBlur</td>
</tr>
</tbody>
</table>
<p>That&#8217;s all there is to it really. Drop this function into your PHP library and off you go blurring images with PHP. You can use myImageBlur whether you&#8217;re on PHP4 or 5 and it will apply the best function; using ImageConvolution if available, else using my own voodoo-ninja PHP code. It runs pretty quickly too.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> myImageBlur<span style="color: #009900;">&#40;</span><span style="color: #000088;">$im</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #666666; font-style: italic;">// http://www.puremango.co.uk/2009/04/php-4-and-5-image-blur/</span>
	<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">function_exists</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'imageconvolution'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$gaussian</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color:#800080;">1.0</span><span style="color: #339933;">,</span> <span style="color:#800080;">2.0</span><span style="color: #339933;">,</span> <span style="color:#800080;">1.0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color:#800080;">2.0</span><span style="color: #339933;">,</span> <span style="color:#800080;">4.0</span><span style="color: #339933;">,</span> <span style="color:#800080;">2.0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color:#800080;">1.0</span><span style="color: #339933;">,</span> <span style="color:#800080;">2.0</span><span style="color: #339933;">,</span> <span style="color:#800080;">1.0</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #990000;">imageconvolution</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$im</span><span style="color: #339933;">,</span> <span style="color: #000088;">$gaussian</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">16</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #666666; font-style: italic;">// w00t. my very own blur function!</span>
		<span style="color: #000088;">$width</span> <span style="color: #339933;">=</span> <span style="color: #990000;">imagesx</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$im</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$height</span> <span style="color: #339933;">=</span> <span style="color: #990000;">imagesy</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$im</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">// the higher, the more blurred (no impact on speed)</span>
		<span style="color: #666666; font-style: italic;">// however, values&gt;2 don't look very good. Sorry.</span>
		<span style="color: #000088;">$distance</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #000088;">$temp_im</span> <span style="color: #339933;">=</span> <span style="color: #990000;">ImageCreateTrueColor</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$width</span><span style="color: #339933;">,</span><span style="color: #000088;">$height</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #990000;">ImageCopy</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$temp_im</span><span style="color: #339933;">,</span><span style="color: #000088;">$im</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span><span style="color: #000088;">$width</span><span style="color: #339933;">,</span><span style="color: #000088;">$height</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #666666; font-style: italic;">/*
		we *could* use this: 
		ImageCopy($temp_im,$im,0,0,0,$distance,$width,$height);
		instead, but that leads to an anomally at the top of the image.		
		*/</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">// blur by merging with itself at different x/y offsets:</span>
		<span style="color: #000088;">$pct</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">70</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// based on empirical tests, 70% gives the most blur.</span>
		<span style="color: #990000;">ImageCopyMerge</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$temp_im</span><span style="color: #339933;">,</span> <span style="color: #000088;">$im</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #000088;">$distance</span><span style="color: #339933;">,</span> <span style="color: #000088;">$width</span><span style="color: #339933;">-</span><span style="color: #000088;">$distance</span><span style="color: #339933;">,</span> <span style="color: #000088;">$height</span><span style="color: #339933;">-</span><span style="color: #000088;">$distance</span><span style="color: #339933;">,</span> <span style="color: #000088;">$pct</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #990000;">ImageCopyMerge</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$im</span><span style="color: #339933;">,</span> <span style="color: #000088;">$temp_im</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #000088;">$distance</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #000088;">$width</span><span style="color: #339933;">-</span><span style="color: #000088;">$distance</span><span style="color: #339933;">,</span> <span style="color: #000088;">$height</span><span style="color: #339933;">,</span> <span style="color: #000088;">$pct</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #990000;">ImageCopyMerge</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$temp_im</span><span style="color: #339933;">,</span> <span style="color: #000088;">$im</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #000088;">$distance</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #000088;">$width</span><span style="color: #339933;">,</span> <span style="color: #000088;">$height</span><span style="color: #339933;">,</span> <span style="color: #000088;">$pct</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #990000;">ImageCopyMerge</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$im</span><span style="color: #339933;">,</span> <span style="color: #000088;">$temp_im</span><span style="color: #339933;">,</span> <span style="color: #000088;">$distance</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #000088;">$width</span><span style="color: #339933;">,</span> <span style="color: #000088;">$height</span><span style="color: #339933;">,</span> <span style="color: #000088;">$pct</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">// remove temp image</span>
		<span style="color: #990000;">ImageDestroy</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$temp_im</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// usage:</span>
<span style="color: #000088;">$im</span> <span style="color: #339933;">=</span> <span style="color: #990000;">ImageCreateFromPNG</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'/path/to/file.png'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
myImageBlur<span style="color: #009900;">&#40;</span><span style="color: #000088;">$im</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #990000;">header</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Content-type: image/png'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">ImagePng</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$im</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">ImageDestroy</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$im</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Most of the code on puremango is GPL, but this function is 100% free (as in, no strings attached) , but I do appreciate links and blog posts :D</p>
]]></content:encoded>
			<wfw:commentRss>http://www.puremango.co.uk/2009/04/php-4-and-5-image-blur/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>PHP Digital Camouflage</title>
		<link>http://www.puremango.co.uk/2009/04/php-digital-camouflage/</link>
		<comments>http://www.puremango.co.uk/2009/04/php-digital-camouflage/#comments</comments>
		<pubDate>Mon, 20 Apr 2009 14:07:26 +0000</pubDate>
		<dc:creator>Howard Yeend</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[camo]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[imagecreate]]></category>
		<category><![CDATA[images]]></category>
		<category><![CDATA[phpdemoscene]]></category>

		<guid isPermaLink="false">http://www.puremango.co.uk/?p=275</guid>
		<description><![CDATA[The other day I was looking at demoscene videos on youtube (do yourself a favour and watch it!) and it made me think back to my PHP image hacking days. One thing led to another and I ended up saying to my partner Linds that I&#8217;d write her a little PHP demo. 3 hours later, [...]]]></description>
			<content:encoded><![CDATA[<p>The other day I was looking at <a href="http://www.youtube.com/watch?v=u4gjR30aeEc">demoscene videos</a> on youtube (do yourself a favour and watch it!) and it made me think back to my <a href="http://www.puremango.co.uk/2009/03/3d_php/">PHP image hacking days</a>. One thing led to another and I ended up saying to my partner Linds that I&#8217;d write her a little PHP demo. 3 hours later, I had digital camo in PHP (click the images for an online demo; refresh to cycle through the different types):</p>
<table border="0">
<tbody>
<tr>
<td><a href="/camo.php" target="_blank"><img src="http://www.puremango.co.uk/camo_woodland.png" alt="Woodland Digital Camo" /></a></td>
<td><a href="/camo.php" target="_blank"><img src="http://www.puremango.co.uk/camo_urban.png" alt="Urban Digital Camo" /></a></td>
</tr>
<tr>
<td><a href="/camo.php" target="_blank"><img src="http://www.puremango.co.uk/camo_desert.png" alt="Desert Digital Camo" /></a></td>
<td><a href="/camo.php" target="_blank"><img src="http://www.puremango.co.uk/camo_nighttime.png" alt="Nighttime Digital Camo" /></a></td>
</tr>
</tbody>
</table>
<p>The <a href="/camo.php" target="_blank">Online Demo</a> generates larger camo patterns and has a few other camo types; refresh it to cycle through them.</p>
<p><a href="http://www.puremango.co.uk/camo.phps" target="_blank">Download PHP Source</a></p>
<p>Let me know if you find a use for this code :)</p>
<p>After the break, I go into the detail of how the code is constructed, and you get a funky debug image too!<br />
<span id="more-275"></span></p>
<p>Ok, so the code isn&#8217;t as pretty as it could be, but it&#8217;s good enough for me to publish, and I&#8217;m confident that it would only take an hour or two to clean it up.</p>
<p>Here&#8217;s that debug image I promised you:</p>
<p><img src="http://www.puremango.co.uk/camo_woodland_debug.png" alt="Debug Camo" /></p>
<p>The background fill colour is usually chosen from one of the preset camo colours, but in debug mode we make it blue. This helped me make sure that there wasn&#8217;t too much background showing through in the final image.</p>
<p>We then draw patches of camo in a randomly chosen camo colour. The patches are drawn in a grid covering in the entire image; each patch begins at one of the red dots in the debug image. We randomly deviate the positions of the patches a little to keep it from being too regular. We also have the patches start and end a little outside the boundary of the final image, to ensure that we don&#8217;t get a lot of background colour showing around the edges.</p>
<p>A patch is actually just a big square made of lots of little squares of the same colour. We make the patches irregular by a) randomly altering the dimensions of each patch, and more importantly b) on the outside edge of the patch, we sometimes don&#8217;t draw a square, so the patches end up looking like this, instead of a regular square:</p>
<p><img src="http://www.puremango.co.uk/camo_one_patch.png" alt="One Patch" /></p>
<p>Once we&#8217;ve created the whole camo pattern, we blur the whole image. Below is a before/after comparison showing the effect of <a href="http://www.puremango.co.uk/2009/04/php-4-and-5-image-blur/" target="_self">myImageBlur</a> (follow the link for an improved PHP image blur function):</p>
<table border="0">
<tbody>
<tr>
<td><img src="http://www.puremango.co.uk/camo_before_blur.png" alt="Before Blur" /><br />
Before Blur</td>
<td><img src="http://www.puremango.co.uk/camo_after_blur.png" alt="After Blur" /><br />
After Blur</td>
</tr>
</tbody>
</table>
<p>If you want to go deeper, the code is fairly well commented :)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.puremango.co.uk/2009/04/php-digital-camouflage/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
