array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'pt_BR', ), 'this' => array ( 0 => 'function.image-type-to-extension.php', 1 => 'image_type_to_extension', ), 'up' => array ( 0 => 'ref.image.php', 1 => 'Funções de GD e Image', ), 'prev' => array ( 0 => 'function.getimagesizefromstring.php', 1 => 'getimagesizefromstring', ), 'next' => array ( 0 => 'function.image-type-to-mime-type.php', 1 => 'image_type_to_mime_type', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'pt_BR', 'path' => 'reference/image/functions/image-type-to-extension.xml', ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); ?>
(PHP 5 >= 5.2.0, PHP 7, PHP 8)
image_type_to_extension — Obtém a extensão de arquivo para o tipo da imagem
Retorna a extensão de arquivo para a constante IMAGETYPE_XXX
informada.
image_type
Uma das constantes IMAGETYPE_XXX
.
include_dot
Informa se deve-se prefixar um ponto à extensão ou não. O padrão é true
(prefixar).
Uma string com a extensão correspondente ao tipo de imagem informado, ou false
em caso de falha.
Exemplo #1 Exemplo de image_type_to_extension()
<?php
// Cria instância da imagem
$im = imagecreatetruecolor(100, 100);
// Salva a imagem
imagepng($im, './test' . image_type_to_extension(IMAGETYPE_PNG));
imagedestroy($im);
?>
Nota:
Esta função não requer a biblioteca de imagens GD.