imagewbmp CREATE a particular WBPM (Wireless Application Protocol Bitmap Format) image to be shown in a browser or stored in a file.
This function creates a WBMP file in $file from the $image which is created by imagecreate or imagecreatetruecolor, for example.
PALETTE IMAGE
is the designation term for images with a small number of colors.
For this type of image, a maximum of 256 colors are accepted.
TRUECOLOR IMAGE
is the designation term for images with a great number of colors.
For this type of image, a maximum of 16,777,216 colors are accepted.
This function returns TRUE on success or FALSE on failure.
However, if libgd fails to output the image, this function returns TRUE.
The WBMP (Wireless Application Protocol Bitmap Format)
(shortened to Wireless Bitmap and with file extension .wbmp) is a monochrome graphics file format optimized for mobile computing devices.
WBMP images are monochrome (black & white) so that the image size is kept to a minimum.
A black pixel is denoted by 0 and a white pixel is denoted by 1.
From Wikipedia, the free encyclopedia.
The WBMP (Wireless Application Protocol Bitmap Format)
comes from the "X Window System", (UNIX and Linux), and is used to store small images such as cursors and icons used in the X graphical interface.
Its support has been removed in major browsers on the Windows™ environment.
However such support is maintained in the most common editors, (GIMP, PhotoShop and PaintShop).
<?php
bool imagewbmp imagewbmp( GdImage $image,
resource|string|null $file = null,
?int $foreground_color = null )
where,
$image = The image identifier
$file = The path or stream resource
( SEE the below TABLE )
$foreground_color = The foreground color obtained
from imagecolorallocate
?>
$image
The image identifier.
$file
The path or stream resource.
$file can reference a local file or, (configuration permitting), a remote file using one of the supported stream wrappers:
STREAM WRAPPERS |
MEANING |
file:// |
LOCAL File System |
http:// |
URL HTTP |
ftp:// |
URL FTP |
php:// |
I/O streams |
zlib:// |
Data Compression stream |
data:// |
DATA (RFC-2397) |
glob:// |
Find Filenames |
phar:// |
PHP Archive |
ssh2:// |
Secure Shell 2 |
rar:// |
RAR |
ogg:// |
Audio |
expect:// |
Interaction of stream processes |
ed48 |
If not set or null, the raw image stream will be output directly.
$foreground_color
The foreground color.
The default foreground color is black.
The $foreground_color is nullabe since PHP 8.0.0.
EXERCISE
<?php
echo 'PHP VERSION: ' . PHP_VERSION . '<br><br>';
$var = getcwd();
define('PBWWP', 'file://' . $var . '/wbmp/');
echo PBWWP . '<br><br>';
// STREAM WRAPPER MODE
$im01 = imagecreatetruecolor (50, 50);
$black = imagecolorallocate($im01, 0, 0, 0);
$white = imagecolorallocate($im01, 255, 255, 255);
$img_file_name = PBWWP . 'WBMP 001 01.wbmp';
$quality01 = 60;
$bool01 = imagewbmp($im01, $img_file_name, $black);
if ($bool01 == TRUE)
{
$mess01 = 'The image was created
<br>BUT CAN NOT be displayed!';
echo '$bool01 = ';
var_dump($bool01);
echo '<br><br>' . $mess01;
imagedestroy($im01);
}
else
{
$mess01 = 'The image COULD NOT BE CREATED!';
echo $mess01;
}
?>
RESULT
WBMP 001 01.wbmp
$bool01 = bool(true)
The image was created
BUT CAN NOT be displayed!
EXERCISE
<?php
// Try this code
echo 'PHP VERSION: ' . PHP_VERSION . '<br><br>';
$im02 = imagecreate (50, 50);
$blue = imagecolorallocate($im02, 0, 0, 255);
$green = imagecolorallocate($im02, 0, 255, 0);
$white = imagecolorallocate($im02, 255, 255, 255);
$img_file_name = NULL;
$quality02 = 60;
$bool02 = imagewbmp($im02, $img_file_name, $blue);
if ($bool02 == TRUE)
{
$mess02 = 'The image was created
<br>BUT CAN NOT be displayed!<br>';
echo '<br><br>$bool02 = ';
var_dump($bool02);
echo '<br><br>' . $mess02;
imagedestroy($im02);
}
else
{
$mess02 = 'The image COULD NOT BE CREATED!';
echo $mess02;
}
?>
RESULT
WBMP 002 02.wbmp
$bool02 = bool(true)
The image was created
BUT CAN NOT be displayed!