Home  >  Article  >  Backend Development  >  PHP implements image scaling function class_PHP tutorial

PHP implements image scaling function class_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 17:18:10637browse

Copy code The code is as follows:

/**
* The Images class is an image processing class
* @package application.controllers
* @since 1.0
*/
class Images
{


/**
* Zoom image
* @param $source original image
* @param $newfile new image
* @param $pre zoom ratio
*/
public function thumn($source,$pre,$newfile)
{
//Get images Size
list($s_w,$s_h)=getimagesize($source);
//Generate new image size
$new_w=$s_w*$pre;
$new_h=$s_h* $pre;

//Create a new image
$new_f=imagecreatetruecolor($new_w, $new_h);
//Create an image with a resource image
$sour_f=imagecreatefromjpeg($source);
/ /Copy the resource image to a new image
imagecopyresampled($new_f, $sour_f, 0, 0, 0, 0, $new_w, $new_h, $s_w, $s_h);
//Output the image to the browser
imagejpeg($new_f,$newfile);

imagedestroy($new_f);
imagedestroy($sour_f);
}
}
?>

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/621680.htmlTechArticleCopy the code as follows: ?php /*** The Images class is an image processing class * @package application.controllers * @since 1.0*/ class Images { /** * Zoom image * @param $source original picture...
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