Php/docs/function.imagewbmp

提供:Dev Guides
< Php
移動先:案内検索

imagewbmp

(PHP 4 >= 4.0.1, PHP 5, PHP 7)

imagewbmp画像をブラウザあるいはファイルに出力する


説明

imagewbmp ( resource $image [, mixed $to = null [, int $foreground ]] ) : bool

imagewbmp() は、指定した image を WBMP にして出力あるいは保存します。


パラメータ

image
imagecreatetruecolor() のような画像作成関数が返す画像リソース。
to
ファイル保存先のパスあるいはオープン中のリソース (この関数が値を戻した後で自動的にクローズされます)。省略したり null を設定したりした場合は、画像ストリームを直接出力します。
foreground
このパラメータで、 前景の色を指定できます。imagecolorallocate() で 取得した ID を使用してください。デフォルトの前景色は黒です。


返り値

成功した場合に true を、失敗した場合に false を返します。

警告 しかしながら、libgd がイメージの出力に失敗した場合、この関数は true を返します。


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

参考

  • image2wbmp() - 画像をブラウザあるいはファイルに出力する
  • imagepng() - PNG イメージをブラウザまたはファイルに出力する
  • imagegif() - 画像をブラウザあるいはファイルに出力する
  • imagejpeg() - 画像をブラウザあるいはファイルに出力する
  • imagetypes() - この PHP がサポートしている画像形式を返す