Php/docs/function.image-type-to-extension

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

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 画像ライブラリを必要としません。