imagewbmp

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>
    <img src="data:image/vnd.wap.wbmp;base64,' . base64_encode($output) . '">
</body>
</html>';

?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AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=">
</body>
</html>

gd_info

getimagesize

getimagesizefromstring

image_type_to_extension

image_type_to_mime_type

imageaffine

imageaffinematrixconcat

imageaffinematrixget

imagealphablending

imageantialias

imagearc

imageavif

imagebmp

imagechar

imagecharup

imagecolorallocate

imagecolorallocatealpha

imagecolorat

imagecolorclosest

imagecolorclosestalpha

imagecolorclosesthwb

imagecolordeallocate

imagecolorexact

imagecolorexactalpha

imagecolormatch

imagecolorresolve

imagecolorresolvealpha

imagecolorset

imagecolorsforindex

imagecolorstotal

imagecolortransparent

imageconvolution

imagecopy

imagecopymerge

imagecopymergegray

imagecopyresampled

imagecopyresized

imagecreate

imagecreatefromavif

imagecreatefrombmp

imagecreatefromgif

imagecreatefromjpeg

imagecreatefrompng

imagecreatefromstring

imagecreatefromtga

imagecreatefromwbmp

imagecreatefromwebp

imagecreatefromxbm

imagecreatefromxpm

imagecreatetruecolor

imagecrop

imagecropauto

imagedashedline

imagedestroy

imageellipse

imagefill

imagefilledarc

imagefilledellipse

imagefilledpolygon

imagefilledrectangle

imagefilltoborder

imagefilter

imageflip

imagefontheight

imagefontwidth

imageftbbox

imagefttext

imagegammacorrect

imagegetclip

imagegetinterpolation

imagegif

imageinterlace

imageistruecolor

imagejpeg

imagelayereffect

imageline

imageloadfont

imageopenpolygon

imagepalettecopy

imagepalettetotruecolor

imagepng

imagepolygon

imagerectangle

imageresolution

imagerotate

imagesavealpha

imagescale

imagesetbrush

imagesetclip

imagesetinterpolation

imagesetpixel

imagesetstyle

imagesetthickness

imagesettile

imagestring

imagestringup

imagesx

imagesy

imagetruecolortopalette

imagettfbbox

imagettftext

imagetypes

imagewebp

imagexbm

iptcembed

iptcparse

HomeMenu