php implements the image zooming function class
- 2020-11-30 08:12:23
- OfStack
<?php
/**
* Images A class is 1 Image processing class
* @package application.controllers
* @since 1.0
*/
class Images
{
/**
* Zoom pictures
* @param $source The original image
* @param $newfile New pictures
* @param $pre scaling
*/
public function thumn($source,$pre,$newfile)
{
// Get picture size
list($s_w,$s_h)=getimagesize($source);
// Generate a 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 the 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);
}
}
?>