imagesettle() เป็นฟังก์ชัน inbuilt ใน PHP ที่ใช้ตั้งค่ารูปภาพไทล์สำหรับการเติม มันตั้งค่ารูปภาพที่จะใช้โดยฟังก์ชันการเติมทุกภูมิภาค เช่น imagefill() และ imagefilledpolygon() เมื่อเติมด้วยสีพิเศษ IMG_COLOR_TILED
เราสามารถพูดได้ว่ากระเบื้องเป็นภาพที่ใช้เติมพื้นที่ที่มีรูปแบบซ้ำ เราสามารถใช้รูปภาพ GD เป็นไทล์ได้
ไวยากรณ์
bool imagesettile($image, $tile)
พารามิเตอร์
imagesettile() รับสองพารามิเตอร์:$image และ $tile.
-
$image − ถือภาพ GD
-
$กระเบื้อง − พารามิเตอร์ $tile ใช้เพื่อตั้งค่าทรัพยากรรูปภาพเป็นไทล์
คืนค่า
imagesettile() คืนค่า True เมื่อสำเร็จและ False เมื่อล้มเหลว
ตัวอย่างที่ 1
<?php
// Load the PNG image by using imagecreatefrompng() function.
$image = imagecreatefrompng('C:\xampp\htdocs\Images\img27.png');
// Create an image of 700x300 size
$img = imagecreatetruecolor(700, 300);
// Set the image tile
imagesettile($img, $image);
// Make the image repeat and IMG_COLOR_TILED is used
imagefilledrectangle($img, 0, 0, 300, 199, IMG_COLOR_TILED);
// Output an image to the browser
header('Content-Type: image/png');
imagepng($img);
imagedestroy($img);
imagedestroy($image);
?> ใส่รูปภาพ

ภาพที่ส่งออก

ตัวอย่างที่ 2
<?php
// Load the PNG image by using imagecreatefrompng() function.
$image = imagecreatefrompng('C:\xampp\htdocs\Images\img27.png');
// Create an image of 700x400 size
$img = imagecreatetruecolor(700, 400);
// Set the image tile
imagesettile($img, $image);
// Make the image repeat, IMG_COLOR_TILED is used
imagefilledrectangle($img, 0, 0, 390, 370, IMG_COLOR_TILED);
// Output an image to the browser
header('Content-Type: image/png');
imagepng($img);
imagedestroy($img);
imagedestroy($image);
?> ผลลัพธ์
