php动态生成缩略图并输出显示的方法
发布时间:2020-12-13 02:34:46 所属栏目:PHP教程 来源:网络整理
导读:《:php动态生成缩略图并输出显示的方法》要点: 本文介绍了:php动态生成缩略图并输出显示的方法,希望对您有用。如果有疑问,可以联系我们。 PHP编程 本篇章节讲解php动态生成缩略图并输出显示的办法.供大家参考研究.具体如下: PHP编程 调用办法
《:php动态生成缩略图并输出显示的方法》要点: PHP编程本篇章节讲解php动态生成缩略图并输出显示的办法.分享给大家供大家参考.具体如下: PHP编程调用办法: PHP编程
<img src="thumbs.php?filename=photo.jpg&width=100&height=100">
PHP编程此代码可以为大图片动态生成缩略图显示,图片在内存中生成,不在硬盘生成真实文件 PHP编程thumbs.php文件如下: PHP编程
<?php
$filename= $_GET['filename'];
$width = $_GET['width'];
$height = $_GET['height'];
$path="http://localhost/images/"; //finish in "/"
// Content type
header('Content-type: image/jpeg');
// Get new dimensions
list($width_orig,$height_orig) = getimagesize($path.$filename);
if ($width && ($width_orig < $height_orig)) {
$width = ($height / $height_orig) * $width_orig;
} else {
$height = ($width / $width_orig) * $height_orig;
}
// Resample
$image_p = imagecreatetruecolor($width,$height);
$image = imagecreatefromjpeg($path.$filename);
imagecopyresampled($image_p,$image,$width,$height,$width_orig,$height_orig);
// Output
imagejpeg($image_p,null,100);
// Imagedestroy
imagedestroy ($image_p);
?>
PHP编程希望本文所述对大家的php程序设计有所赞助. 《:php动态生成缩略图并输出显示的方法》是否对您有启发,欢迎查看更多与《:php动态生成缩略图并输出显示的方法》相关教程,学精学透。编程之家 52php.cn为您提供精彩教程。 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |