I’m dynaically creating images using *imagecreatetruecolor(), *and I’m purposefully leaving the bottom half of the created image blank because it’s going to be the rollover state of the image.
How can you specify the backround colour of an image created using *imagecreatetruecolor()?
*This is my function so far:
function create_thumb($name,$filename,$new_w,$new_h){
$src_img = imagecreatefromjpeg($name);
$original_x = imagesx($src_img);
$original_y = imagesy($src_img);
$dst_img = imagecreatetruecolor($new_w,$new_h*2);
imagecolorset($dst_img, 0, 255, 0, 0);
$half_x = $original_x / 2;
$half_y = $original_y / 2;
$min_x = $half_x - ($half_x/2);
$max_x = $half_x + ($half_x/2);
$min_y = $half_y - ($half_y/2);
$max_y = $half_y + ($half_y/2);
$start_x = rand($min_x, $max_x);
$start_y = rand($min_y, $max_y);
imagecopyresampled($dst_img, $src_img, 0, 0, $start_x, $start_y, $new_w, $new_h, $new_w, $new_h);
imagejpeg($dst_img, $filename);
imagedestroy($dst_img);
imagedestroy($src_img);
}
create_thumb("ayako_tanaka-8.jpg", "course-thumbs/ayako_tanaka_cover.jpg", 98, 73);