Php/docs/function.imageistruecolor

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

imageistruecolor

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

imageistruecolor画像が truecolor かどうか調べる


説明

imageistruecolor ( resource $image ) : bool

imageistruecolor() は、 image が truecolor 画像かどうか調べます。


パラメータ

image
imagecreatetruecolor() のような画像作成関数が返す画像リソース。


返り値

image が truecolor の場合に true、 それ以外の場合に false を返します。


例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() を使います}// 画像のインスタンスに対する操作を続けます?>

参考