IT貓撲網(wǎng):您身邊最放心的安全下載站! 最新更新|軟件分類(lèi)|軟件專(zhuān)題|手機(jī)版|論壇轉(zhuǎn)貼|軟件發(fā)布

您當(dāng)前所在位置: 首頁(yè)網(wǎng)絡(luò)編程PHP編程 → php做縮略圖源碼

php做縮略圖源碼

時(shí)間:2015-06-28 00:00:00 來(lái)源:IT貓撲網(wǎng) 作者:網(wǎng)管聯(lián)盟 我要評(píng)論(1)

thump.php:

include_once('extra.php');
$path='assets/';
$new_height=800;
$dir='E:\webroot\blog\test\assets\\';
define("END", "\n");
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)<300)
//if (substr($f,0,3)!='000' || substr($f,0,3)!='2003')
// continue;
? $data[]=$f;
??? }

/* $result=implode("\t\n",$data);
echo $result;*/
??? closedir($handle);


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

/*function ()
{

}
*/

關(guān)鍵詞標(biāo)簽:php

相關(guān)閱讀

文章評(píng)論
發(fā)表評(píng)論

熱門(mén)文章 plsql developer怎么連接數(shù)據(jù)庫(kù)-plsql developer連接數(shù)據(jù)庫(kù)方法 plsql developer怎么連接數(shù)據(jù)庫(kù)-plsql developer連接數(shù)據(jù)庫(kù)方法 2021年最好用的10款php開(kāi)發(fā)工具推薦 2021年最好用的10款php開(kāi)發(fā)工具推薦 php利用淘寶IP庫(kù)獲取用戶(hù)ip地理位置 php利用淘寶IP庫(kù)獲取用戶(hù)ip地理位置 在 PHP 中使用命令行工具 在 PHP 中使用命令行工具

相關(guān)下載

    人氣排行 詳解ucenter原理及第三方應(yīng)用程序整合思路、方法 plsql developer怎么連接數(shù)據(jù)庫(kù)-plsql developer連接數(shù)據(jù)庫(kù)方法 PHP中防止SQL注入攻擊 PHP會(huì)話(huà)Session的具體使用方法解析 PHP運(yùn)行出現(xiàn)Notice : Use of undefined constant 的解決辦法 PHP如何清空mySQL數(shù)據(jù)庫(kù) CakePHP程序員必須知道的21條技巧 PHP采集圖片實(shí)例(PHP采集)