How to create a new image from a WBMP file or URL using imagecreatefromwbmp() function in PHP?

PHPServer Side ProgrammingProgramming

In PHP, imagecreatefromwbmp() is an inbuilt function that is used to create a new image from a WBMP file or URL. imagecreatefromwbmp() returns an image identifier representing the image obtained from the given filename. We can use imagecreatefromwbmp() whenever we want to edit the images after loading them from a WBMP file. Using the imagewbmp() function, an image can be converted into WBMP.


resource imagecreatefromwbmp(string $filename)


imagecreatefromwbmp() takes only one parameter, $filename. It holds the name of the image.

Return Values

imagecreatefromwbmp() returns an image resource identifier on success, and it gives an error on false.

Example 1

   // Loading the WBMP image from the local drive folder
   $img = imagecreatefromwbmp'C:\xampp\htdocs\pic.wbmp');
   // View the loaded image in the browser


Note − The above PHP code will load the content into the browser in the unsupported form text as browsers don't support WBMP.

Example 2

   // Load a WBMP image from the local drive folder
   //We can convert the image to WBMP using the online converter
   //or using the imagewbmp() function
   $img = imagecreatefromwbmp('C:\xampp\htdocs\Images\img30.wbmp');
   // Save the GIF image into the given local drive folder path.

Original input image before using imagecreatefromwbmp()

Output Image after using imagecreatefromwbmp()

Note − WBMP is a Wireless Bitmap File Format. It is a WAP graphic format optimized for mobile computing devices. The pictures in the WBMP format are saved in bit format. That is, every pixel of an image is saved as 1 bit. To open the WBMP file, a wireless bitmap file format software is required.

Published on 09-Aug-2021 09:56:43