<?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>ChadSmiley Blog &#187; PHP</title>
	<atom:link href="http://chadsmiley.com/chadsmiley/category/uncategorized/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://chadsmiley.com/chadsmiley</link>
	<description>Things about family, life, coding, and more</description>
	<lastBuildDate>Sun, 11 Mar 2012 03:01:46 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Change image hue with PHP</title>
		<link>http://chadsmiley.com/chadsmiley/2010/03/change-image-hue-with-php/</link>
		<comments>http://chadsmiley.com/chadsmiley/2010/03/change-image-hue-with-php/#comments</comments>
		<pubDate>Mon, 08 Mar 2010 15:33:49 +0000</pubDate>
		<dc:creator>ChadSmiley</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://chadsmiley.com/chadsmiley/?p=1950</guid>
		<description><![CDATA[I am considering changing the color of my dojo grids so it is easier to distinguish them because there will be so many on one page (this is an internal application). I have not worked through the CSS changes which &#8230; <a href="http://chadsmiley.com/chadsmiley/2010/03/change-image-hue-with-php/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[I am considering changing the color of my <a href="http://dojotoolkit.org/">dojo</a> grids so it is easier to distinguish them because there will be so many on one page (this is an internal application).  I have not worked through the CSS changes which could be a small challenge but more on that to later.  For now this is the php code that I used to change the <a href="http://en.wikipedia.org/wiki/Hue">hue</a> on the images from the soria theme.  I am using <http://www.php.net/manual/en/book.imagick.php">ImageMagick</a>, specificly the <a href="http://php.net/manual/en/function.imagick-modulateimage.php">modulateImage</a> function.  Yes, I did search and could not find any existing app that could batch change the hue, so PHP came to my rescue!


<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000088;">$originalPath</span> <span style="color: #339933;">=</span><span style="color: #0000ff;">'/dojo/chadsmiley/Themes/soria/'</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$path</span> <span style="color: #339933;">=</span><span style="color: #0000ff;">'/dojo/chadsmiley/Themes/Hue30/'</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$dir_handle</span> <span style="color: #339933;">=</span> <span style="color: #339933;">@</span><span style="color: #990000;">opendir</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$originalPath</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//running the while loop</span>
<span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$file</span> <span style="color: #339933;">=</span> <span style="color: #990000;">readdir</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$dir_handle</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	   <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$file</span><span style="color: #339933;">!=</span><span style="color: #0000ff;">&quot;.&quot;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #000088;">$file</span><span style="color: #339933;">!=</span><span style="color: #0000ff;">&quot;..&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
&nbsp;
			<span style="color: #000088;">$img</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Imagick<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #000088;">$img</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">readImage</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$originalPath</span><span style="color: #339933;">.</span><span style="color: #000088;">$file</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			 <span style="color: #009933; font-style: italic;">/**
			   *@var brightness 100 = no change
			   *@var saturation 100 = no change 
			   *@var hue (percentage of absolute rotation from the current position)
			   */</span>
			<span style="color: #000088;">$img</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">modulateImage</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">100</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">100</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">30</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #000088;">$img</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">writeImage</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$path</span><span style="color: #339933;">.</span><span style="color: #000088;">$file</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #000088;">$img</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">clear</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #000088;">$img</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">destroy</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	   <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//closing the directory</span>
<span style="color: #990000;">closedir</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$dir_handle</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>


]]></content:encoded>
			<wfw:commentRss>http://chadsmiley.com/chadsmiley/2010/03/change-image-hue-with-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk: basic
Page Caching using disk: enhanced

Served from: www.chadsmiley.com @ 2012-05-22 10:13:08 -->
