« getimagesizefromstring
image_type_to_mime_type »

image_type_to_extension

(PHP 5 >= 5.2.0, PHP 7, PHP 8)

image_type_to_extension — 画像形式からファイルの拡張子を取得する

説明

function image_type_to_extension(int $image_type, bool $include_dot = true): string|false

指定した定数 IMAGETYPE_* に対応する拡張子を返します。

パラメータ

image_type

IMAGETYPE_* 定数のいずれかひとつ。

include_dot

拡張子の前にドットをつけるかどうか。デフォルトは true。

戻り値

指定した型に対応する拡張子を文字列で返します。 失敗した場合に false を返します

例

例1 image_type_to_extension() の例

<?php
// 画像のインスタンスを作成します
$im = imagecreatetruecolor(100, 100);

// 画像を保存します
imagepng($im, './test' . image_type_to_extension(IMAGETYPE_PNG));
?>

注意

注意:

この関数は、GD 画像ライブラリは必要ありません。

関連キーワード:
type   image   画像   拡張子   extension   定数   getimagesizefromstring   mime   Image   ドット   インスタンス   imagecreatetruecolor   imagepng   ライブラリ
関連する関数・ページ:
function.ps-open-image-file   function.image2wbmp   function.ps-open-memory-image   function.ps-close-image   function.image-type-to-mime-type   function.ps-open-image