Color and Image Fills in PHP

Description

The following code shows how to color and Image Fills.

Example


<?php/*from  w w w  . j  a  va  2  s . c o m*/
    $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("test.png");
    imagesettile($image, $bg);
    imagefill($image, 0, 0, IMG_COLOR_TILED);
    header("content-type: image/png");

    imagepng($image);
    imagedestroy($image);
    imagedestroy($bg);
?>




















Home »
  PHP Tutorial »
    Image »




Color
Create
Font
Operation
Shape
Text