Dutch PHP Conference 2025 - Call For Papers

imagebmp

(PHP 7 >= 7.2.0, PHP 8)

imagebmpOutput a BMP image to browser or file

Опис

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

Outputs or saves a BMP version of the given image.

Параметри

image

Об'єкт GdImage, що повертається однією з функцій створення зображення, такою як imagecreatetruecolor().

file

Шлях або відкритий ресурс потоку (котрий автоматично закривається після повернення з цієї функції) для збереження файла. Якщо не встановлено або дорівнює null, буде виведено двійковий код зображення.

Зауваження:

null is invalid if the compressed arguments is not used.

compressed

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

Значення, що повертаються

Повертає true у разі успіху або false в разі помилки.

Застереження

Проте, якщо libgd не може вивести зображення, ця функція повертає true.

Журнал змін

Версія Опис
8.0.0 Тепер image має бути примірником GdImage. Раніше очікувався gd-resource.
8.0.0 The type of compressed is bool now; formerly it was int.

Приклади

Приклад #1 Saving a BMP file

<?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');

// Free up memory
imagedestroy($im);
?>

add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top