Home  >  Article  >  Backend Development  >  PHP thumbnail image function code according to maximum width and height

PHP thumbnail image function code according to maximum width and height

WBOY
WBOYOriginal
2016-07-25 08:51:08984browse
A very simple code to shrink images according to the maximum width and height, which is convenient for novices and people who are too lazy to write it themselves
                 
                                                                                                                                                                                                                                                                                                                   OnFunction Thumb ($ ImageFile, $ maxwidth, $ maxheight) {
$ DIM = GetimageSize ($ ImageFile);
$ width = $ dim [0]; = $ dim [1 ; // Original image aspect ratio
                                                                                                                                                                                                        aspect ratio,        aspect ratio
              $thumbHeight = $maxheight;
                                                                                                                                                                        $thumbHeight = $maxheight; = $maxheight*$crown;
            }
  1.                                                                                                                          $thumb thumbHeight, $width, $ height);
  2.                 return $thumb;
  3. }
  4. Copy code
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:PHP aes algorithmNext article:PHP aes algorithm