ฟังก์ชัน imagecolortransparent() ตั้งค่าสีโปร่งใส (Transparent) ของภาพ
ไวยากรณ์
imagecolortransparent (img, color)
พารามิเตอร์
- img: ภาพจาก imagecreatetruecolor()
- color: Color identifier จาก imagecolorallocate()
คืนค่า
คืน identifier ของสีโปร่งใสใหม่ -1 ถ้าไม่ระบุสีและภาพไม่มีสีโปร่งใส
ตัวอย่าง
<?php
$img = imagecreatetruecolor(500, 400);
$blue = imagecolorallocate($img, 0, 0, 255);
$transparent = imagecolorallocate($img, 0, 0, 0);
imagecolortransparent($img, $transparent);
imagefilledrectangle($img, 80, 90, 400, 220, $blue);
header('Content-Type: image/png');
imagepng($img);
imagedestroy($img);
?>
ผลลัพธ์
