PHP image_type_to_extension - Get Image Extension
image_type_to_extension — Returns the file extension for the given image type.
Syntax
string image_type_to_extension ( int $imagetype [, bool $include_dot = TRUE ] )
Returns the extension based on the given constant IMAGETYPE_XXX.
Example
<?php // 创建图像实例 $im = imagecreatetruecolor(100, 100); // 保存图像 png 格式 imagepng($im, './test' . image_type_to_extension(IMAGETYPE_PNG)); imagedestroy($im); ?>
Running the above file will generate a test.png image in the current directory.
Other Extensions
PHP Image Processing