Thursday, October 16, 2025
HomeLanguagesPHP | imagecreatefromxbm() function

PHP | imagecreatefromxbm() function

The imagecreatefromxbm() function is an inbuilt function in PHP which is used to create a new image from XBM file or URL. XBM file extension is an X Bitmap Graphics file used for Graphical UI systems. This loaded image can be further worked upon in the program. This function is usually used when you want to edit your images after loading them from an XBM file. An image can be converted into XBM using imagexbm() function.

Syntax:

resource imagecreatefromxbm( string $filename )

Parameters:This function accepts a single parameter $filename which holds the name of image.

Return Value: This function returns an image resource identifier on success, FALSE on errors.

Below given programs illustrate the imagecreatefromxbm() function in PHP:
Program 1:




<?php
// Load an XBM image from local folder
// You can convert any image to XBM using
// imagexbm() function or online convertors
$im = imagecreatefromxbm('./neveropen.xbm');
  
// View the loaded image in browser
imagexbm($im);
imagedestroy($im);
?>


Output:

This will load the content into browser in the form of unsupported text as browsers don't support XBM.

Program 2:




<?php
// Load an XBM image from local folder
// You can convert any image to XBM using
// imagexbm() function or online convertors
$im = imagecreatefromxbm('./neveropen.xbm');
  
// Output the image by converting it into PNG
header('Content-type: image/png');
imagepng($im);
imagedestroy($im);
?>


Output:

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

RELATED ARTICLES

Most Popular

Dominic
32361 POSTS0 COMMENTS
Milvus
88 POSTS0 COMMENTS
Nango Kala
6728 POSTS0 COMMENTS
Nicole Veronica
11892 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11954 POSTS0 COMMENTS
Shaida Kate Naidoo
6852 POSTS0 COMMENTS
Ted Musemwa
7113 POSTS0 COMMENTS
Thapelo Manthata
6805 POSTS0 COMMENTS
Umr Jansen
6801 POSTS0 COMMENTS