PHP 8.1.24 Released!

imagebmp

(PHP 7 >= 7.2.0, PHP 8)

imagebmpOutput a BMP image to browser or file

Descrição

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

Outputs or saves a BMP version of the given image.

Parâmetros

image

Um objeto GdImage, retornado por uma das funções de criação de imagem, como imagecreatetruecolor().

file

O caminho ou um recurso de stream aberto (que será fechado automaticamente após o retorno desta função) para salvar o arquivo. Se não for definido ou for null, o stream da imagem bruta será enviado diretamente.

Nota:

null is invalid if the compressed arguments is not used.

compressed

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

Valor Retornado

Retorna true em caso de sucesso ou false em caso de falha.

Cuidado

Entretanto, se a biblioteca libgd falhar ao gerar a imagem, esta função retornará true.

Changelog

Versão Descrição
8.0.0 O parâmetro image agora espera uma instância de GdImage; anteriormente, um resource gd válido era esperado.
8.0.0 The type of compressed is bool now; formerly it was int.

Exemplos

Exemplo #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