使用php怎么在服务器端调整图片的大小-创新互联
                                            这篇文章给大家介绍使用php怎么在服务器端调整图片的大小,内容非常详细,感兴趣的小伙伴们可以参考借鉴,希望对大家能有所帮助。

 $ratio_orig) {
   $width = $height*$ratio_orig;
  } else {
   $height = $width/$ratio_orig;
  }
  // This resamples the image
  $image_p = imagecreatetruecolor($width, $height);
  $image = imagecreatefromjpeg($url);
  imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height, $width_orig, $height_orig);
  // Output the image
  imagejpeg($image_p, null, 100);
 }
 //works with both POST and GET
 $method = $_SERVER['REQUEST_METHOD'];
 if ($method == 'GET') {
  imageResize($_GET['url'], $_GET['w'], $_GET['h']);
  } elseif ($method == 'POST') {
  imageResize($_POST['url'], $_POST['w'], $_POST['h']);
  }
 // makes the process simpler
 function loadImage($url, $width, $height){
  echo 'image.php?url=', urlencode($url) ,
  '&w=',$width,
  '&h=',$height;
 }
?>用法:
//Above code would be in a file called image.php. //Images would be displayed like this:" alt="" />
关于使用php怎么在服务器端调整图片的大小就分享到这里了,希望以上内容可以对大家有一定的帮助,可以学到更多知识。如果觉得文章不错,可以把它分享出去让更多的人看到。
分享文章:使用php怎么在服务器端调整图片的大小-创新互联
网站链接:http://www.scyingshan.cn/article/dosdeg.html

 建站
建站
 咨询
咨询 售后
售后
 建站咨询
建站咨询 
 