Home  >  Article  >  Backend Development  >  PHP thumbnail implementation function code_PHP tutorial

PHP thumbnail implementation function code_PHP tutorial

WBOY
WBOYOriginal
2016-07-21 15:28:06794browse

array getimagesize ( string $filename [, array &$imageinfo ] ) Get the image size
resource imagecreatetruecolor ( int $x_size , int $y_size ) Create a new true color image
resource imagecreatefromjpeg ( string $filename ) From a JPEG file or URL Create a new image
bool imagecopyresized ( resource $dst_image , resource $src_image , int $dst_x , int $dst_y , int $src_x , int $src_y , int $dst_w , int $dst_h , int $src_w , int $src_h ) Copy part of the image and resize
bool imagejpeg ( resource $image [, string $filename [, int $quality ]] ) Output the image to a browser or file in JPEG format

Copy code The code is as follows:

/*
Created by http://www.cnphp.info
*/
// File and zoom size
//$imgfile = 'smp.jpg';
//$ percent = 0.2;
header('Content-type: image/jpeg');
list($width, $height) = getimagesize($imgfile);
$newwidth = $width * $percent;
$newheight = $height * $percent;
$thumb = ImageCreateTrueColor($newwidth,$newheight);
$source = imagecreatefromjpeg($imgfile);
imagecopyresized($thumb, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
imagejpeg($thumb);
?>

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/323653.htmlTechArticlearray getimagesize ( string $filename [, array lt;?php /* Created by A href="http:/ /www.cnphp.info"http://www.cnphp.info/A */ // File and zoom size //$imgfile = 'smp.jpg'; //$per...
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