Changing Hue in a image dynamically using GD

Is it possible to change the hue in a image from a location (image/logo.png) and resave to another location?
Sam CohenConsultant to Digital/DeveloperAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Hi there,

Having had a little look around, I stumbled across this link:

It looks as if changing the hue in the GD Library is not directly catered for. An alternative suggestion I saw was to use the ImageMagick library:

Hope that helps,
Sam CohenConsultant to Digital/DeveloperAuthor Commented:
how can i use this with a common image located in the image folder?
Ok, the code from that page is shown below.

As far as my knowledge goes, you'd have to change 2 things on the following line:
$im = imagecreatefrompng("b2.png") or die ("Cannot Initialize new GD image stream");

You'd need to change imagecreatefrompng to suit your image format i.e. imagecreatefromjpeg. You'd also need to change the filepath to your image i.e. imagecreatefromjpeg("/images/example.jpg").

If you want to save it, you need to change the following line:

and insert a file path like so:

Hope that helps,
function make_seed() {
    list($usec, $sec) = explode(' ', microtime());
    return (float) $sec + ((float) $usec * 100000);
if ($onetwoorthree+1>2)
//echo " ".$ar[0]." ".$ar[1]." ".$ar[2];
$im = imagecreatefrompng("b2.png") or die ("Cannot Initialize new GD image stream");
header ("Content-type: image/jpeg");
for ($x=0;$x<$width;$x++){
	for ($y=0;$y<$height;$y++){
		$rgb = ImageColorAt($im, $x, $y);
		$r = ($rgb >> 16) & 0xFF;
		$g = ($rgb >> 8) & 0xFF;
		$b = $rgb & 0xFF;
		$color = imagecolorallocate($im2, $r, $g, $b);

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Sam CohenConsultant to Digital/DeveloperAuthor Commented:
One more question. Where would i add the values, inorder to change the color?
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.