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

📄 func_thumb.php

📁 采用模块化设计,自由组合文章,软件,论坛等模块,安装方便快捷 模板支持Dreamweaver可视化编辑,创建风格更为容易,专业
💻 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 + -