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

imagewbmp

Description

The imagewbmp of Image for PHP output image to browser or file.

Syntax

imagewbmp(
    GdImage $image,
    resource|string|null $file = null,
    ?int $foreground_color = null
): bool

Parameters

image

A GdImage object, returned by one of the image creation functions, such as imagecreatetruecolor().

file

The path or an open stream resource (which is automatically closed after this function returns) to save the file to. If not set or null, the raw image stream will be output directly.

foreground_color

You can set the foreground color with this parameter by setting an identifier obtained from imagecolorallocate(). The default foreground color is black.

Return

Returns true on success or false on failure.

Caution: However, if libgd fails to output the image, this function returns true.

Examples

1 · image

<?

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

$return = imagewbmp($image);

var_export($return);

?>
ddtrue

2 · file

<?

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

$file = $_SERVER['DOCUMENT_ROOT'] . '/assets/wbmp/1.wbmp';

$return = imagewbmp($image, $file);

var_export($return);

?>
true

3 · foreground_color

<?

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

$file = $_SERVER['DOCUMENT_ROOT'] . '/assets/wbmp/1.wbmp';

$red = 255;
$green = 255;
$blue = 255;
$foreground_color = imagecolorallocate($image, $red, $green, $blue);

$return = imagewbmp($image, $file, $foreground_color);

var_export($return);

?>
true

4 · header

<?

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

header("content-type: image/vnd.wap.wbmp");

imagewbmp($image);

?>
dd

5 · path

<?

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

$path = "/assets/wbmp/1.wbmp";
$file = $_SERVER['DOCUMENT_ROOT'] . $path;
imagewbmp($image, $file);

echo '<!doctype html>
<html>
<body>
    <img src="' . $path . '">
</body>
</html>';

?>
<!doctype html>
<html>
<body>
    <img src="/assets/wbmp/1.wbmp">
</body>
</html>

6 · base64

<?

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

ob_start();

    imagewbmp($image);

$output = ob_get_clean();

echo '<!doctype html>
<html>
<body>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