PHP Image processing function acquisition type and extension instance _php skill

Source: Internet
Author: User
Tags php tutorial

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.

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.