PHP implements image scaling function class_PHP tutorial

WBOY
Release: 2016-07-13 17:18:10
Original
636 people have browsed it

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...
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!