新建文件index.php,需要在统计目录下有个图片为q.jpg(可根据源码进行更改图片的名称)

源代码如下:

<?php
$filename="q.jpg";
$per=0.3;
list($width, $height)=getimagesize($filename);
$n_w=$width*$per;
$n_h=$height*$per;
$new=imagecreatetruecolor($n_w, $n_h);
$img=imagecreatefromjpeg($filename);
//拷贝部分图像并调整
imagecopyresized($new, $img,0, 0,0, 0,$n_w, $n_h, $width, $height);
//图像输出新图片、另存为
imagejpeg($new, "q1.jpg");
imagedestroy($new);
imagedestroy($img);
?>

使用浏览器运行过后,在index.php同级的目录下会有个q1.jpg,这个图片就是等比例缩放后的图片,路径可以自己在源代码里面更改,放在自己的项目当中去或写个方法也行

力劦工作室提供

 

相关文章:

  • 2021-12-31
  • 2022-02-23
  • 2021-09-19
  • 2021-07-05
猜你喜欢
  • 2022-02-19
  • 2022-12-23
  • 2021-07-26
  • 2022-12-23
  • 2021-12-31
相关资源
相似解决方案