一区二区久久-一区二区三区www-一区二区三区久久-一区二区三区久久精品-麻豆国产一区二区在线观看-麻豆国产视频

PHP批量生成縮略圖的代碼

缺點:長寬不一的圖片會被拉伸變形,不能智能裁切,需要智能裁切的,請自行研究。
<?php 
$config = array(); 
$config['path'] = "./"; 
$config['t_width'] = 120; 
$config['t_height'] = 98; 
$config['ignore'] = array("",".",".."); 
$config['prefix'] = "thumb_"; 
$done = 0; 
define("IMAGE_JPG", 2); 
define("ENDL", "/n"); 
if($handle = opendir($config['path'])) { 
while(false !== ($file = readdir($handle))) { 
if(!array_search($file,$config['ignore'])) { 

list($im_width, $im_height, $type) = getimagesize($file); 
if($type != IMAGE_JPG) { 
continue; 


$op .= "found -> <a href='{$file}'>$file</a>" . ENDL; 
$im = @imagecreatefromjpeg($file); 
if(!$im) { 
$op .= "fail -> couldn't create sour image pointer." . ENDL; 
continue; 


if(file_exists($config['prefix'] . $file) || substr($file, 0, strlen($config['prefix'])) == $config['prefix']) { 
$op .= "note -> this file has already got a thumbnail." . ENDL; 
continue; 

$to = imagecreatetruecolor($config['t_width'],$config['t_height']); 
if(!$to) { 
$op .= "fail -> couldn't create dest image pointer." . ENDL; 
continue; 


if(!imagecopyresampled($to, $im, 0, 0, 0, 0, $config['t_width'], $config['t_height'], $im_width, $im_height)) { 
$op .= "fail -> couldn't create thumbnail. php fail." . ENDL; 
continue; 


//保存文件 
imagejpeg($to, $config['prefix'] . $file); 
$op .= "done -> created thumb: <a href='{$config['prefix']}{$file}'>{$config['prefix']}{$file}</a>" . ENDL; 
$done++; 



closedir($handle); 
$op .= "fin -> {$done} file(s) written" . ENDL; 
echo "<pre>"; 
echo $op; 
echo "</pre>"; 
exit; 
?>

php技術PHP批量生成縮略圖的代碼,轉載需保留來源!

鄭重聲明:本文版權歸原作者所有,轉載文章僅為傳播更多信息之目的,如作者信息標記有誤,請第一時間聯系我們修改或刪除,多謝。

主站蜘蛛池模板: 国语自产免费精品视频在 | 日产精品一区二区三区免费 | 国产精品欧美日韩视频一区 | 免费精品一区二区三区第35 | 91成人午夜精品福利院在线观看 | 天天干天天干天天 | 1204曰韩欧美成人看片 | 91中文| 亚洲综人网 | avwww在线| 午夜视频在线观看免费视频 | 国产一级又裸又黄又裸又 | 999国产视频 | 伊人不卡久久大香线蕉综合影院 | 亚洲天堂五月天 | 美女网站色黄 | 国产在线视频福利 | 国产真实一区二区三区 | 国产一区不卡 | 欧美亚洲高清日韩成人 | 国产精选在线 | 色综合网站在线 | 色人影院 | 免费啪视频观在线视频在线 | 国产91激情对白露脸全程 | 涩涩爱网站 | 91九色视频无限观看免费 | 久久伊人精品青青草原2021 | 国产成人综合日韩精品婷婷九月 | 久久精品国产99久久无毒不卡 | 一区二区三区四区视频 | 亚洲一级毛片 | 美女三级视频 | 天天做天天摸天天爽天天爱 | 久久青草免费91线频观看不卡 | 伊人热热久久原色播放www | 国产成人香蕉在线视频网站 | 一区二区三区在线观看免费 | 国产精品欧美激情在线播放 | 涩涩视频网站 | 婷婷在线免费视频 |