首页 > php教程 > php手册 > 正文

php做缩略图源码

php中文网
发布: 2016-06-06 19:52:21
原创
1640人浏览过

thump.php: ?php include_once('extra.php'); $path='assets/'; $new_height=800; $dir='E:webrootlog estssets\'; define("END", " "); define("TUD",$dir); function thumb($source,$new_height) { list($im_width, $im_height, $type) = getimage

thump.php:

include_once('extra.php');
$path='assets/';
$new_height=800;
$dir='E:webrootlog estssets\';
define("END", " ");
define("TUD",$dir);
function thumb($source,$new_height)
{
list($im_width, $im_height, $type) = getimagesize($source);
/*$file=explode('/',$source);
$file=array_pop($file);*/

$file=basename($source);
echo $file;


if (!is_writable($source)) {
trigger_error('dir can't be write');
//touch('thumb');
}
$new_width=$im_width * $new_height / $im_height;
$new_width=sprintf('%d',round($new_width));
echo $new_width;
$im = ImageCreatefromJpeg($source);
if (!$im)
throw new Exception('Unable to read image file');
$thumb = ImageCreateTrueColor($new_width, $new_height);
ImageCopyResampled($thumb, $im, 0, 0, 0, 0, $new_width, $new_height, $im_width, $im_height);
if (!Imagejpeg($thumb,'thumb/'.$file))
throw new Exception('缩略图失败');
imagedestroy($im);
imagedestroy($thumb);
unlink (TUD.$file);
//echo TUD.$file.' done';
}
$data=enterDir(TUD);
//print_r ($data);
foreach($data as $v)
//echo $v;
thumb(TUD.$v,$new_height);
/*$handle = opendir('thumb/');
while(false !== ($file = readdir($handle))) {
$source="thumb/".$file;
echo "$file
";
}*/
?>
extra.php:

function enterDir($path)
{

if ($handle = opendir($path)) {
$data=array();
    while (false !== ($f = readdir($handle))) {
$ep=array('.','..');
//$ext=substr($f,-3,3);
if (in_array($f,$ep))
continue;
//if (filesize($path.$f)//if (substr($f,0,3)!='000' || substr($f,0,3)!='2003')
// continue;
        $data[]=$f;
    }

jQuery鼠标经过商品列表缩略图变大文字特效动画代码
jQuery鼠标经过商品列表缩略图变大文字特效动画代码

jQuery鼠标经过商品列表缩略图变大文字特效动画代码下载。效果非常炫酷。

jQuery鼠标经过商品列表缩略图变大文字特效动画代码 169
查看详情 jQuery鼠标经过商品列表缩略图变大文字特效动画代码

/* $result=implode(" ",$data);
echo $result;*/
    closedir($handle);


return $data;
}
}
$data=enterDir('E:webrootlog estssets\');
print_r($data);
foreach ($data as $k=>$v) {
$title=substr($v,0,-4);
$data[$k]='';
//echo $v;
}
$data=implode(" ",$data);
echo $data;

/*function ()
{

}
*/

相关标签:
php
PHP速学教程(入门到精通)
PHP速学教程(入门到精通)

PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!

下载
来源:php中文网
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
最新问题
开源免费商场系统广告
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号