English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Basic PHP Tutorial

Advanced PHP Tutorial

PHP & MySQL

PHP Reference Manual

Usage and examples of PHP image_type_to_extension() function

PHP Image Processing

image_type_to_extension — Returns the corresponding file extension based on the specified image type.

Syntax

string image_type_to_extension ( int $imagetype [, bool $include_dot = TRUE ] )

Returns the file extension based on the given constant IMAGETYPE_XXX.

Example

<?php
// Create image example
$im = imagecreatetruecolor(100, 100);
// Save image in png format
imagepng($im, './test' . image_type_to_extension(IMAGETYPE_PNG));
imagedestroy($im);
?>

Executing the above file will generate a test.png image in the current directory.

PHP Image Processing