php8.5
Home/ Manual/ image / functions/ imagebmp

imagebmp

PHP function Edit on GitHub ✎

(PHP 7 >= 7.2.0, PHP 8)

Output a BMP image to browser or file

Description

imagebmp(GdImage $image, resource|string|null $file = null, bool $compressed = true): bool

Outputs or saves a BMP version of the given image.

Parameters

file

Path

Note

null is invalid if the compressed arguments is not used.

compressed

Whether the BMP should be compressed with run-length encoding (RLE), or not.

Return Values

Success

Trueonerror

Changelog

VersionDescription
8.0.0The type of compressed is Boolean now; formerly it was Integer.

Examples

Saving a BMP file

php
<?php
// Create a blank image and add some text
$im = imagecreatetruecolor(120, 20);
$text_color = imagecolorallocate($im, 233, 14, 91);

imagestring($im, 1, 5, 5,  'BMP with PHP', $text_color);

// Save the image
imagebmp($im, 'php.bmp');
?>

Source: reference/image/functions/imagebmp.xml · from the official PHP manual (php/doc-en)