Php method for generating image thumbnails, _php tutorial

Source: Internet
Author: User

How PHP generates thumbnails of pictures,


The example in this article describes how PHP generates image thumbnails. Share to everyone for your reference. Specific as follows:

We need to use the GD2 library here.

function Make_thumb ($SRC, $dest, $desired _width) {/   * Read the source image */  $source _image = Imagecreatefromjpeg ($SRC);  $width = Imagesx ($source _image);  $height = Imagesy ($source _image);  /* Find the "desired height" of this thumbnail, relative to the desired width *  /$desired _height = Floor ($height * ($des ired_width/$width));  /* Create a new, "virtual" image *  /$virtual _image = Imagecreatetruecolor ($desired _width, $desired _height);  /* Copy source image at a resized size *  /imagecopyresized ($virtual _image, $source _image,0,0,0,0, $desired _width,$ Desired_height, $width, $height);  /* Create the physical thumbnail image to its destination *  /imagejpeg ($virtual _image, $dest, 83);}

I hope this article is helpful to everyone's PHP programming.

http://www.bkjia.com/PHPjc/980224.html www.bkjia.com true http://www.bkjia.com/PHPjc/980224.html techarticle PHP generates thumbnail image of the method, the example of this article describes how to generate a thumbnail image of PHP. Share to everyone for your reference. Here are the following: GD2 library functio is needed here ...

  • 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.