⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 resize_image.php

📁 《PHP和MySQL Web开发》(第三版) Source
💻 PHP
字号:
<?php  $image = $_REQUEST['image'];  $max_width = $_REQUEST['max_width'];  $max_height = $_REQUEST['max_height'];  if (!$max_width)    $max_width = 80;  if (!$max_height)    $max_height = 60;  $size = GetImageSize($image);  $width = $size[0];  $height = $size[1];  $x_ratio = $max_width / $width;  $y_ratio = $max_height / $height;  if ( ($width <= $max_width) && ($height <= $max_height) ) {    $tn_width = $width;    $tn_height = $height;  }  else if (($x_ratio * $height) < $max_height) {    $tn_height = ceil($x_ratio * $height);    $tn_width = $max_width;  }  else {    $tn_width = ceil($y_ratio * $width);    $tn_height = $max_height;  }  $src = ImageCreateFromJpeg($image);  $dst = ImageCreate($tn_width,$tn_height);  ImageCopyResized($dst, $src, 0, 0, 0, 0,      $tn_width,$tn_height,$width,$height);  header('Content-type: image/jpeg');  ImageJpeg($dst, null, -1);  ImageDestroy($src);  ImageDestroy($dst);?>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -