phpgd搴撳嚱鏁扮敓鎴愰珮娓呯缉鐣ュ浘绋嬪簭_PHP鏁欑▼|甯涔嬪
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了phpgd搴撳嚱鏁扮敓鎴愰珮娓呯缉鐣ュ浘绋嬪簭_PHP鏁欑▼|甯涔嬪,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含2349字,纯文字阅读大概需要4分钟。
内容图文
![phpgd搴撳嚱鏁扮敓鎴愰珮娓呯缉鐣ュ浘绋嬪簭_PHP鏁欑▼|甯涔嬪](/upload/InfoBanner/zyjiaocheng/181/baec9276abda4aa09b95dea6305a645b.jpg)
include('resizeimage.php');
if(!empty($_post)){
echo($filename.".jpg?cache=".rand(0,999999));
}
?>
resizeimage.php 鏂囦欢
$filename="image.thumb";
// 鐢熸垚鍥剧墖鐨勫搴?
$resizewidth=400;
// 鐢熸垚鍥剧墖鐨勯珮搴?
$resizeheight=400;function resizeimage($im,$maxwidth,$maxheight,$name){
$width = imagesx($im);
$height = imagesy($im);
if(($maxwidth && $width > $maxwidth) || ($maxheight && $height > $maxheight)){
if($maxwidth && $width > $maxwidth){
$widthratio = $maxwidth/$width;
$resizewidth=true;
}
if($maxheight && $height > $maxheight){
$heightratio = $maxheight/$height;
$resizeheight=true;
}
if($resizewidth && $resizeheight){
if($widthratio < $heightratio){
$ratio = $widthratio;
}else{
$ratio = $heightratio;
}
}elseif($resizewidth){
$ratio = $widthratio;
}elseif($resizeheight){
$ratio = $heightratio;
}
$newwidth = $width * $ratio;
$newheight = $height * $ratio;
if(function_exists("imagecopyresampled")){
$newim = imagecreatetruecolor($newwidth, $newheight);
imagecopyresampled($newim, $im, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
}else{
$newim = imagecreate($newwidth, $newheight);
imagecopyresized($newim, $im, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
}
imagejpeg ($newim,$name . ".jpg");
imagedestroy ($newim);
}else{
imagejpeg ($im,$name . ".jpg");
}
}if($_files['image']['size']){
if($_files['image']['type'] == "image/pjpeg"){
$im = imagecreatefromjpeg($_files['image']['tmp_name']);
}elseif($_files['image']['type'] == "image/x-png"){
$im = imagecreatefrompng($_files['image']['tmp_name']);
}elseif($_files['image']['type'] == "image/gif"){
$im = imagecreatefromgif($_files['image']['tmp_name']);
}
if($im){
if(file_exists("$filename.jpg")){
unlink("$filename.jpg");
}
resizeimage($im,$resizewidth,$resizeheight,$filename);
imagedestroy ($im);
}
}
?>
http://www.bkjia.com/PHPjc/632985.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/632985.htmlTechArticlegd搴撴槸php鏁欑▼涓竴涓鐞嗗浘鍍忕殑涓撶敤搴擄紝浠栧彲浠ユ柟渚垮揩鎹风殑澶勭悊澶у鏁版嵁澶勭悊锛屽畠鎻愪緵浜嗗ぇ閲忕殑鍥剧墖澶勭悊鍑芥暟锛屼笅闈㈡垜浠氨鍒╃敤gd搴撶殑鍑芥暟鏉?..
内容总结
以上是互联网集市为您收集整理的phpgd搴撳嚱鏁扮敓鎴愰珮娓呯缉鐣ュ浘绋嬪簭_PHP鏁欑▼|甯涔嬪全部内容,希望文章能够帮你解决phpgd搴撳嚱鏁扮敓鎴愰珮娓呯缉鐣ュ浘绋嬪簭_PHP鏁欑▼|甯涔嬪所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。