Super simple php big image generation thumbnail implementation code _ PHP Tutorial

Source: Internet
Author: User
Super simple php big image generation thumbnail implementation code. How can I generate a thumbnail in a large image in a simple php Tutorial? Php *** generate a thumbnail ** @ paramstring $ imagepath Image path * @ paramstring $ thumb generate a thumbnail name * @ paraminte super simple php Tutorial to generate a thumbnail implementation code

/**
* Generating thumbnails
*
* @ Param string $ imagepath Image path
* @ Param string $ thumb generate a thumbnail name
* @ Param integer $ width: generate the maximum width of the thumbnail.
* @ Param integer $ height: generate the maximum height of the thumbnail.
*

*/
Function resizeimage ($ imagepath, $ thumb, $ width = 200, $ height = 200)
{
List ($ imagewidth, $ imageheight) = getimagesize ($ imagepath );
$ Imagepath = imagecreatefromjpeg ($ imagepath );
If ($ width & ($ imagewidth <$ imageheight ))
{
$ Width = ($ height/$ imageheight) * $ imagewidth;
}
Else
{
$ Height = ($ width/$ imagewidth) * $ imageheight;
}
$ Image = imagecreatetruecolor ($ width, $ height );
Imagecopyresampled ($ image, $ imagepath, 0, 0, 0, 0, $ width, $ height, $ imagewidth, $ imageheight );
Imagepng ($ image, $ thumb );
Imagedestroy ($ image );
}
Resizeimage('test.jpg ', 'test_thumb.jpg ');
?>

How can I generate a thumbnail for a larger image? Php/*** generate a thumbnail ** @ param string $ imagepath Image path * @ param string $ thumb generate a thumbnail name * @ param inte...

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.