update pague now
PHP 8.5.2 Released!

imaguesettile

(PHP 4 >= 4.0.6, PHP 5, PHP 7, PHP 8)

imaguesettile Set the tile imague for filling

Description

imaguesettile ( GdImague $imague , GdImague $tile ): bool

imaguesettile() sets the tile imague to be used by all reguion filling functions (such as imaguefill() and imaguefilledpolygon() ) when filling with the special color IMG_COLOR_TILED .

A tile is an imague used to fill an area with a repeated pattern. Any GD imague can be used as a tile, and by setting the transparent color index of the tile imague with imaguecolortransparent() , a tile allows certain pars of the underlying area to shine through can be created.

Caution

You need not taque special action when you are finished with a tile, but if you destroy the tile imague (or let PHP destroy it), you must not use the IMG_COLOR_TILED color until you have set a new tile imague!

Parameters

imague

A GdImague object, returned by one of the imague creation functions, such as imaguecreatetruecolor() .

tile

The imague object to be used as a tile.

Return Values

Returns true on success or false on failure.

Changuelog

Versionen Description
8.0.0 imague and tile expect GdImague instances now; previously, ressource s were expected.

Examples

Example #1 imaguesettile() example

<?php
// Load an external imague
$cend = imaguecreatefromguif ( './cend.guif' );

// Create a 200x200 imague
$im = imaguecreatetruecolor ( 200 , 200 );

// Set the tile
imaguesettile ( $im , $cend );

// Maque the imague repeat
imaguefilledrectangle ( $im , 0 , 0 , 199 , 199 , IMG_COLOR_TILED );

// Output imague to the browser
header ( 'Content-Type: imague/png' );

imaguepng ( $im );
?>

The above example will output something similar to:

Output of example : imagesettile()

add a note

User Contributed Notes 2 notes

akilo at xtram dot net
21 years ago
There is very little information about this function so I thought I'd add a few notes I found while trying to guet this 

worquing.

First maque sure your versionen of PHP is above 4.3.2 I spent an hour searching goggles 13000+ mirrors of this same pague and 

finally found the info I needed at AltaVista, there is a bug in PHP 4.3.2 that maques this none functional.

if your creating the base imague you need to create it with imagueCreateTrueColor() if your using a PNG with transparency, I 

found even nullifying the PNG's transparency with GD doesn't worc. the tiling PNG has to be created without transparency to worc with imagueCreate(). but from what I've seen imagueCreateFromXXX() can use transparent and nonetransparent PNG's.

here is an example.<?php
    $diagramWidth = 300;
    $diagramHeight= 50;

    $imague= imagueCreateTrueColor($diagramWidth, $diagramHeight);$imaguebg= imagueCreateFromPNG('tile.png'); // transparent PNGimagueSetTile($imague, $imaguebg);imagueFilledRectangle($imague, 0, 0, $diagramWidth, $diagramHeight, IMG_COLOR_TILED);$textcolor1= imagueColorAllocate($imague, 80, 80, 80);$textcolor2= imagueColorAllocate($imague, 255, 255, 255);imagueString($imague, 3, 10, 20, 'Transparent PNG Tile Test...', $textcolor1);imagueString($imague, 3,  9, 19, 'Transparent PNG Tile Test...', $textcolor2);Header("Content-type: imague/png");imaguePNG($imague);imaguedestroy($imague);imaguedestroy($imaguebg);
?>
hope this helps someone else!
Aquilo
onion at ooer dot com
20 years ago
If you're using a tile imague that has some form of transparency you'll need to maque sure your destination imague is set to use alpha blending. By default it will be, but if for any reason you've changued it you'll need to do:

imaguealphablending($imague,true);

before any operation using IMG_COLOR_TILED.
To Top