In the picture save, we do not have to modify the image in PS or other tools, we can also use the code to implement. Here are two examples of the same effect:
$sourcefile = "images/1.jpg";//Old map path
$dstfile = "images/1_small.jpg";//New map path
$arr =getimagesize ($sourcefile);//Get the picture scale so that we don't have to look for the width of the image property again in the directory.
$SRC _width= "144";
$SRC _height= "200"; You can also customize the zoom scale but too much of the picture will distort
$scle =0.5;//Scale Factor
$DST _width=ceil ($arr [0]* $scle);
$DST _width=ceil ($arr [1]* $sclie);//new graph width High
$DST _img=imagecreatetruecolor ($dst _width, $dst _height);//Load new diagram
$SRC _img=imagecreatefromjpeg ($sourcefile);//load old diagram
Imagecopyresampled ($dst _img, $src _img,0,0,0,0$dst_width, $dst _height, $src _width, $src _height);//Output image
Imagejpeg ($dst _img, $dstfile);//new diagram, Path
Imagedestroy ($dst _img);
Imagedestroy ($src _img);//Destroy Picture
?>
Class zoom{
private $srcImg;//Original address
private $scle;//Zoom factor
Public function __construct ($a $b) {
$this->srcimg= $a;
$this->scle= $b;
List ($src _w $src _h) =getimagesize ($this->srcimg);
$DST _w=ceil ($src _w* $this->scle);
$DST _h=ceil ($src _h* $this->scle);
$arr =explode ("." $this->srcimg);
$ext =end ($arr);
if ($ext = = "jpg") {
$src _img=imagecreatefromjpeg ($this->srcimg);
}else if ($ext = = "gif") {
$src _img=imagecreatefromgif ($this->srcimg);
}else if ($ext = = "png") {
$src _img=imagecreatefrompng ($this->srcimg);
}else{
echo "Please select JPG, PNG, GIF image format";
Exit
}
$DSTIMG = $arr [0]. $this->scle. " _small ".". ". $ext;
$DST _img=imagecreatetruecolor ($dst _w$dst_h);
Imagecopyresampled ($dst _img$src_img0000$dst_w$dst_h$src_w$src_h);
if ($ext = = "jpg") {
Imagejpeg ($dst _img$dstimg);
}else if ($ext = = "gif") {
Imagegif ($dst _img$dstimg);
}else if ($ext = = "png") {
Imagepng ($dst _img$dstimg);
}
Imagedestroy ($src _img);
Imagedestroy ($dst _img);
}
}
$image = "Imgs/a.jpg";
$b = 1;
$i =new Zoom ($image $b);
?>