I’ve been working with an image layering code for a while now. Currently I have one that is working properly but it will only recolor images saved in PNG-8 which makes the images look rather choppy. Ideally, I would like to be able to recolor my images saved in PNG-24 but I’m having trouble finding a code for this if its even possible. My current code is layering everything properly, just omits the recoloring of the “stockings2.png” file. Any advice is GREATLY appreciated! I’ve been ripping my hair out over this ? Here is my current code:
[code=php]
<?php
(“Content-type: image/png”);
include “dbconnect.php”;
$hid=$_GET[‘id’];
// Get new dimensions
list($width, $height) = getimagesize(‘horses/ridingpony/base.png’);
$new_width=$width;
$new_height=$height;
$horsecolor = $_GET[‘color’];
$red = hexdec(substr($horsecolor, 0, 2));
$green = hexdec(substr($horsecolor, 2, 2));
$blue = hexdec(substr($horsecolor, 4, 2));
//load the horse’s base image
$image_p = @imagecreatetruecolor($new_width, $new_height);
$image = imagecreatefrompng(‘horses/ridingpony/background.png’);
imagealphablending($image_p, true);
imagesavealpha($image_p, true);
imagecopyresampled($image_p, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
$image1 = imagecreatefrompng(‘horses/ridingpony/stockings2.png’);
imagecolorset($image1, 0, $red, $green, $blue);
imagealphablending($image_p, true);
imagecopyresampled($image_p, $image1, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
imagesavealpha($image_p, true);
$image = imagecreatefrompng(‘horses/ridingpony/shading.png’);
imagealphablending($image_p, true);
imagesavealpha($image_p, true);
imagecopyresampled($image_p, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
$image = imagecreatefrompng(‘horses/ridingpony/lines.png’);
imagealphablending($image_p, true);
imagesavealpha($image_p, true);
imagecopyresampled($image_p, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
//create the horse’s image
imagepng($image_p, ‘horseimages/hi.gif’);
print “<img src=horseimages/hi.gif>”;
?>