array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'ja', ), 'this' => array ( 0 => 'function.imagegd2.php', 1 => 'imagegd2', ), 'up' => array ( 0 => 'ref.image.php', 1 => 'GD および Image 関数', ), 'prev' => array ( 0 => 'function.imagegammacorrect.php', 1 => 'imagegammacorrect', ), 'next' => array ( 0 => 'function.imagegd.php', 1 => 'imagegd', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'ja', 'path' => 'reference/image/functions/imagegd2.xml', ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); ?>
(PHP 4 >= 4.0.7, PHP 5, PHP 7, PHP 8)
imagegd2 — GD2 イメージをブラウザまたはファイルに出力する
$image
,$file
= null
,$chunk_size
= 128,$mode
= IMG_GD2_RAW
GD2 イメージを、指定した file
に出力します。
image
imagecreatetruecolor()のような画像作成関数が返す GdImage オブジェクト。
file
ファイル保存先のパスあるいはオープン中のリソース (この関数が値を戻した後で自動的にクローズされます)。省略したり null
を設定したりした場合は、画像ストリームを直接出力します。
chunk_size
チャンクの大きさ。
mode
IMG_GD2_RAW
あるいは
IMG_GD2_COMPRESSED
のいずれかです。デフォルトは
IMG_GD2_RAW
です。
バージョン | 説明 |
---|---|
8.0.3 |
file は、nullable になりました。
|
8.0.0 |
image は、
GdImage
クラスのインスタンスを期待するようになりました。
これより前のバージョンでは、有効な gd resource が期待されていました。
|
例1 GD2 画像の出力
<?php
// 空の画像を作成し、テキストを追加します
$im = imagecreatetruecolor(120, 20);
$text_color = imagecolorallocate($im, 233, 14, 91);
imagestring($im, 1, 5, 5, "A Simple Text String", $text_color);
// 画像を出力します
imagegd2($im);
// メモリを開放します
imagedestroy($im);
?>
例2 GD2 画像の保存
<?php
// 空の画像を作成し、テキストを追加します
$im = imagecreatetruecolor(120, 20);
$text_color = imagecolorallocate($im, 233, 14, 91);
imagestring($im, 1, 5, 5, "A Simple Text String", $text_color);
// GD2 画像を保存します
// GD2 画像のファイル形式は .gd2 です。 http://www.libgd.org/GdFileFormats を参照ください
imagegd2($im, 'simple.gd2');
// メモリを開放します
imagedestroy($im);
?>
注意:
通常 GD2 フォーマットはイメージの一部を高速にロードするために 使用されます。GD2 フォーマットは GD2 互換アプリケーションでのみ使用可能であることに注意してください。
GD と GD2 画像フォーマットは libgd が作った独自仕様の画像フォーマットです。これらは obsolete と見なされているため、開発とテストの用途にだけ使うべきです。