📄 image.php
字号:
<?
/*
*#########################################
* PHPCMS 文件管理器 v4.01
* Copyright (c) 2004-2006 phpcms.cn
* 作者:Longbill ( http://www.longbill.cn )
* 请保留版权信息
*#########################################
*/
if (!$path || !file_exists($path)) $path="images/notfound.gif"; //图片没有找到
if (!$max) err(); //默认最宽100px
if (!$imgarr=@getimagesize($path)) err(); //的到图片原始信息
$width_orig=$imgarr[0];
$height_orig=$imgarr[1];
$mime_orig=$imgarr["mime"];
$mime=str_replace("image/","",$mime_orig);
$mime=($mime=="bmp")?"wbmp":$mime;
if (!function_exists("imagecreatefrom$mime")) err();
//处理大小
if ($width_orig < $height_orig && $height_orig>$max)
{
$height =$max;
$width = ($max / $height_orig) * $width_orig;
}
else if ($width_orig>$height_orig && $width_orig>$max)
{
$width=$max;
$height=($max/$width_orig)*$height_orig;
}
else err(); //如果不需要处理就转到原始图片地址
//生成图片
$image_p = @imagecreatetruecolor($width, $height) or err();
if (@eval('$image = imagecreatefrom'.$mime.'($path);')===false) err();
@imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height, $width_orig, $height_orig) or err();
//输出图片
@header('Content-type: '.$mime_orig);
if (@eval('image'.$mime.'($image_p, null, 100);')===false) err();
function err() //遇到错误就转到原始图片地址
{
global $path;
header("location:$path");
die;
}
?>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -