一区二区久久-一区二区三区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技術(shù)PHP批量生成縮略圖的代碼,轉(zhuǎn)載需保留來源!

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

主站蜘蛛池模板: 91视频这里只有精品 | 97在线播放视频 | 999精品视频 | 欧美激情乱人伦 | 2021国产精品系列一区二区 | 精品久久久久久午夜 | 日本精品国产 | 在线成人小视频 | 四色最新网址 | 日韩成人免费一级毛片 | 亚洲成人伊人网 | 婷婷色激情 | 久久青青草原精品国产软件 | 五月激情六月丁香 | 久久亚洲精品国产精品婷婷 | 起碰97 | 国产高颜值露脸在线观看 | 伊人中文字幕在线观看 | 一级毛片成人午夜 | 色老板最新地址 | 国产精品乱 | 欧美色视频网站 | 中文字幕一区在线播放 | 激情一区二区三区成人 | 久久综合色鬼 | 亚洲欧美日韩国产精品第不页 | 爱爱一区| 午夜免费 | 伊人久久狼人 | 婷婷综合网站 | 6080午夜乱理伦片 | 国产线视频精品免费观看视频 | 色多多网站入口 | 激情综合色综合久久综合 | 人与禽物videos另类 | 久久久久综合网 | 中文字幕1区2区 | 国产一区二区高清 | 久久中文字幕不卡一二区 | 在线亚洲精品中文字幕美乳 | 黄网站在线观看高清免费 |