[PHP] 如何用PHP改变图片的尺寸 →→→→→进入此内容的聊天室

来自 , 2020-09-20, 写在 PHP, 查看 204 次.
URL http://www.code666.cn/view/ce60ff16
  1. <?php
  2. $imgsrc = "http://yuncode.net/images/3.jpg";
  3. $width = 780;
  4. $height = 420;
  5. resizejpg($imgsrc,$imgdst,$width,$height);
  6. function resizejpg($imgsrc,$imgdst,$imgwidth,$imgheight)
  7. {
  8.         //$imgsrc jpg格式图像路径 $imgdst jpg格式图像保存文件名 $imgwidth要改变的宽度 $imgheight要改变的高度
  9.         //取得图片的宽度,高度值
  10.         $arr = getimagesize($imgsrc);                    
  11.         header("Content-type: image/jpg");
  12.        
  13.         $imgWidth = $imgwidth;
  14.         $imgHeight = $imgheight;
  15.         // Create image and define colors
  16.         $imgsrc = imagecreatefromjpeg($imgsrc);
  17.         $image = imagecreatetruecolor($imgWidth, $imgHeight);  //创建一个彩色的底图
  18.         imagecopyresampled($image, $imgsrc, 0, 0, 0, 0,$imgWidth,$imgHeight,$arr[0], $arr[1]);
  19.         imagepng($image);
  20.         imagedestroy($image);
  21. }
  22. ?>
  23.  

回复 "如何用PHP改变图片的尺寸"

这儿你可以回复上面这条便签

captcha