Php generates the thumbnail function code .? Php *** generate image thumbnails ** @ paramstring $ src source image address * @ paramstring $ savePath thumbnail save address * @ paraminteger $ width thumbnail width * @ paraminteger $ height shrink
- /**
- * Generating image thumbnails
- *
- * @ Param string $ src source image address
- * @ Param string $ savePath the thumbnail storage address
- * @ Param integer $ width thumbnail width
- * @ Param integer $ height the Thumbnail height
- * @ Return string thumbnail address
- */
- Function buildThumb ($ src, $ savePath, $ width = 220, $ height = 180)
- {
- $ Arr = getimagesize ($ src );
- If (! Is_array ($ arr )){
- Return false;
- }
- // 1, 2, and 3 are gif, jpg, and png, respectively.
- If ($ arr [2]> 4 ){
- Return false;
- }
- $ Func = imagecreatefrom;
- Switch ($ arr [2]) {
- Case 1: $ func. = gif; break;
- Case 2: $ func. = jpeg; break;
- Case 3: $ func. = png; break;
- Default: $ func. = jpeg;
- }
- $ SrcIm = $ func ($ src );
- $ Im = imagecreatetruecolor ($ width, $ height );
- Imagecopyresized ($ im, $ srcIm, 0, 0, 0, 0, $ width, $ height, $ arr [0], $ arr [1]);
- Imagejpeg ($ im, $ savePath );
- Imagedestroy ($ srcIm );
- Imagedestroy ($ im );
- Return true;
- }
- ?>
Http://www.bkjia.com/PHPjc/486193.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/486193.htmlTechArticle? Php/*** generate image thumbnails ** @ param string $ src source image address * @ param string $ savePath thumbnail storage address * @ param integer $ width thumbnail width * @ param integer $ height shrink...