一個頁面,列出幾百個頭像的圖標,。尺寸是64x64的,而我有全部圖標的160x160尺寸的,如果全部加載大圖標,那頁面顯示比較慢,那我就需要做出一份小圖標,如下:
set_time_limit(0); $handle = opendir('icon/.'); while( false !== ($file = readdir($handle)) ){if($file != '.' && $file != '..'){$im = imagecreatefromjpeg('./icon/'.$file);$pic = imagecreatetruecolor(64,64);imagecopyresampled($pic,$im,0,0,0,0,64,64,160,160);imagejpeg($pic,'./icon64/'.$file,100);}} echo 'Well Done^-^!';
php输出html。