Php image processing function obtaining type and extension instance, _ PHP Tutorial

Source: Internet
Author: User
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...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.