array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'ja', ), 'this' => array ( 0 => 'function.imagewbmp.php', 1 => 'imagewbmp', ), 'up' => array ( 0 => 'ref.image.php', 1 => 'GD および Image 関数', ), 'prev' => array ( 0 => 'function.imagetypes.php', 1 => 'imagetypes', ), 'next' => array ( 0 => 'function.imagewebp.php', 1 => 'imagewebp', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'ja', 'path' => 'reference/image/functions/imagewbmp.xml', ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); ?>
(PHP 4 >= 4.0.1, PHP 5, PHP 7, PHP 8)
imagewbmp — 画像をブラウザあるいはファイルに出力する
imagewbmp() は、指定した
image
を
WBMP にして出力あるいは保存します。
image
imagecreatetruecolor()のような画像作成関数が返す GdImage オブジェクト。
file
ファイル保存先のパスあるいはオープン中のリソース (この関数が値を戻した後で自動的にクローズされます)。省略したり null
を設定したりした場合は、画像ストリームを直接出力します。
foreground_color
このパラメータで、 前景の色を指定できます。imagecolorallocate() で 取得した ID を使用してください。デフォルトの前景色は黒です。
バージョン | 説明 |
---|---|
8.0.0 |
image は、
GdImage
クラスのインスタンスを期待するようになりました。
これより前のバージョンでは、有効な gd resource が期待されていました。
|
8.0.0 |
foreground_color は、
nullable になりました。
|
例1 WBMP 画像の出力
<?php
// 空の画像を作成してテキストを追加します
$im = imagecreatetruecolor(120, 20);
$text_color = imagecolorallocate($im, 233, 14, 91);
imagestring($im, 1, 5, 5, 'A Simple Text String', $text_color);
// content type ヘッダを設定します - ここでは image/vnd.wap.wbmp
// ヒント: image_type_to_mime_type() で content-types を取得します
header('Content-Type: image/vnd.wap.wbmp');
// 画像を出力します
imagewbmp($im);
// メモリを開放します
imagedestroy($im);
?>
例2 WBMP 画像の保存
<?php
// 空の画像を作成してテキストを追加します
$im = imagecreatetruecolor(120, 20);
$text_color = imagecolorallocate($im, 233, 14, 91);
imagestring($im, 1, 5, 5, 'A Simple Text String', $text_color);
// 画像を保存します
imagewbmp($im, 'simpletext.wbmp');
// メモリを開放します
imagedestroy($im);
?>
例3 別の前景での画像の出力
<?php
// 空の画像を作成してテキストを追加します
$im = imagecreatetruecolor(120, 20);
$text_color = imagecolorallocate($im, 233, 14, 91);
imagestring($im, 1, 5, 5, 'A Simple Text String', $text_color);
// content type ヘッダを設定します - ここでは image/vnd.wap.wbmp
// ヒント: image_type_to_mime_type() で content-types を取得します
header('Content-Type: image/vnd.wap.wbmp');
// 別の前景色を設定します
$foreground_color = imagecolorallocate($im, 255, 0, 0);
imagewbmp($im, NULL, $foreground_color);
// メモリを開放します
imagedestroy($im);
?>