Color changing and PNG alpha

GD and GD2 are useful libraries for creating graphics on-the-fly. Discuss your PHP GD and GD2 scripts here.

Moderators: onion2k, General Moderators

Post Reply
Silverwings
Forum Newbie
Posts: 1
Joined: Thu Sep 13, 2007 7:02 pm

Color changing and PNG alpha

Post by Silverwings »

I'm trying to write up a little PHP script to allow a user to change a background color and then the color of a PNG with alpha that's sitting on top of it. I found this thread that's somewhat close:

viewtopic.php?t=43130&postdays=0&postorder=asc&start=0

but apparently I don't know enough about what's going on. There, ahsanra was trying to change specific colors in a picture, so I'm hoping that I can cannibalize that code to do what I want, but I'm not sure what does what. I just want to change the whole image to a different color, straight hex value replacement for every pixel... but retain the alpha values. Is that possible, and if so, how?

I'm hoping it'll be the same code for both the background and the image, and that the alpha channel ignores the hex value change. I would greatly appreciate any input that any of you could offer. I did do some searching, so please forgive me if my search-fu is weak. All I could dig up was the aforementioned thread.
Rovas
Forum Contributor
Posts: 272
Joined: Mon Aug 21, 2006 7:09 am
Location: Romania

Post by Rovas »

Try and use the following
http://alexle.net/archives/131 for saving alpha and use the first part of Rob script from here: http://www.php.net/manual/en/function.i ... parent.php
Post Reply