Php image processing function obtaining type and extension instance ,. Php image processing function obtaining type and extension example. This article describes how to obtain the type and extension of php image processing function. Share it with you for your reference. Implementation of modern php image processing function acquisition types and extension instances,
This example describes how to obtain the type and extension of php image processing functions. Share it with you for your reference.
The specific implementation code is as follows:
The code is as follows:
Image_type = image_type_to_mime_type (imagetype_png); // Obtain the mime type of png
Echo $ image_type; // output result
//
$ 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 image-type file suffix... warning. no documentation for this function
$ File_ext = image_type_to_extension ("1.jpg ");
Echo $ file_ext;
//
$ Filename = "1.jpg"; // define an image file
$ Size = getimagesize ($ filename); // Obtain the image size
$ Fp = fopen ($ filename, "rb"); // open the file
If ($ size & $ fp) // if it is enabled successfully
{
Header ("content-type: {$ size ['Mime ']}"); // output file header information
Fpassthru ($ fp); // output file content
Exit; // stop the operation
}
Else
{
Echo "an error occurred while opening the file, or the specified file is not an image file"; // output an error message
}
I hope this article will help you with PHP programming.
Examples in this article describe how to obtain the type and extension of php image processing functions. Share it with you for your reference. Concrete implementation of modern...