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 | <?php $originalPath ='/dojo/chadsmiley/Themes/soria/'; $path ='/dojo/chadsmiley/Themes/Hue30/'; $dir_handle = @opendir($originalPath); //running the while loop while ($file = readdir($dir_handle)){ if($file!="." && $file!=".."){ $img = new Imagick(); $img->readImage($originalPath.$file); /** *@var brightness 100 = no change *@var saturation 100 = no change *@var hue (percentage of absolute rotation from the current position) */ $img->modulateImage(100, 100, 30); $img->writeImage($path.$file); $img->clear(); $img->destroy(); } } //closing the directory closedir($dir_handle); ?> |
Mar
08
Change image hue with PHP
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 could be a small challenge but more on that to later. For now this is the php code that I used to change the hue on the images from the soria theme. I am using ImageMagick, specificly the modulateImage function. Yes, I did search and could not find any existing app that could batch change the hue, so PHP came to my rescue!