<?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>damonky.co.uk &#187; PHP</title>
	<atom:link href="http://www.damonky.co.uk/tag/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.damonky.co.uk</link>
	<description>Just another WordPress weblog</description>
	<lastBuildDate>Sun, 04 Apr 2010 19:31:44 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Getting back into cakePHP</title>
		<link>http://www.damonky.co.uk/uncategorized/getting-back-into-cakephp/</link>
		<comments>http://www.damonky.co.uk/uncategorized/getting-back-into-cakephp/#comments</comments>
		<pubDate>Wed, 11 Jun 2008 12:47:49 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[1.2]]></category>
		<category><![CDATA[cakePHP]]></category>
		<category><![CDATA[Fat models]]></category>
		<category><![CDATA[MVC]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[renderElement]]></category>
		<category><![CDATA[skinny controllers]]></category>
		<category><![CDATA[web development]]></category>

		<guid isPermaLink="false">http://damonky.co.uk/2008/06/getting-back-into-cakephp/</guid>
		<description><![CDATA[I have just started an internal project at work to create a portfolio management system. After several months of Joomla hacking it seems this is my chance to get back into serious development again.
I have gone for cakePHP for the project, as opposed to Codeigniter. Although I have mainly tended towards codeigniter in the past [...]]]></description>
			<content:encoded><![CDATA[<p>I have just started an internal project at work to create a portfolio management system. After several months of Joomla hacking it seems this is my chance to get back into serious development again.</p>
<p>I have gone for <a target="_blank" href="http://www.cakephp.org">cakePHP</a> for the project, as opposed to <a target="_blank" href="http://www.codeigniter.com">Codeigniter</a>. Although I have mainly tended towards codeigniter in the past for applications, It has been a while since i have really used cake i was drawn in by cakePHP&#8217;s features.</p>
<p>One feature i am finding particularly useful is the elements (using renderElement), as a lot of the forms use similar listings. Instead of using requestAction, I load the data into a standard variable (e.g: $campaigns, for campaigns) from either data already loaded or  direct from a custom function in the model. This removes the need to call a particular view from within the element and reduces the bloating of the controller as suggested by the article <a target="_blank" href="http://weblog.jamisbuck.org/2006/10/18/skinny-controller-fat-model">Skinny Controller, Fat Model</a>. </p>
<p>Jamis says:<br />
<blockquote>Be aggressive! Try to keep your controller actions and views as slim as<br />
possible. A one-line action is a thing of wonder, as is a template that<br />
is mostly <span class="caps">HTML</span>. It is also <em>much</em> more maintainable than a view that is full of assignment statements and chained method calls.</p></blockquote>
<p>I have found that this approach has indeed made my life a lot easier, It&#8217;s soo easy to get tangled up in controllers, and sometimes reapeating code when there is simply no need.</p>
<p>I haven&#8217;t tried to understand the paging yet, but based on a couple blogs I&#8217;ve read, it works the same as the find command, although I&#8217;m not sure how paging would work with several tables on the page &#8211; I guess I&#8217;ll find out in the next few days.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.damonky.co.uk/uncategorized/getting-back-into-cakephp/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Resize and crop to best fit function</title>
		<link>http://www.damonky.co.uk/php/resize-and-crop-to-best-fit-function/</link>
		<comments>http://www.damonky.co.uk/php/resize-and-crop-to-best-fit-function/#comments</comments>
		<pubDate>Wed, 28 May 2008 23:13:00 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[cropping]]></category>
		<category><![CDATA[gd]]></category>
		<category><![CDATA[getimagesize]]></category>
		<category><![CDATA[image manipulation]]></category>
		<category><![CDATA[image resizing]]></category>
		<category><![CDATA[imagecopyresampled]]></category>

		<guid isPermaLink="false">http://damonky.co.uk/?p=7</guid>
		<description><![CDATA[Whilst writing several applications i have wanted needed to automate the process of resizing and cropping an image to fit, for example for sites which have catalogues.
After getting just a little bit more than bored of photoshopping 300+ images i decided to write my own function to automate the re-size. The function below will take [...]]]></description>
			<content:encoded><![CDATA[<p>Whilst writing several applications i have <span style="text-decoration: line-through;">wanted</span> needed to automate the process of resizing and cropping an image to fit, for example for sites which have catalogues.</p>
<p>After getting just a little bit more than bored of photoshopping 300+ images i decided to write my own function to automate the re-size. The function below will take a file reference, load the file, find the best fit for the desired output size and crop / re-size  accordingly.</p>
<p><code lang="php">function autoCrop($file, $height, $width){<br />
//load the image file<br />
$img = false;<br />
$img = imagecreatefromjpeg($file);<br />
//quit if not loaded<br />
if(!$img){<br />
return false;<br />
}<br />
//get the image dimensions<br />
$curr = @getimagesize($file);</p>
<p>$perc_w = $width / $curr[0];<br />
$perc_h = $height / $curr[1];</p>
<p>if(($width > $curr[0]) || ($height > $curr[1])){<br />
return;<br />
}</p>
<p>if($perc_h > $perc_w){<br />
//taller<br />
$width = $width;<br />
$height = round($curr[1] * $perc_w);<br />
} else {<br />
//wider<br />
$height = $height;<br />
$width = round($curr[0] * $perc_h);<br />
}<br />
//output<br />
$nwimg = imagecreatetruecolor($width, $height);<br />
imagecopyresampled($nwimg, $img, 0, 0, 0, 0, $width, $height, $curr[0], $curr[1]);<br />
imagejpeg($nwimg, $file);</p>
<p>imagedestroy($nwimg);<br />
imagedestroy($img);</p>
<p>}</code></p>
]]></content:encoded>
			<wfw:commentRss>http://www.damonky.co.uk/php/resize-and-crop-to-best-fit-function/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
