The example in this article describes the method of obtaining the type and extension of the PHP image processing function. Share to everyone for your reference.
The specific implementation code is as follows:
Copy Code code as follows:
Image_type=image_type_to_mime_type (imagetype_png); Get 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-gets the file suffix of the image type ... warning. There is no document for this function temporarily
$file _ext=image_type_to_extension ("1.jpg");
echo $file _ext;
//
$filename = "1.jpg"; Defining image files
$size =getimagesize ($filename); Get the size of the image
$FP =fopen ($filename, "RB"); Open File
if ($size && $fp)//if successfully opened
{
Header ("Content-type: {$size [' MIME ']}"); Output File header information
Fpassthru ($FP); Output file contents
Exit Abort operation
}
Else
{
echo "File open failed, or not specified image file"; Output error message
}
I hope this article will help you with your PHP program design.