array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'ja', ), 'this' => array ( 0 => 'function.imageistruecolor.php', 1 => 'imageistruecolor', ), 'up' => array ( 0 => 'ref.image.php', 1 => 'GD および Image 関数', ), 'prev' => array ( 0 => 'function.imageinterlace.php', 1 => 'imageinterlace', ), 'next' => array ( 0 => 'function.imagejpeg.php', 1 => 'imagejpeg', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'ja', 'path' => 'reference/image/functions/imageistruecolor.xml', ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); ?>
(PHP 4 >= 4.3.2, PHP 5, PHP 7, PHP 8)
imageistruecolor — 画像が truecolor かどうか調べる
バージョン | 説明 |
---|---|
8.0.0 |
image は、
GdImage
クラスのインスタンスを期待するようになりました。
これより前のバージョンでは、有効な gd resource が期待されていました。
|
例1 imageistruecolor() による、シンプルな true color 画像の検出
<?php
// $im は画像のインスタンスです
// それが true color 画像か否かを調べます
if(!imageistruecolor($im))
{
// 新しい true color 画像のインスタンスを作成します
$tc = imagecreatetruecolor(imagesx($im), imagesy($im));
// ピクセルをコピーします
imagecopy($tc, $im, 0, 0, 0, 0, imagesx($im), imagesy($im));
imagedestroy($im);
$im = $tc;
$tc = NULL;
// あるいは imagepalettetotruecolor() を使います
}
// 画像のインスタンスに対する操作を続けます
?>