PHP image_type_to_extension() 函数获取图片后缀用法及示例 - PHP教程

由网友 大卫 发布 阅读 2

PHP image_type_to_extension() 函数获取图片后缀用法及示例 - PHP教程

PHP 图像处理

image_type_to_extension — 根据指定的图像类型返回对应的后缀名。

语法

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

根据给定的常量 IMAGETYPE_XXX 返回后缀名。

示例

<?php
// 创建图像示例
$im = imagecreatetruecolor(100, 100);
// 保存图像 png 格式
imagepng($im, './test' . image_type_to_extension(IMAGETYPE_PNG));
imagedestroy($im);
?>

执行以上文件会在当期目录下生成一个 test.png 的图片。

PHP 图像处理

PHP getimagesizefromstring() 函数获取图片信息用法及示例 PHP imagecolorallocatealpha() 为一幅图像分配颜色和透明度用法及示例