<?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>ifwebstudio blog &#187; PHP</title>
	<atom:link href="http://blog.ifwebstudio.com/category/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.ifwebstudio.com</link>
	<description>PHP, SEO, Web Design</description>
	<lastBuildDate>Tue, 08 Dec 2009 18:27:48 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Calculate image aspect ratio in PHP</title>
		<link>http://blog.ifwebstudio.com/php/calculate-image-aspect-ratio-in-php/</link>
		<comments>http://blog.ifwebstudio.com/php/calculate-image-aspect-ratio-in-php/#comments</comments>
		<pubDate>Sun, 13 Sep 2009 14:49:00 +0000</pubDate>
		<dc:creator>Ilir Fekaj</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://blog.ifwebstudio.com/?p=13</guid>
		<description><![CDATA[Calculating image aspect ratio in PHP is very simple. First you need to find greatest common divisor(GCD). You can do that by using following function: function GCD($a, $b) { while ($b != 0) $remainder = $a % $b; $a = $b; $b = $remainder; } return abs ($a); } If you compiled your PHP version [...]]]></description>
			<content:encoded><![CDATA[<p>Calculating image aspect ratio in PHP is very simple. First you need to find greatest common divisor(GCD). You can do that by using following function:</p>
<pre name="code" class="php">
function GCD($a, $b) {
while ($b != 0)
$remainder = $a % $b;
$a = $b;
$b = $remainder;
}
return abs ($a);
}
</pre>
<p>If you compiled your PHP version with GMP functions, you can also use following:</p>
<pre name="code" class="php">
$gcd = gmp_gcd($a, $b);
</pre>
<p>After finding GCD, simply divide both sides with it:</p>
<pre name="code" class="php">
$a = 2048; // screen width
$b = 1152; // screen height
$gcd = GCD($a, $b);
$a = $a/$gcd;
$b = $b/$gcd;
$ratio = $a . ":" . $b;
</pre>
<p align="left"><a class="tt" href="http://twitter.com/home/?status=Calculate+image+aspect+ratio+in+PHP+http://iszya.th8.us" title="Post to Twitter"><img class="nothumb" src="http://blog.ifwebstudio.com/wp-content/plugins/tweet-this/icons/tt-twitter.png" alt="Post to Twitter" /></a> <a class="tt" href="http://twitter.com/home/?status=Calculate+image+aspect+ratio+in+PHP+http://iszya.th8.us" title="Post to Twitter">Tweet This Post</a></p>]]></content:encoded>
			<wfw:commentRss>http://blog.ifwebstudio.com/php/calculate-image-aspect-ratio-in-php/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
