PHP image processing function obtains type and extension examples,
The example in this article describes how to obtain the type and extension of the PHP image processing function. Share it with everyone for your reference.
The specific implementation code is as follows:
Copy code The code is as follows:
image_type=image_type_to_mime_type(imagetype_png); //Get the mime type of png
echo $image_type; //Output results
//
$file = '1.jpg';
$image = imagecreatefromjpeg($file);
header('content-type: ' . image_type_to_mime_type(imagetype_wbmp));
$fp=fopen($file,r);
fpassthru($fp);
image2wbmp($image,"1.bmp"); // output the stream directly
//image_type_to_extension. (php tutorial 5). image_type_to_extension — Get the file suffix of the image type... warning. There is no documentation for this function
$file_ext=image_type_to_extension("1.jpg");
echo $file_ext;
//
$filename="1.jpg"; //Define image file
$size=getimagesize($filename); //Get the size of the image
$fp=fopen($filename,"rb"); //Open the file
if($size && $fp) //If successfully opened
{
header("content-type: {$size['mime']}"); //Output file header information
fpassthru($fp); //Output file content
exit; //Abort the operation
}
else
{
echo "Failed to open the file, or the specified image file is not an image file"; //Output error message
}
I hope this article will be helpful to everyone’s PHP programming design.
http://www.bkjia.com/PHPjc/914055.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/914055.htmlTechArticlephp image processing function acquisition type and extension example, this article describes the php image processing function acquisition type and extension example method. Share it with everyone for your reference. Specific implementation code...
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn