PHP.nl

image_type_to_extension

image_type_to_extension

Get file extension for image type

 **image_type_to_extension** int $image_type bool $include_dot

Returns the extension for the given constant. IMAGETYPE_*

image_type One of the constant. IMAGETYPE_*

include_dotWhether to prepend a dot to the extension or not. Default to true.

A string with the extension corresponding to the given image type, return.falseforfailure.

Voorbeeld: example

<?php
// Create image instance
$im = imagecreatetruecolor(100, 100);

// Save image
imagepng($im, './test' . image_type_to_extension(IMAGETYPE_PNG));
?>