imagesettile 


gd apg

SET the tile image for filling.





This function sets the tile image to be used by all region filling functions, such as imagefill, imagefilledrectangle or imagefilledpolygon when filling with the special color IMG_COLOR_TILED.

This function returns TRUE on success or FALSE on failure.



<?php

bool imagesettile 
( GdImage $image, GdImage $tile )

where,

$image = The image identifier

$tile 
= The image identifier to be used as a tile

?>
 

  $image   


The image identifier.



  $tile   


The image identifier to be used as a tile.



  1 EXERCISE   

<?php

echo 'PHP VERSION: ' . PHP_VERSION . '<br><br>';

$base_img = 'jpeg/JPEG 032 01.jpg';

$tile_img = 'png/PNG 072 01.png';

$dest_img = 'jpeg/JPEG 032 01 imagesettile.jpg';

echo 
$tile_img; ?><br><br>Tile Image<br><br>
<img src="<?php echo $tile_img; ?>"
alt="<?php echo $tile_img; ?>"
title="<?php echo $tile_img; ?>" width="20"> <br><br>

<?php echo $base_img; ?><br><br>Base image<br><br>
<img src="<?php echo $base_img; ?>"
alt="<?php echo $base_img; ?>"
title="<?php echo $base_img; ?>" width="400"><br><br><br>

<?php

$id_base 
= imagecreatefromjpeg($base_img);
$id_tile = imagecreatefrompng($tile_img);

imagesettile($id_base, $id_tile);

$from_x = 0;
$from_y = 0;

$to_x = imagesx($id_base) - 1;
$to_y = imagesy($id_base) - 1;

imagefilledrectangle($id_base, 
                                 
$from_x, 
                                 
$from_y, 
                                 
$to_x, 
                                 
$to_y, 
                                 
IMG_COLOR_TILED);

imagejpeg($id_base, $dest_img, 90);

echo 
$dest_img; ?><br><br>Tiled Image<br><br>
<img src="<?php echo $dest_img; ?>"
alt="<?php echo $dest_img; ?>"
title="<?php echo $dest_img; ?>" width="400"><br><br> 


 RESULT   

PNG 072 01.png

Existing Tile Image

PNG 072 01.png apr

JPEG 032 01.jpg

Existing Base Image

JPEG 032 01.jpg apr


JPEG 032 01 imagesettile.jpg

Created Tiled Image

JPEG 032 01 imagesettile.jpg apr