频道栏目
首页 > 资讯 > 图像编程 > 正文

简单的图片生成缩略图

16-01-07        来源:[db:作者]  
收藏   我要投稿

新弄的图片生成缩略图

PHP代码
<?php   
// The file   
$filename = 'mm.jpg';   
$dstFile="icons/";   
$filePath="icons/test.jpg";   
  
// Set a maximum height and width   
$width = 100;   
$height = 100;   
  
// Content type   
header('Content-type: image/jpeg');   
  
// Get new dimensions   
list($width_orig, $height_orig) = getimagesize($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($filename);   
imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height, $width_orig, $height_orig);   
  
// Output   
imagejpeg($image_p,$filePath);   
?>   
$filename图片的名称,包括路径

$dstFile目标路径
相关TAG标签
上一篇:Bigcommerce:PHP版本升级错误解决办法
下一篇:基于PHP实现阿里云开放存储服务
相关文章
图文推荐

关于我们 | 联系我们 | 广告服务 | 投资合作 | 版权申明 | 在线帮助 | 网站地图 | 作品发布 | Vip技术培训 | 举报中心

版权所有: 红黑联盟--致力于做实用的IT技术学习网站