📄 func_thumb.php
字号:
<?php
if (!defined('ROOT'))
exit('Access Denied');
function thumb($filename,$sourfile) {
$imagetype = strtolower(str_replace('.', '', strrchr($sourfile, '.')));
if (!$data = @getimagesize($sourfile))
return false;
if ($imagetype == 'gif') {
$img = imagecreatefromgif($sourfile);
} else
if ($imagetype == 'jpg' || $imagetype == 'jpeg') {
$img = imagecreatefromjpeg($sourfile);
} else
if ($imagetype == 'png') {
$img = imagecreatefrompng($sourfile);
} else {
return false;
}
if (empty($img)) return false;
$width = 200;
$height = 200;
$width = ($width > $data[0]) ? $data[0] : $width;
$height = ($height > $data[1]) ? $data[1] : $height;
$srcW = $data[0];
$srcH = $data[1];
if ($srcW * $width > $srcH * $height)
$height = round($srcH * $width / $srcW);
else
$width = round($srcW * $height / $srcH);
if (function_exists('imagecreatetruecolor')) {
$new = imagecreatetruecolor($width, $height);
ImageCopyResampled($new, $img, 0, 0, 0, 0, $width, $height, $data[0], $data[1]);
} else {
$new = imagecreate($width, $height);
ImageCopyResized($new, $img, 0, 0, 0, 0, $width, $height, $data[0], $data[1]);
}
ImageJPEG($new, $filename);
ImageDestroy($new);
ImageDestroy($img);
return true;
}
?>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -