Friday, June 12, 2026
HomeLanguagesPHP | imagewbmp() Function

PHP | imagewbmp() Function

The imagewbmp() function is an inbuilt function in PHP which is used to display image to browser or file. The main use of this function is to view an image in the browser and convert any other image type to WBMP.

Syntax:

bool imagewbmp( resource $image, int $to, int $foreground )

Parameters: This function accept three parameters as mentioned above and described below:

  • $image: It specifies the image resource file to perform operation.
  • $to (Optional): It specifies the path to save the file.
  • $foreground (Optional): It specifies the foreground of the image.

Return Value: This function returns TRUE on success or FALSE on error.

Below examples illustrate the imagewbmp() function in PHP:

Example 1: In this example we will be downloading an image in browser.




<?php
  
// Load an wbmp image from local folder
// Image can be converted into wbmp using
// online convertors or imagewbmp
$im = imagecreatefromwbmp('neveropen.wbmp');
  
// Download the image
header('Content-Type: image/vnd.wap.wbmp');
imagewbmp($im);
imagedestroy($im);
?>


Output:

This will download your image as download, further you can rename
this file to anything like neveropen.wbmp and use it.

Example 2: In this example we will convert PNG into WBMP.




<?php
  
// Load an image from PNG URL
$im = imagecreatefrompng(
  
// Convert the image into WBMP using imagewbmp() function
imagewbmp($im, 'converted.wbmp');
imagedestroy($im);
?>


Output:

This will save the WBMP version of image in the same
folder where your PHP script exist.

Reference: https://www.php.net/manual/en/function.imagewbmp.php

RELATED ARTICLES

Most Popular

Dominic
32515 POSTS0 COMMENTS
Milvus
131 POSTS0 COMMENTS
Nango Kala
6897 POSTS0 COMMENTS
Nicole Veronica
12013 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12109 POSTS0 COMMENTS
Shaida Kate Naidoo
7019 POSTS0 COMMENTS
Ted Musemwa
7262 POSTS0 COMMENTS
Thapelo Manthata
6976 POSTS0 COMMENTS
Umr Jansen
6964 POSTS0 COMMENTS