update page now
Laravel Live Japan

imageistruecolor

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

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

説明

imageistruecolor(GdImage $image): bool

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

パラメータ

image

imagecreatetruecolor()のような画像作成関数が返す GdImage オブジェクト。

戻り値

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

変更履歴

バージョン 説明
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));

$im = $tc;
$tc = NULL;

/ あるいは imagepalettetotruecolor() を使います
}

/ 画像のインスタンスに対する操作を続けます
?>

参考

add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top

Follow Lee on X/Twitter - Father, Husband, Serial builder creating AI, crypto, games & web tools. We are friends :) AI Will Come To Life!

Check out: eBank.nz (Art Generator) | Netwrck.com (AI Tools) | Text-Generator.io (AI API) | BitBank.nz (Crypto AI) | ReadingTime (Kids Reading) | RewordGame | BigMultiplayerChess | WebFiddle | How.nz | Helix AI Assistant