PHP | imagebmp() Function
Last Updated :
28 Jan, 2020
Improve
The imagebmp() function is an inbuilt function in PHP which is used to return the output or save a BMP version of the given image.
Syntax:
php
Output:
Program 2 (Converting a image into bmp):
php
Output:
Reference: https://www.php.net/manual/en/function.imagebmp.php
bool imagebmp( resource $image, mixed $to, bool $compressed )Parameters: This function accept three parameters as mentioned above and described below:
- $image: It specifies the image to be converted.
- $to (Optional): It specifies the path to save file to.
- $compressed (Optional): It specifies whether BMP should be compressed with run-length encoding or not.
<?php
// Create a blank image
$im = imagecreatetruecolor(120, 100);
// Add text in image
$text_color = imagecolorallocate($im, 200, 240, 21);
imagestring($im, 1, 5, 50, 'GeeksforGeeks', $text_color);
// Output that image as bmp
header("Content-Type: image/bmp");
imagebmp($im);
?>

<?php
// Create a image from URL
$im = imagecreatefrompng(
'https://media.geeksforgeeks.org/wp-content/uploads/geeksforgeeks-13.png');
// Output that image as bmp
header("Content-Type: image/bmp");
imagebmp($im);
?>
