image_type_to_extension
(PHP 5 >= 5.2.0, PHP 7)
image_type_to_extension — 画像形式からファイルの拡張子を取得する
説明
image_type_to_extension
( int
$imagetype
[, bool $include_dot = TRUE
] ) : string指定した定数 IMAGETYPE_XXX に対応する拡張子を返します。
パラメータ
-
imagetype -
IMAGETYPE_XXX 定数のいずれかひとつ。
-
include_dot -
拡張子の前にドットをつけるかどうか。デフォルトは
TRUE。
返り値
指定した型に対応する拡張子を文字列で返します。
例
例1 image_type_to_extension() の例
<?php
// 画像のインスタンスを作成します
$im = imagecreatetruecolor(100, 100);
// 画像を保存します
imagepng($im, './test' . image_type_to_extension(IMAGETYPE_PNG));
imagedestroy($im);
?>
注意
注意:
この関数は、GD 画像ライブラリを必要としません。