Computer >> Hướng Dẫn Máy Tính >  >> Lập Trình >> PHP

Hàm imagecreatetruecolor() trong PHP

imagecreatetruecolor() tạo hình ảnh true color mới (24-bit RGB).

Cú pháp

imagecreatetruecolor(int $width, int $height): resource|false

Tham số

  • width: Chiều rộng (pixel).
  • height: Chiều cao (pixel).

Trả về

Resource hình ảnh (image resource) nếu thành công, false nếu lỗi.

Ví dụ

<?php
$img = imagecreatetruecolor(600, 500);
echo imagesy($img) . "
"; // 500 (chiều cao) echo imagesx($img); // 600 (chiều rộng) ?>

Ví dụ 2

<?php
$img = imagecreatetruecolor(300, 450);
echo imagesy($img) . "
"; // 450 echo imagesx($img); // 300 ?>