PHP/Graphics Image/imagecreatefrompng
Color and Image Fills
<?php
$red = imagecolorallocate($image, 255, 0, 0);
imagefill($image, 0, 0, $red);
imagefilltoborder($image, 0, 0, $white, $red);
$_GET["size"] = 44;
$_GET["text"] = "Hello, world!";
$size = imagettfbbox($_GET["size"], 0, "ARIAL", $_GET["text"]);
$xsize = 50;
$ysize = 60;
$image = imagecreate($xsize, $ysize);
$blue = imagecolorallocate($image, 0, 0, 255);
$white = ImageColorAllocate($image, 255,255,255);
imagettftext($image, $_GET["size"], 0, abs($size[0]), $ysize, $white, "ARIAL","asdfasdf");
$bg = imagecreatefrompng("button_mini.png");
imagesettile($image, $bg);
imagefill($image, 0, 0, IMG_COLOR_TILED);
header("content-type: image/png");
imagepng($image);
imagedestroy($image);
imagedestroy($bg);
?>
Create image object from PNG
<?php
$stars = imagecreatefrompng("stars.png");
$gradient = imagecreatefrompng("gradient.png");
imagecopymerge($stars, $gradient, 0, 0, 0, 0, 256, 256, 60);
header("Content-type: image/png");
imagepng($stars);
imagedestroy($stars);
imagedestroy($gradient);
?>
Loading Existing Images
<?php
$_GET["size"] = 26;
$_GET["text"] = "Button text";
$size = imagettfbbox($_GET["size"], 0, "ARIAL", $_GET["text"]);
$xsize = abs($size[0]) + abs($size[2]);
$ysize = abs($size[5]) + abs($size[1]);
$image = imagecreatefrompng("button.png");
$imagesize = getimagesize("button.png");
$textleftpos = round(($imagesize[0] - $xsize) / 2);
$texttoppos = round(($imagesize[1] + $ysize) / 2);
$white = ImageColorAllocate($image, 255,255,255);
imagettftext($image, $_GET["size"], 0, $textleftpos, $texttoppos, $white, "ARIAL",
$_GET["text"]);
header("content-type: image/png");
imagepng($image);
imagedestroy($image);
?>