<?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>Mikko's blog &#187; Imagick</title>
	<atom:link href="http://valokuva.org/?feed=rss2&#038;cat=1" rel="self" type="application/rss+xml" />
	<link>http://valokuva.org</link>
	<description>My Thoughts Exactly</description>
	<lastBuildDate>Sat, 19 Sep 2009 12:07:56 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Imagick and Gmagick builds available for Windows</title>
		<link>http://valokuva.org/?p=161</link>
		<comments>http://valokuva.org/?p=161#comments</comments>
		<pubDate>Sat, 19 Sep 2009 03:23:42 +0000</pubDate>
		<dc:creator>Mikko Koppanen</dc:creator>
				<category><![CDATA[Imagick]]></category>
		<category><![CDATA[PHP stuff]]></category>

		<guid isPermaLink="false">http://valokuva.org/?p=161</guid>
		<description><![CDATA[The new Windows build page http://valokuva.org/magick/ contains builds for both Imagick and Gmagick. All builds are done using VC9 and PHP 5.3. ImageMagick builds are QuantumDepth 16 (default). GraphicsMagick builds are QuantumDepth 8 (default). Please note that these builds won&#8217;t work with the official PHP.net binaries which are compiled using VC6. Edit: Pierre corrected me [...]]]></description>
			<content:encoded><![CDATA[<p>The new Windows build page <a href="http://valokuva.org/magick/">http://valokuva.org/magick/</a> contains builds for both Imagick and Gmagick. All builds are done using VC9 and PHP 5.3.</p>
<p>ImageMagick builds are QuantumDepth 16 (default).<br />
GraphicsMagick builds are QuantumDepth 8 (default).</p>
<p>Please note that these builds won&#8217;t work with the official PHP.net binaries which are compiled using VC6.</p>
<p><strong>Edit: </strong> Pierre corrected me that there are official VC9 builds of PHP available at <a href="http://windows.php.net/download/" onclick="urchinTracker('/outgoing/windows.php.net/download/?referer=');">http://windows.php.net/download/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://valokuva.org/?feed=rss2&amp;p=161</wfw:commentRss>
		<slash:comments>15</slash:comments>
		</item>
		<item>
		<title>Perspective transformations</title>
		<link>http://valokuva.org/?p=112</link>
		<comments>http://valokuva.org/?p=112#comments</comments>
		<pubDate>Wed, 04 Feb 2009 20:48:21 +0000</pubDate>
		<dc:creator>Mikko Koppanen</dc:creator>
				<category><![CDATA[Imagick]]></category>
		<category><![CDATA[PHP stuff]]></category>

		<guid isPermaLink="false">http://valokuva.org/?p=112</guid>
		<description><![CDATA[Finally (after a long break) I managed to force myself to update the PHP documentation and this time it was distortImage code example. Things have been hectic lately but that does not quite explain the 6 months(?) break between this and the previous post. As a matter of a fact there is no excuse for [...]]]></description>
			<content:encoded><![CDATA[<p>Finally (after a long break) I managed to force myself to update the PHP documentation and this time it was distortImage code example. Things have been hectic lately but that does not quite explain the 6 months(?) break between this and the previous post. As a matter of a fact there is no excuse for such a long silence so I will try to update this blog a bit more often from now on.</p>
<p>Back in the day I used to blog the examples and update the documentation if I remembered but I am trying to fix this bad habit. Most of the latest examples have been updated in to the manual. In the case of the two last examples I updated the documentation first and then blogged on the subject.</p>
<p>I took some time to actually understand the perspective transformations properly using the excellent <a href="http://imagemagick.org/Usage/distorts/#perspective" onclick="urchinTracker('/outgoing/imagemagick.org/Usage/distorts/_perspective?referer=');">ImageMagick examples</a> (mainly created by Anthony Thyssen) as a reference. The basic idea of perspective distortion seems simple: to distort the control points to new locations. Grabbing the syntax for Imagick was easy, an array of control point pairs in the form of:</p>
<div class="igBar"><span id="lphp-3"><a href="#" onclick="javascript:showCodeTxt('php-3'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-3">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><a href="http://www.php.net/array" onclick="urchinTracker('/outgoing/www.php.net/array?referer=');"><span style="color:#000066;">array</span></a><span style="color:#006600; font-weight:bold;">&#40;</span>source_x, source_y, dest_x, dest_y ... <span style="color:#006600; font-weight:bold;">&#41;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>The following example uses the built-in checkerboard pattern to demonstrate perspective distortion:</p>
<div class="igBar"><span id="lphp-4"><a href="#" onclick="javascript:showCodeTxt('php-4'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-4">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">&lt;?php</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">/* Create new object */</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$im</span> = <span style="color:#000000; font-weight:bold;">new</span> Imagick<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">/* Create new checkerboard pattern */</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$im</span>-&gt;<span style="color:#006600;">newPseudoImage</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC66CC;color:#800000;">100</span>, <span style="color:#CC66CC;color:#800000;">100</span>, <span style="color:#FF0000;">"pattern:checkerboard"</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">/* Set the image format to png */</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$im</span>-&gt;<span style="color:#006600;">setImageFormat</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'png'</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">/* Fill background area with transparent */</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$im</span>-&gt;<span style="color:#006600;">setImageVirtualPixelMethod</span><span style="color:#006600; font-weight:bold;">&#40;</span>Imagick::<span style="color:#006600;">VIRTUALPIXELMETHOD_TRANSPARENT</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">/* Activate matte */</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$im</span>-&gt;<span style="color:#006600;">setImageMatte</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#000000; font-weight:bold;">true</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">/* Control points for the distortion */</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$controlPoints</span> = <a href="http://www.php.net/array" onclick="urchinTracker('/outgoing/www.php.net/array?referer=');"><span style="color:#000066;">array</span></a><span style="color:#006600; font-weight:bold;">&#40;</span> <span style="color:#CC66CC;color:#800000;">10</span>, <span style="color:#CC66CC;color:#800000;">10</span>, </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#CC66CC;color:#800000;">10</span>, <span style="color:#CC66CC;color:#800000;">5</span>,</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#CC66CC;color:#800000;">10</span>, <span style="color:#0000FF;">$im</span>-&gt;<span style="color:#006600;">getImageHeight</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span> - <span style="color:#CC66CC;color:#800000;">20</span>,</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#CC66CC;color:#800000;">10</span>, <span style="color:#0000FF;">$im</span>-&gt;<span style="color:#006600;">getImageHeight</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span> - <span style="color:#CC66CC;color:#800000;">5</span>,</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$im</span>-&gt;<span style="color:#006600;">getImageWidth</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span> - <span style="color:#CC66CC;color:#800000;">10</span>, <span style="color:#CC66CC;color:#800000;">10</span>,</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$im</span>-&gt;<span style="color:#006600;">getImageWidth</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span> - <span style="color:#CC66CC;color:#800000;">10</span>, <span style="color:#CC66CC;color:#800000;">20</span>,</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$im</span>-&gt;<span style="color:#006600;">getImageWidth</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span> - <span style="color:#CC66CC;color:#800000;">10</span>, <span style="color:#0000FF;">$im</span>-&gt;<span style="color:#006600;">getImageHeight</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span> - <span style="color:#CC66CC;color:#800000;">10</span>,</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$im</span>-&gt;<span style="color:#006600;">getImageWidth</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span> - <span style="color:#CC66CC;color:#800000;">10</span>, <span style="color:#0000FF;">$im</span>-&gt;<span style="color:#006600;">getImageHeight</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span> - <span style="color:#CC66CC;color:#800000;">30</span><span style="color:#006600; font-weight:bold;">&#41;</span>; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">/* Perform the distortion */</span>&nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$im</span>-&gt;<span style="color:#006600;">distortImage</span><span style="color:#006600; font-weight:bold;">&#40;</span>Imagick::<span style="color:#006600;">DISTORTION_PERSPECTIVE</span>, <span style="color:#0000FF;">$controlPoints</span>, <span style="color:#000000; font-weight:bold;">true</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">/* Ouput the image */</span>&nbsp; &nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><a href="http://www.php.net/header" onclick="urchinTracker('/outgoing/www.php.net/header?referer=');"><span style="color:#000066;">header</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">"Content-Type: image/png"</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><a href="http://www.php.net/echo" onclick="urchinTracker('/outgoing/www.php.net/echo?referer=');"><span style="color:#000066;">echo</span></a> <span style="color:#0000FF;">$im</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">?&gt;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Here is the source image:<br />
<img src="http://valokuva.org/wp-content/uploads/2009/02/checker.png" alt="checker before" /></p>
<p>And the result:<br />
<img src="http://valokuva.org/wp-content/uploads/2009/02/checkerboard.png" alt="after" /></p>
]]></content:encoded>
			<wfw:commentRss>http://valokuva.org/?feed=rss2&amp;p=112</wfw:commentRss>
		<slash:comments>33</slash:comments>
		</item>
		<item>
		<title>Fill patterns</title>
		<link>http://valokuva.org/?p=102</link>
		<comments>http://valokuva.org/?p=102#comments</comments>
		<pubDate>Sat, 26 Apr 2008 09:15:28 +0000</pubDate>
		<dc:creator>Mikko Koppanen</dc:creator>
				<category><![CDATA[Imagick]]></category>
		<category><![CDATA[PHP stuff]]></category>

		<guid isPermaLink="false">http://valokuva.org/?p=102</guid>
		<description><![CDATA[My work life has been quite busy lately and I haven't had a chance to sit down and blog. I have been touring around London and some parts of the northern England consulting and organizing some training here and there. Luckily I have had the chance to do some work on Imagick and the 2.2.0 [...]]]></description>
			<content:encoded><![CDATA[<p>My work life has been quite busy lately and I haven't had a chance to sit down and blog. I have been touring around London and some parts of the northern England consulting and organizing some training here and there. Luckily I have had the chance to do some work on Imagick and the 2.2.0 beta release is getting closer. The internal structure was completely restructured and broken down into several smaller files. During this time Imagick was adapted to follow the PHP Coding Standards more closely. Still a work in progress <img src='http://valokuva.org/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>I committed slightly modified version of this example to PHP Manual <a href="http://uk.php.net/manual/en/imagick.examples.php" onclick="urchinTracker('/outgoing/uk.php.net/manual/en/imagick.examples.php?referer=');">http://uk.php.net/manual/en/imagick.examples.php</a> page a few days ago. The example illustrates using an image as a part of a named fill pattern. The fill pattern is used to annotate text but the named pattern could also be used to fill any shapes that allow fill to be specified (include circles, ellipses, rectangles, polygons etc etc). The code itself is pretty straight forward: Read the image, create the pattern and use the pattern as a fill.</p>
<p>The ice formations image is from <a href="http://www.photoeverywhere.co.uk/west/winterholiday/slides/iceformations5679.htm" onclick="urchinTracker('/outgoing/www.photoeverywhere.co.uk/west/winterholiday/slides/iceformations5679.htm?referer=');">http://www.photoeverywhere.co.uk/west/winterholiday/slides/iceformations5679.htm</a>.</p>
<div class="igBar"><span id="lphp-6"><a href="#" onclick="javascript:showCodeTxt('php-6'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-6">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">&lt;?php</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">/* Create a new imagick object */</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$im</span> = <span style="color:#000000; font-weight:bold;">new</span> Imagick<span style="color:#006600; font-weight:bold;">&#40;</span> <span style="color:#FF0000;">'iceformations5679.JPG'</span> <span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">/* Create imagickdraw object */</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$draw</span> = <span style="color:#000000; font-weight:bold;">new</span> ImagickDraw<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">/* Start a new pattern called &quot;ice&quot; */</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$draw</span>-&gt;<span style="color:#006600;">pushPattern</span><span style="color:#006600; font-weight:bold;">&#40;</span> <span style="color:#FF0000;">'ice'</span>&nbsp; , <span style="color:#CC66CC;color:#800000;">0</span>&nbsp; , <span style="color:#CC66CC;color:#800000;">0</span>&nbsp; , <span style="color:#CC66CC;color:#800000;">50</span>&nbsp; , <span style="color:#CC66CC;color:#800000;">50</span> <span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">/* Composite the image on the pattern */</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$draw</span>-&gt;<span style="color:#006600;">composite</span><span style="color:#006600; font-weight:bold;">&#40;</span> Imagick::<span style="color:#006600;">COMPOSITE_OVER</span>, <span style="color:#CC66CC;color:#800000;">0</span>, <span style="color:#CC66CC;color:#800000;">0</span>, <span style="color:#CC66CC;color:#800000;">50</span>, <span style="color:#CC66CC;color:#800000;">50</span>, <span style="color:#0000FF;">$im</span> <span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">/* Close the pattern */</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$draw</span>-&gt;<span style="color:#006600;">popPattern</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">/* Use the pattern called &quot;ice&quot; as the fill */</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$draw</span>-&gt;<span style="color:#006600;">setFillPatternURL</span><span style="color:#006600; font-weight:bold;">&#40;</span> <span style="color:#FF0000;">'#ice'</span> <span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">/* Set font size to 52 */</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$draw</span>-&gt;<span style="color:#006600;">setFontSize</span><span style="color:#006600; font-weight:bold;">&#40;</span> <span style="color:#CC66CC;color:#800000;">52</span> <span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">/* Annotate some text */</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$draw</span>-&gt;<span style="color:#006600;">annotation</span><span style="color:#006600; font-weight:bold;">&#40;</span> <span style="color:#CC66CC;color:#800000;">5</span>, <span style="color:#CC66CC;color:#800000;">50</span>, <span style="color:#FF0000;">"Hello World!"</span> <span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">/* Create a new canvas and white image */</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$canvas</span> = <span style="color:#000000; font-weight:bold;">new</span> Imagick<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$canvas</span>-&gt;<span style="color:#006600;">newImage</span><span style="color:#006600; font-weight:bold;">&#40;</span> <span style="color:#CC66CC;color:#800000;">310</span>, <span style="color:#CC66CC;color:#800000;">70</span>, <span style="color:#FF0000;">"white"</span> <span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">/* Add black border around the resulting image */</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$canvas</span>-&gt;<span style="color:#006600;">borderImage</span><span style="color:#006600; font-weight:bold;">&#40;</span> <span style="color:#FF0000;">'black'</span>, <span style="color:#CC66CC;color:#800000;">1</span>, <span style="color:#CC66CC;color:#800000;">1</span> <span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">/* Draw the ImagickDraw on to the canvas */</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$canvas</span>-&gt;<span style="color:#006600;">drawImage</span><span style="color:#006600; font-weight:bold;">&#40;</span> <span style="color:#0000FF;">$draw</span> <span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">/* Set the format to PNG */</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$canvas</span>-&gt;<span style="color:#006600;">setImageFormat</span><span style="color:#006600; font-weight:bold;">&#40;</span> <span style="color:#FF0000;">'png'</span> <span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">/* Output the image */</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><a href="http://www.php.net/header" onclick="urchinTracker('/outgoing/www.php.net/header?referer=');"><span style="color:#000066;">header</span></a><span style="color:#006600; font-weight:bold;">&#40;</span> <span style="color:#FF0000;">"Content-Type: image/png"</span> <span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><a href="http://www.php.net/echo" onclick="urchinTracker('/outgoing/www.php.net/echo?referer=');"><span style="color:#000066;">echo</span></a> <span style="color:#0000FF;">$canvas</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">?&gt;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>And the result is here:</p>
<p><a href="http://valokuva.org/wp-content/uploads/2008/04/patternphp1.png"><img src="http://valokuva.org/wp-content/uploads/2008/04/patternphp1.png"></a></p>
]]></content:encoded>
			<wfw:commentRss>http://valokuva.org/?feed=rss2&amp;p=102</wfw:commentRss>
		<slash:comments>41</slash:comments>
		</item>
		<item>
		<title>phplondon conference 2008</title>
		<link>http://valokuva.org/?p=101</link>
		<comments>http://valokuva.org/?p=101#comments</comments>
		<pubDate>Sun, 02 Mar 2008 19:35:59 +0000</pubDate>
		<dc:creator>Mikko Koppanen</dc:creator>
				<category><![CDATA[Everything else]]></category>
		<category><![CDATA[Imagick]]></category>
		<category><![CDATA[PHP stuff]]></category>
		<category><![CDATA[phplondon08]]></category>

		<guid isPermaLink="false">http://valokuva.org/?p=101</guid>
		<description><![CDATA[To summarize it: I had fun My conference preparations started about two weeks before the conference. The PHPLondon fellows (Paul, Matt and Richard) asked me to do a small presentation about Imagick at the pre-conference social event. The presentation I assembled ended up being a little over two hours, give or take. The hardest part [...]]]></description>
			<content:encoded><![CDATA[<p>To summarize it: I had fun <img src='http://valokuva.org/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  My conference preparations started about two weeks before the conference. The PHPLondon fellows (Paul, Matt and Richard) asked me to do a small presentation about Imagick at the pre-conference social event. The presentation I assembled ended up being a little over two hours, give or take. The hardest part was to trim down from two hours to about 40 minutes (I didn't want to bore the people with too many code examples). The slides are available at <a href="http://valokuva.org/talks">http://valokuva.org/talks</a> if you need them for some reason. </p>
<p>My conference day was pretty hectic from the beginning to the end. I gave a few demos about the products that we represent and the moment I opened my mouth for the first time people started leaving the room. I hope that it had something to do with the  "My Framework is better than yours?" talk starting at the same time <img src='http://valokuva.org/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>I met quite a lot of new people at the conference and of course it was nice to see the familiar faces from other conferences and PHPLondon meetings. I was especially happy that I was able to answer the questions <a href="http://nigeljames.wordpress.com/2008/03/01/quick-update-from-phplondon-conference/" onclick="urchinTracker('/outgoing/nigeljames.wordpress.com/2008/03/01/quick-update-from-phplondon-conference/?referer=');">Nigel James</a> had <img src='http://valokuva.org/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>A huge thanks to the organizers for making this day possible!</p>
]]></content:encoded>
			<wfw:commentRss>http://valokuva.org/?feed=rss2&amp;p=101</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Seam carving</title>
		<link>http://valokuva.org/?p=99</link>
		<comments>http://valokuva.org/?p=99#comments</comments>
		<pubDate>Wed, 13 Feb 2008 18:38:21 +0000</pubDate>
		<dc:creator>Mikko Koppanen</dc:creator>
				<category><![CDATA[Imagick]]></category>
		<category><![CDATA[PHP stuff]]></category>

		<guid isPermaLink="false">http://valokuva.org/?p=99</guid>
		<description><![CDATA[Today I was reading trough the ImageMagick ChangeLog and noticed an interesting entry. "Add support for liquid rescaling". I rushed to check the MagickWand API docs and there it was: MagickLiquidRescaleImage! After about ten minutes of hacking the Imagick support was done. Needless to say; I was excited For those who don't know what seam [...]]]></description>
			<content:encoded><![CDATA[<p>Today I was reading trough the ImageMagick ChangeLog and noticed an interesting entry. "Add support for liquid rescaling". I rushed to check the MagickWand API docs and there it was: MagickLiquidRescaleImage! After about ten minutes of hacking the Imagick support was done. Needless to say; I was excited <img src='http://valokuva.org/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>For those who don't know what seam carving is check the demo <a href="http://www.youtube.com/watch?v=6NcIJXTlugc" onclick="urchinTracker('/outgoing/www.youtube.com/watch?v=6NcIJXTlugc&amp;referer=');">here</a>. More detailed information about the algorithm can be found here: <a href="http://www.faculty.idc.ac.il/arik/imret.pdf" onclick="urchinTracker('/outgoing/www.faculty.idc.ac.il/arik/imret.pdf?referer=');">"Seam Carving for Content-Aware Image Resizing" by Shai Avidan and Ariel Shamir</a></p>
<p>To use this functionality you need to install at least ImageMagick 6.3.8-2 and liblqr. Remember to pass --with-lqr to ImageMagick configuration line. You can get liblqr here: <a href="http://liblqr.wikidot.com/" onclick="urchinTracker('/outgoing/liblqr.wikidot.com/?referer=');">http://liblqr.wikidot.com/</a>. The Imagick side of the functionality should appear in the CVS today if everything goes as planned.</p>
<p>Here is a really simple example just to illustrate the results of the operation. The parameters might be far from optimal (didn't do much testing yet). The original dimensions of image are 500x375 and the resulting size is 500x200.</p>
<p><em><strong>Update: the functionality is pending until license issues are solved.</strong></em></p>
<div class="igBar"><span id="lphp-8"><a href="#" onclick="javascript:showCodeTxt('php-8'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-8">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">&lt;?php</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">/* Create new object */</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$im</span> = <span style="color:#000000; font-weight:bold;">new</span> Imagick<span style="color:#006600; font-weight:bold;">&#40;</span> <span style="color:#FF0000;">'test.jpg'</span> <span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">/* Scale down */</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$im</span>-&gt;<span style="color:#006600;">liquidRescaleImage</span><span style="color:#006600; font-weight:bold;">&#40;</span> <span style="color:#CC66CC;color:#800000;">500</span>, <span style="color:#CC66CC;color:#800000;">200</span>, <span style="color:#CC66CC;color:#800000;">3</span>, <span style="color:#CC66CC;color:#800000;">25</span> <span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">/* Display */</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><a href="http://www.php.net/header" onclick="urchinTracker('/outgoing/www.php.net/header?referer=');"><span style="color:#000066;">header</span></a><span style="color:#006600; font-weight:bold;">&#40;</span> <span style="color:#FF0000;">'Content-Type: image/jpg'</span> <span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><a href="http://www.php.net/echo" onclick="urchinTracker('/outgoing/www.php.net/echo?referer=');"><span style="color:#000066;">echo</span></a> <span style="color:#0000FF;">$im</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">?&gt;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>The original image by flickr/jennconspiracy</p>
<p><img src="http://valokuva.org/wp-content/uploads/2008/02/landscape_orig.jpg" alt="result" /></p>
<p>And the result:</p>
<p><img src="http://valokuva.org/wp-content/uploads/2008/02/landscape.jpg" alt="result" /></p>
<p><em>Update. On kenrick's request here is an image which is scaled down to 300x300 </em></p>
<p><img src="http://valokuva.org/wp-content/uploads/2008/02/300x300_result.jpg" alt="result2" /></p>
]]></content:encoded>
			<wfw:commentRss>http://valokuva.org/?feed=rss2&amp;p=99</wfw:commentRss>
		<slash:comments>50</slash:comments>
		</item>
		<item>
		<title>Typesetting</title>
		<link>http://valokuva.org/?p=93</link>
		<comments>http://valokuva.org/?p=93#comments</comments>
		<pubDate>Wed, 16 Jan 2008 22:07:28 +0000</pubDate>
		<dc:creator>Mikko Koppanen</dc:creator>
				<category><![CDATA[Imagick]]></category>
		<category><![CDATA[PHP stuff]]></category>

		<guid isPermaLink="false">http://valokuva.org/?p=93</guid>
		<description><![CDATA[Ever had the situation where you have a piece of string which you need to overlay on an image? Maybe a situation where the area reserved for the string is known in pixels but you need to know the font size to fill most of the area? Think no more! Here is a small example [...]]]></description>
			<content:encoded><![CDATA[<p>Ever had the situation where you have a piece of string which you need to overlay on an image? Maybe a situation where the area reserved for the string is known in pixels but you need to know the font size to fill most of the area? Think no more! </p>
<p>Here is a small example of how to fit a certain piece of a string on to an area of which you know the width and the height or only the width. The magic happens through the ImageMagick CAPTION: format. You can see from the example images how the parameters actually affect the image.</p>
<div class="igBar"><span id="lphp-10"><a href="#" onclick="javascript:showCodeTxt('php-10'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-10">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">&lt;?php</span> </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">/* How wide is our image */</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$image_width</span> = <span style="color:#CC66CC;color:#800000;">200</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">/* Give zero for autocalculating the height */</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$image_height</span> = <span style="color:#CC66CC;color:#800000;">200</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">/* Specify the text */</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$text</span> = <span style="color:#FF0000;">"Lorem ipsum dolor sit amet, consectetuer adipiscing elit. </span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF0000;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Mauris lectus mi, mattis non, euismod vel, sagittis nec, ipsum."</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">/* Instanciate imagick */</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$im</span> = <span style="color:#000000; font-weight:bold;">new</span> Imagick<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">/* Create new image using caption: pseudo format */</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$im</span>-&gt;<span style="color:#006600;">newPseudoImage</span><span style="color:#006600; font-weight:bold;">&#40;</span> <span style="color:#0000FF;">$image_width</span>, <span style="color:#0000FF;">$image_height</span>, <span style="color:#FF0000;">"caption:"</span> . <span style="color:#0000FF;">$text</span> <span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">/* Put 1px border around the image */</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$im</span>-&gt;<span style="color:#006600;">borderImage</span><span style="color:#006600; font-weight:bold;">&#40;</span> <span style="color:#FF0000;">'black'</span>, <span style="color:#CC66CC;color:#800000;">1</span>, <span style="color:#CC66CC;color:#800000;">1</span> <span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">/* PNG format */</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$im</span>-&gt;<span style="color:#006600;">setImageFormat</span><span style="color:#006600; font-weight:bold;">&#40;</span> <span style="color:#FF0000;">"png"</span><span style="color:#006600; font-weight:bold;">&#41;</span> ;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">/* Output */</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><a href="http://www.php.net/header" onclick="urchinTracker('/outgoing/www.php.net/header?referer=');"><span style="color:#000066;">header</span></a><span style="color:#006600; font-weight:bold;">&#40;</span> <span style="color:#FF0000;">"Content-Type: image/png"</span> <span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><a href="http://www.php.net/echo" onclick="urchinTracker('/outgoing/www.php.net/echo?referer=');"><span style="color:#000066;">echo</span></a> <span style="color:#0000FF;">$im</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">?&gt;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Here is image with width 100 and height 0:</p>
<p><a href='http://valokuva.org/wp-content/uploads/2008/01/width_100_height_0.png' title='width_100_height_0.png'><img src='http://valokuva.org/wp-content/uploads/2008/01/width_100_height_0.png' alt='width_100_height_0.png' /></a></p>
<p>Width 100 Height 50:</p>
<p><a href='http://valokuva.org/wp-content/uploads/2008/01/width_100_height_50.png' title='width_100_height_50.png'><img src='http://valokuva.org/wp-content/uploads/2008/01/width_100_height_50.png' alt='width_100_height_50.png' /></a></p>
<p>Width 200 Height 200 (as you can see the font size is now larger):</p>
<p><a href='http://valokuva.org/wp-content/uploads/2008/01/width_200_height_200.png' title='width_200_height_200.png'><img src='http://valokuva.org/wp-content/uploads/2008/01/width_200_height_200.png' alt='width_200_height_200.png' /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://valokuva.org/?feed=rss2&amp;p=93</wfw:commentRss>
		<slash:comments>40</slash:comments>
		</item>
		<item>
		<title>Padding thumbnail with color</title>
		<link>http://valokuva.org/?p=92</link>
		<comments>http://valokuva.org/?p=92#comments</comments>
		<pubDate>Fri, 11 Jan 2008 12:30:34 +0000</pubDate>
		<dc:creator>Mikko Koppanen</dc:creator>
				<category><![CDATA[Imagick]]></category>
		<category><![CDATA[PHP stuff]]></category>

		<guid isPermaLink="false">http://valokuva.org/?p=92</guid>
		<description><![CDATA[I know, it's been a while since I last blogged. This is because a lot of things are happening in my personal life. I recently relocated to London from Finland and started a new job. Things are quite busy but I will try to post an example now and then. In the meanwhile I would [...]]]></description>
			<content:encoded><![CDATA[<p>I know, it's been a while since I last blogged. This is because a lot of things are happening in my personal life. I recently relocated to London from Finland and started a new job. Things are quite busy but I will try to post an example now and then. In the meanwhile I would like to hear about sites using Imagick, so if your project is not super secret please post an url and maybe a small explanation what you're doing with Imagick on the site. This is purely for my personal interest.</p>
<p>Anyway, to the point. Today's example originates from a question asked by a user. How do I thumbnail the image inside given dimensions proportionally and fill the "blank" areas with a color? Well, the answer is here <img src='http://valokuva.org/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>The code is for Imagick 2.1.0 but adapting to older versions should not be hard.</p>
<div class="igBar"><span id="lphp-12"><a href="#" onclick="javascript:showCodeTxt('php-12'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-12">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">&lt;?php</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">/* Define width and height of the thumbnail */</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$width</span> = <span style="color:#CC66CC;color:#800000;">100</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$height</span> = <span style="color:#CC66CC;color:#800000;">100</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">/* Instanciate and read the image in */</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$im</span> = <span style="color:#000000; font-weight:bold;">new</span> Imagick<span style="color:#006600; font-weight:bold;">&#40;</span> <span style="color:#FF0000;">"test.png"</span> <span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">/* Fit the image into $width x $height box </span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;"> The third parameter fits the image into a &quot;bounding box&quot; */</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$im</span>-&gt;<span style="color:#006600;">thumbnailImage</span><span style="color:#006600; font-weight:bold;">&#40;</span> <span style="color:#0000FF;">$width</span>, <span style="color:#0000FF;">$height</span>, <span style="color:#000000; font-weight:bold;">true</span> <span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">/* Create a canvas with the desired color */</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$canvas</span> = <span style="color:#000000; font-weight:bold;">new</span> Imagick<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$canvas</span>-&gt;<span style="color:#006600;">newImage</span><span style="color:#006600; font-weight:bold;">&#40;</span> <span style="color:#0000FF;">$width</span>, <span style="color:#0000FF;">$height</span>, <span style="color:#FF0000;">'pink'</span>, <span style="color:#FF0000;">'png'</span> <span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">/* Get the image geometry */</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$geometry</span> = <span style="color:#0000FF;">$im</span>-&gt;<span style="color:#006600;">getImageGeometry</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">/* The overlay x and y coordinates */</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$x</span> = <span style="color:#006600; font-weight:bold;">&#40;</span> <span style="color:#0000FF;">$width</span> - <span style="color:#0000FF;">$geometry</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'width'</span><span style="color:#006600; font-weight:bold;">&#93;</span> <span style="color:#006600; font-weight:bold;">&#41;</span> / <span style="color:#CC66CC;color:#800000;">2</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$y</span> = <span style="color:#006600; font-weight:bold;">&#40;</span> <span style="color:#0000FF;">$height</span> - <span style="color:#0000FF;">$geometry</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'height'</span><span style="color:#006600; font-weight:bold;">&#93;</span> <span style="color:#006600; font-weight:bold;">&#41;</span> / <span style="color:#CC66CC;color:#800000;">2</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">/* Composite on the canvas&nbsp; */</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$canvas</span>-&gt;<span style="color:#006600;">compositeImage</span><span style="color:#006600; font-weight:bold;">&#40;</span> <span style="color:#0000FF;">$im</span>, imagick::<span style="color:#006600;">COMPOSITE_OVER</span>, <span style="color:#0000FF;">$x</span>, <span style="color:#0000FF;">$y</span> <span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">/* Output the image*/</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><a href="http://www.php.net/header" onclick="urchinTracker('/outgoing/www.php.net/header?referer=');"><span style="color:#000066;">header</span></a><span style="color:#006600; font-weight:bold;">&#40;</span> <span style="color:#FF0000;">"Content-Type: image/png"</span> <span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><a href="http://www.php.net/echo" onclick="urchinTracker('/outgoing/www.php.net/echo?referer=');"><span style="color:#000066;">echo</span></a> <span style="color:#0000FF;">$canvas</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">?&gt;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>The source image:<br />
<a href='http://valokuva.org/wp-content/uploads/2008/01/test.png' title='test.png'><img src='http://valokuva.org/wp-content/uploads/2008/01/test.png' alt='test.png' /></a></p>
<p>The resulting image:<br />
<a href='http://valokuva.org/wp-content/uploads/2008/01/testphp.png' title='testphp.png'><img src='http://valokuva.org/wp-content/uploads/2008/01/testphp.png' alt='testphp.png' /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://valokuva.org/?feed=rss2&amp;p=92</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>Creating buttons with Imagick</title>
		<link>http://valokuva.org/?p=84</link>
		<comments>http://valokuva.org/?p=84#comments</comments>
		<pubDate>Wed, 21 Nov 2007 08:24:38 +0000</pubDate>
		<dc:creator>Mikko Koppanen</dc:creator>
				<category><![CDATA[Imagick]]></category>
		<category><![CDATA[PHP stuff]]></category>

		<guid isPermaLink="false">http://valokuva.org/?p=84</guid>
		<description><![CDATA[A fellow called kakapo asked me to create a button with Imagick. He had an image of the button and a Photoshop tutorial but unfortunately the tutorial was in Chinese. My Chinese is a bit rusty so it will take a little longer to create that specific button The button in this example is created [...]]]></description>
			<content:encoded><![CDATA[<p>A fellow called <a href="http://www.kakapo.cn/blog/" onclick="urchinTracker('/outgoing/www.kakapo.cn/blog/?referer=');">kakapo</a> asked me to create a button with Imagick. He had an image of the button and a Photoshop tutorial but unfortunately the tutorial was in Chinese. My Chinese is a bit rusty so it will take a little longer to create that specific button <img src='http://valokuva.org/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>The button in this example is created after this tutorial <a href="http://xeonfx.com/tutorials/easy-button-tutorial/" onclick="urchinTracker('/outgoing/xeonfx.com/tutorials/easy-button-tutorial/?referer=');">http://xeonfx.com/tutorials/easy-button-tutorial/</a> (yes, I googled "easy button tutorial"). The code and the button it creates are both very simple but the effect looks really nice. </p>
<p>Here we go with the code:</p>
<div class="igBar"><span id="lphp-14"><a href="#" onclick="javascript:showCodeTxt('php-14'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-14">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">&lt;?php</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">/* Create a new Imagick object */</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$im</span> = <span style="color:#000000; font-weight:bold;">new</span> Imagick<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">/* Create empty canvas */</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$im</span>-&gt;<span style="color:#006600;">newImage</span><span style="color:#006600; font-weight:bold;">&#40;</span> <span style="color:#CC66CC;color:#800000;">200</span>, <span style="color:#CC66CC;color:#800000;">200</span>, <span style="color:#FF0000;">"white"</span>, <span style="color:#FF0000;">"png"</span> <span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">/* Create the object used to draw */</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$draw</span> = <span style="color:#000000; font-weight:bold;">new</span> ImagickDraw<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">/* Set the button color. </span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">&nbsp; &nbsp;Changing this value changes the color of the button */</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$draw</span>-&gt;<span style="color:#006600;">setFillColor</span><span style="color:#006600; font-weight:bold;">&#40;</span> <span style="color:#FF0000;">"#4096EE"</span> <span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">/* Create the outer circle */</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$draw</span>-&gt;<span style="color:#006600;">circle</span><span style="color:#006600; font-weight:bold;">&#40;</span> <span style="color:#CC66CC;color:#800000;">50</span>, <span style="color:#CC66CC;color:#800000;">50</span>, <span style="color:#CC66CC;color:#800000;">70</span>, <span style="color:#CC66CC;color:#800000;">70</span> <span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">/* Create the smaller circle on the button */</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$draw</span>-&gt;<span style="color:#006600;">setFillColor</span><span style="color:#006600; font-weight:bold;">&#40;</span> <span style="color:#FF0000;">"white"</span> <span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">/* Semi-opaque fill */</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$draw</span>-&gt;<span style="color:#006600;">setFillAlpha</span><span style="color:#006600; font-weight:bold;">&#40;</span> <span style="color:#CC66CC;color:#800000;">0</span>.<span style="color:#CC66CC;color:#800000;">2</span> <span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">/* Draw the circle */</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$draw</span>-&gt;<span style="color:#006600;">circle</span><span style="color:#006600; font-weight:bold;">&#40;</span> <span style="color:#CC66CC;color:#800000;">50</span>, <span style="color:#CC66CC;color:#800000;">50</span>, <span style="color:#CC66CC;color:#800000;">68</span>, <span style="color:#CC66CC;color:#800000;">68</span> <span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">/* Set the font */</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$draw</span>-&gt;<span style="color:#006600;">setFont</span><span style="color:#006600; font-weight:bold;">&#40;</span> <span style="color:#FF0000;">"./test1.ttf"</span> <span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">/* This is the alpha value used to annotate */</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$draw</span>-&gt;<span style="color:#006600;">setFillAlpha</span><span style="color:#006600; font-weight:bold;">&#40;</span> <span style="color:#CC66CC;color:#800000;">0</span>.<span style="color:#CC66CC;color:#800000;">17</span> <span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">/* Draw a curve on the button with 17% opaque fill */</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$draw</span>-&gt;<span style="color:#006600;">bezier</span><span style="color:#006600; font-weight:bold;">&#40;</span> <a href="http://www.php.net/array" onclick="urchinTracker('/outgoing/www.php.net/array?referer=');"><span style="color:#000066;">array</span></a><span style="color:#006600; font-weight:bold;">&#40;</span> </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.php.net/array" onclick="urchinTracker('/outgoing/www.php.net/array?referer=');"><span style="color:#000066;">array</span></a><span style="color:#006600; font-weight:bold;">&#40;</span> <span style="color:#FF0000;">"x"</span> =&gt; <span style="color:#CC66CC;color:#800000;">10</span> , <span style="color:#FF0000;">"y"</span> =&gt; <span style="color:#CC66CC;color:#800000;">25</span> <span style="color:#006600; font-weight:bold;">&#41;</span>,</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.php.net/array" onclick="urchinTracker('/outgoing/www.php.net/array?referer=');"><span style="color:#000066;">array</span></a><span style="color:#006600; font-weight:bold;">&#40;</span> <span style="color:#FF0000;">"x"</span> =&gt; <span style="color:#CC66CC;color:#800000;">39</span>, <span style="color:#FF0000;">"y"</span> =&gt; <span style="color:#CC66CC;color:#800000;">49</span> <span style="color:#006600; font-weight:bold;">&#41;</span>,</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.php.net/array" onclick="urchinTracker('/outgoing/www.php.net/array?referer=');"><span style="color:#000066;">array</span></a><span style="color:#006600; font-weight:bold;">&#40;</span> <span style="color:#FF0000;">"x"</span> =&gt; <span style="color:#CC66CC;color:#800000;">60</span>, <span style="color:#FF0000;">"y"</span> =&gt; <span style="color:#CC66CC;color:#800000;">55</span> <span style="color:#006600; font-weight:bold;">&#41;</span>,</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.php.net/array" onclick="urchinTracker('/outgoing/www.php.net/array?referer=');"><span style="color:#000066;">array</span></a><span style="color:#006600; font-weight:bold;">&#40;</span> <span style="color:#FF0000;">"x"</span> =&gt; <span style="color:#CC66CC;color:#800000;">75</span>, <span style="color:#FF0000;">"y"</span> =&gt; <span style="color:#CC66CC;color:#800000;">70</span> <span style="color:#006600; font-weight:bold;">&#41;</span>,</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.php.net/array" onclick="urchinTracker('/outgoing/www.php.net/array?referer=');"><span style="color:#000066;">array</span></a><span style="color:#006600; font-weight:bold;">&#40;</span> <span style="color:#FF0000;">"x"</span> =&gt; <span style="color:#CC66CC;color:#800000;">100</span>, <span style="color:#FF0000;">"y"</span> =&gt; <span style="color:#CC66CC;color:#800000;">70</span> <span style="color:#006600; font-weight:bold;">&#41;</span>,</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.php.net/array" onclick="urchinTracker('/outgoing/www.php.net/array?referer=');"><span style="color:#000066;">array</span></a><span style="color:#006600; font-weight:bold;">&#40;</span> <span style="color:#FF0000;">"x"</span> =&gt; <span style="color:#CC66CC;color:#800000;">100</span>, <span style="color:#FF0000;">"y"</span> =&gt; <span style="color:#CC66CC;color:#800000;">10</span> <span style="color:#006600; font-weight:bold;">&#41;</span>,</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; <span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#41;</span>; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">/* Render all pending operations on the image */</span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$im</span>-&gt;<span style="color:#006600;">drawImage</span><span style="color:#006600; font-weight:bold;">&#40;</span> <span style="color:#0000FF;">$draw</span> <span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">/* Set fill to fully opaque */</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$draw</span>-&gt;<span style="color:#006600;">setFillAlpha</span><span style="color:#006600; font-weight:bold;">&#40;</span> <span style="color:#CC66CC;color:#800000;">1</span> <span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">/* Set the font size to 30 */</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$draw</span>-&gt;<span style="color:#006600;">setFontSize</span><span style="color:#006600; font-weight:bold;">&#40;</span> <span style="color:#CC66CC;color:#800000;">30</span> <span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">/* The text on the */</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$draw</span>-&gt;<span style="color:#006600;">setFillColor</span><span style="color:#006600; font-weight:bold;">&#40;</span> <span style="color:#FF0000;">"white"</span> <span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">/* Annotate the text */</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$im</span>-&gt;<span style="color:#006600;">annotateImage</span><span style="color:#006600; font-weight:bold;">&#40;</span> <span style="color:#0000FF;">$draw</span>, <span style="color:#CC66CC;color:#800000;">38</span>, <span style="color:#CC66CC;color:#800000;">55</span>, <span style="color:#CC66CC;color:#800000;">0</span>, <span style="color:#FF0000;">"go"</span> <span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">/* Trim extra area out of the image */</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$im</span>-&gt;<span style="color:#006600;">trimImage</span><span style="color:#006600; font-weight:bold;">&#40;</span> <span style="color:#CC66CC;color:#800000;">0</span> <span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">/* Output the image */</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><a href="http://www.php.net/header" onclick="urchinTracker('/outgoing/www.php.net/header?referer=');"><span style="color:#000066;">header</span></a><span style="color:#006600; font-weight:bold;">&#40;</span> <span style="color:#FF0000;">"Content-Type: image/png"</span> <span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><a href="http://www.php.net/echo" onclick="urchinTracker('/outgoing/www.php.net/echo?referer=');"><span style="color:#000066;">echo</span></a> <span style="color:#0000FF;">$im</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">?&gt;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>And here is a few buttons I created by changing the fill color value:</p>
<p><img src="http://valokuva.org/wp-content/uploads/2007/11/button_red.png" alt="red" /></p>
<p><img src="http://valokuva.org/wp-content/uploads/2007/11/button_green.png" alt="green" /></p>
<p><img src="http://valokuva.org/wp-content/uploads/2007/11/button_blue.png" alt="blue" /></p>
]]></content:encoded>
			<wfw:commentRss>http://valokuva.org/?feed=rss2&amp;p=84</wfw:commentRss>
		<slash:comments>22</slash:comments>
		</item>
		<item>
		<title>Creating a reflection</title>
		<link>http://valokuva.org/?p=82</link>
		<comments>http://valokuva.org/?p=82#comments</comments>
		<pubDate>Mon, 19 Nov 2007 20:45:43 +0000</pubDate>
		<dc:creator>Mikko Koppanen</dc:creator>
				<category><![CDATA[Imagick]]></category>
		<category><![CDATA[PHP stuff]]></category>

		<guid isPermaLink="false">http://valokuva.org/?p=82</guid>
		<description><![CDATA[Here is a simple example of creating a reflection of an image. The reflection is created by flipping the image and overlaying a gradient on it. Then both, the original image and the reflection is overlayed on a canvas. This example is created for Imagick 2.1.x but with a little tuning it should work with [...]]]></description>
			<content:encoded><![CDATA[<p>Here is a simple example of creating a reflection of an image. The reflection is created by flipping the image and overlaying a gradient on it. Then both, the original image and the reflection is overlayed on a canvas. </p>
<p>This example is created for Imagick 2.1.x but with a little tuning it should work with earlier versions.</p>
<div class="igBar"><span id="lphp-16"><a href="#" onclick="javascript:showCodeTxt('php-16'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-16">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">&lt;?php</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">/* Read the image */</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$im</span> = <span style="color:#000000; font-weight:bold;">new</span> Imagick<span style="color:#006600; font-weight:bold;">&#40;</span> <span style="color:#FF0000;">"strawberry.png"</span> <span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">/* Thumbnail the image */</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$im</span>-&gt;<span style="color:#006600;">thumbnailImage</span><span style="color:#006600; font-weight:bold;">&#40;</span> <span style="color:#CC66CC;color:#800000;">200</span>, <span style="color:#000000; font-weight:bold;">null</span> <span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">/* Create a border for the image */</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$im</span>-&gt;<span style="color:#006600;">borderImage</span><span style="color:#006600; font-weight:bold;">&#40;</span> <span style="color:#FF0000;">"white"</span>, <span style="color:#CC66CC;color:#800000;">5</span>, <span style="color:#CC66CC;color:#800000;">5</span> <span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">/* Clone the image and flip it */</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$reflection</span> = <span style="color:#0000FF;">$im</span>-&gt;<span style="color:#006600;">clone</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$reflection</span>-&gt;<span style="color:#006600;">flipImage</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">/* Create gradient. It will be overlayd on the reflection */</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$gradient</span> = <span style="color:#000000; font-weight:bold;">new</span> Imagick<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">/* Gradient needs to be large enough for the image</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">and the borders */</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$gradient</span>-&gt;<span style="color:#006600;">newPseudoImage</span><span style="color:#006600; font-weight:bold;">&#40;</span> <span style="color:#0000FF;">$reflection</span>-&gt;<span style="color:#006600;">getImageWidth</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span> + <span style="color:#CC66CC;color:#800000;">10</span>,</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; <span style="color:#0000FF;">$reflection</span>-&gt;<span style="color:#006600;">getImageHeight</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span> + <span style="color:#CC66CC;color:#800000;">10</span>,</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; <span style="color:#FF0000;">"gradient:transparent-black"</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">/* Composite the gradient on the reflection */</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$reflection</span>-&gt;<span style="color:#006600;">compositeImage</span><span style="color:#006600; font-weight:bold;">&#40;</span> <span style="color:#0000FF;">$gradient</span>, imagick::<span style="color:#006600;">COMPOSITE_OVER</span>, <span style="color:#CC66CC;color:#800000;">0</span>, <span style="color:#CC66CC;color:#800000;">0</span> <span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">/* Add some opacity */</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$reflection</span>-&gt;<span style="color:#006600;">setImageOpacity</span><span style="color:#006600; font-weight:bold;">&#40;</span> <span style="color:#CC66CC;color:#800000;">0</span>.<span style="color:#CC66CC;color:#800000;">3</span> <span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">/* Create empty canvas */</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$canvas</span> = <span style="color:#000000; font-weight:bold;">new</span> Imagick<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">/* Canvas needs to be large enough to hold the both images */</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$width</span> = <span style="color:#0000FF;">$im</span>-&gt;<span style="color:#006600;">getImageWidth</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span> + <span style="color:#CC66CC;color:#800000;">40</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$height</span> = <span style="color:#006600; font-weight:bold;">&#40;</span> <span style="color:#0000FF;">$im</span>-&gt;<span style="color:#006600;">getImageHeight</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span> * <span style="color:#CC66CC;color:#800000;">2</span> <span style="color:#006600; font-weight:bold;">&#41;</span> + <span style="color:#CC66CC;color:#800000;">30</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$canvas</span>-&gt;<span style="color:#006600;">newImage</span><span style="color:#006600; font-weight:bold;">&#40;</span> <span style="color:#0000FF;">$width</span>, <span style="color:#0000FF;">$height</span>, <span style="color:#FF0000;">"black"</span>, <span style="color:#FF0000;">"png"</span> <span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">/* Composite the original image and the reflection on the canvas */</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$canvas</span>-&gt;<span style="color:#006600;">compositeImage</span><span style="color:#006600; font-weight:bold;">&#40;</span> <span style="color:#0000FF;">$im</span>, imagick::<span style="color:#006600;">COMPOSITE_OVER</span>, <span style="color:#CC66CC;color:#800000;">20</span>, <span style="color:#CC66CC;color:#800000;">10</span> <span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$canvas</span>-&gt;<span style="color:#006600;">compositeImage</span><span style="color:#006600; font-weight:bold;">&#40;</span> <span style="color:#0000FF;">$reflection</span>, imagick::<span style="color:#006600;">COMPOSITE_OVER</span>,</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#CC66CC;color:#800000;">20</span>, <span style="color:#0000FF;">$im</span>-&gt;<span style="color:#006600;">getImageHeight</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span> + <span style="color:#CC66CC;color:#800000;">10</span> <span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">/* Output the image*/</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><a href="http://www.php.net/header" onclick="urchinTracker('/outgoing/www.php.net/header?referer=');"><span style="color:#000066;">header</span></a><span style="color:#006600; font-weight:bold;">&#40;</span> <span style="color:#FF0000;">"Content-Type: image/png"</span> <span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><a href="http://www.php.net/echo" onclick="urchinTracker('/outgoing/www.php.net/echo?referer=');"><span style="color:#000066;">echo</span></a> <span style="color:#0000FF;">$canvas</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">?&gt;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>The source image:</p>
<p><img src="http://valokuva.org/wp-content/uploads/2007/11/strawberry1.png" alt="source" /></p>
<p>And the result:</p>
<p><img src="http://valokuva.org/wp-content/uploads/2007/11/reflection.png" alt="result" /></p>
<p>P.S. Please send me some new images which I can use in these examples <img src='http://valokuva.org/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://valokuva.org/?feed=rss2&amp;p=82</wfw:commentRss>
		<slash:comments>21</slash:comments>
		</item>
		<item>
		<title>ImagickPixelIterator is not read-only after all..</title>
		<link>http://valokuva.org/?p=79</link>
		<comments>http://valokuva.org/?p=79#comments</comments>
		<pubDate>Thu, 15 Nov 2007 06:54:50 +0000</pubDate>
		<dc:creator>Mikko Koppanen</dc:creator>
				<category><![CDATA[Imagick]]></category>
		<category><![CDATA[PHP stuff]]></category>

		<guid isPermaLink="false">http://valokuva.org/?p=79</guid>
		<description><![CDATA[A few days ago I got a help request from a user: "How do you change pixel color during the iteration with ImagickPixelIterator". My initial response was that ImagickPixelIterator is read-only. Well, I have to admit I was wrong. After searching trough ImageMagick docs I stumbled across an example and noticed that PixelIterator (and therefor [...]]]></description>
			<content:encoded><![CDATA[<p>A few days ago I got a help request from a user: "How do you change pixel color during the iteration with ImagickPixelIterator". My initial response was that ImagickPixelIterator is read-only.</p>
<p>Well, I have to admit I was wrong. After searching trough ImageMagick docs I stumbled across an example and noticed that PixelIterator (and therefor ImagickPixelIterator) is not read-only after all. I have tried the code like in this example before; without the syncIterator call after each row. After adding the Imagick::syncIterator call everything worked as expected.</p>
<p>This example will work with Imagick 2.1.0 (the RC1 was released yesterday) but with a little tweaking it should work with 2.0.x too.</p>
<div class="igBar"><span id="lphp-18"><a href="#" onclick="javascript:showCodeTxt('php-18'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-18">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">&lt;?php</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">/* Create new object with the image */</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$im</span> = <span style="color:#000000; font-weight:bold;">new</span> Imagick<span style="color:#006600; font-weight:bold;">&#40;</span> <span style="color:#FF0000;">"strawberry.png"</span> <span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">/* Get iterator */</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$it</span> = <span style="color:#0000FF;">$im</span>-&gt;<span style="color:#006600;">getPixelIterator</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">/* Loop trough pixel rows */</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#616100;">foreach</span><span style="color:#006600; font-weight:bold;">&#40;</span> <span style="color:#0000FF;">$it</span> <span style="color:#616100;">as</span> <span style="color:#0000FF;">$row</span> =&gt; <span style="color:#0000FF;">$pixels</span> <span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#008000;">/* For every second row */</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#616100;">if</span> <span style="color:#006600; font-weight:bold;">&#40;</span> <span style="color:#0000FF;">$row</span> % <span style="color:#CC66CC;color:#800000;">2</span> <span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#008000;">/* Loop trough the pixels in the row (columns) */</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">foreach</span> <span style="color:#006600; font-weight:bold;">&#40;</span> <span style="color:#0000FF;">$pixels</span> <span style="color:#616100;">as</span> <span style="color:#0000FF;">$column</span> =&gt; <span style="color:#0000FF;">$pixel</span> <span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#008000;">/* Paint every second pixel black*/</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">if</span> <span style="color:#006600; font-weight:bold;">&#40;</span> <span style="color:#0000FF;">$column</span> % <span style="color:#CC66CC;color:#800000;">2</span> <span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$pixel</span>-&gt;<span style="color:#006600;">setColor</span><span style="color:#006600; font-weight:bold;">&#40;</span> <span style="color:#FF0000;">"black"</span> <span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#008000;">/* Sync the iterator, this is important</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">&nbsp; &nbsp; to do on each iteration */</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#0000FF;">$it</span>-&gt;<span style="color:#006600;">syncIterator</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">/* Display the image */</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><a href="http://www.php.net/header" onclick="urchinTracker('/outgoing/www.php.net/header?referer=');"><span style="color:#000066;">header</span></a><span style="color:#006600; font-weight:bold;">&#40;</span> <span style="color:#FF0000;">"Content-Type: image/png"</span> <span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><a href="http://www.php.net/echo" onclick="urchinTracker('/outgoing/www.php.net/echo?referer=');"><span style="color:#000066;">echo</span></a> <span style="color:#0000FF;">$im</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">?&gt;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>The source image:</p>
<p><img src="http://valokuva.org/wp-content/uploads/2007/11/strawberry.png" alt="strawberry" /> </p>
<p>The result image:</p>
<p><img src="http://valokuva.org/wp-content/uploads/2007/11/strawberry_colored.png" alt="strawberry_result" /> </p>
]]></content:encoded>
			<wfw:commentRss>http://valokuva.org/?feed=rss2&amp;p=79</wfw:commentRss>
		<slash:comments>18</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Page Caching using apc (user agent is rejected)
Database Caching 3/10 queries in 0.021 seconds using apc

Served from: valokuva.org @ 2010-09-10 19:35:11 -->