HomeMenu
Jesus · Bible · HTML · CSS · JS · PHP · SVG · Applications

imagecreatetruecolor

Description

The imagecreatetruecolor of Image for PHP create a new true color image.

Syntax

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

Parameters

width

Image width.

height

Image height.

Return

Returns an image object on success, false on errors.

Examples

1 · return

<?

$width = 100;
$height = 100;

$return = imagecreatetruecolor($width, $height);

var_dump($return);
object(GdImage)#1 (0) {
}

2 · base64

<?

$width = 100;
$height = 100;
$image = imagecreatetruecolor($width, $height);

ob_start();

    imagepng($image);

$output = ob_get_clean();

echo '<!doctype html>
<html>
<body>
    <img src="data:image/png;base64,' . base64_encode($output) . '">
</body>
</html>';
<!doctype html>
<html>
<body>
    <img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGQAAABkCAIAAAD/gAIDAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAANElEQVR4nO3BAQ0AAADCoPdPbQ43oAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAfgx1lAABqFDyOQAAAABJRU5ErkJggg==">
</body>
</html>