모든 하위 디렉토리를 반복적으로 반복하고 모든 jpeg를 압축하는 스크립트가 있습니다. 압축 전후에 파일 크기를 인쇄하지만 같은 번호를 인쇄합니다.이미지 압축하기 - 이미지 크기 얻기 PHP
set_time_limit (86000);
ob_implicit_flush(true);
$main = "files";
function readDirs($main){
$dirHandle = opendir($main);
while($file = readdir($dirHandle)){
$newFile = $main.'/'.$file;
if(is_dir($newFile) && $file != '.' && $file != '..'){
readDirs($newFile);
}
else{
if($file != '.' && $file != '..' && stristr($newFile,'.jpg'))
{
//echo $newFile.'</br>';
$img = imagecreatefromjpeg($newFile);
echo 'Compressing '.$newFile.'... from ('.filesize($newFile).' bytes) to (';
imagejpeg($img,$newFile, 30);
echo filesize($newFile).' bytes)...<br>';
for($k = 0; $k < 40000; $k++)
echo ' '; // extra spaces to fill up browser buffer
}
}
}
}
내가 얻을 출력은 다음과 같습니다 : 나는 실행하고 스크립트는 파일을 압축
// 0079/3180/Beautifully_renovated_garden_apartment_in_Rehavia_7.JPG 1013 ...에서 (58,666 바이트) (58,666 바이트) ... 파일을 압축하는// 0,559/0,088 1,013/Exquisite_stand_alone_house_in_Givat_Hamivtar_exceptional_views_3.JPG ... 파일을 압축 (49,786 바이트) 내지 (49,786 바이트) ...에서 /1,013/0,088/0,587/Exquisite_stand_alone_house_in_Givat_Hamivtar_excep tional_views_6.JPG ... ~ (18994 bytes) ~ (18994 bytes) ... 파일 압축/1013/0138/4914/Beautiful_4_rooms_apartment_with_views_to_the_Old_City_2.JPG ... (527801 바이트) ~ (527801 바이트) ... 파일/압축/0,208 1,013/0,656/Fevrier_2011_005.JPG (35,607 바이트) 내지 (35,607 바이트) ... 파일을 압축// 0216/6078/Beautiful_townhouse_in_the_heart_of_the_German_Colony_00.JPG ... 발 (1013 42509 바이트 수) ~ (42509 바이트) ... 파일 압축/1013/0217/1359/Unique_luxurious_new_penthouse_in_the_heart_of_the_German_Colony_028.jpg ... (1101251 바이트) ~ (1101251 바이트) ... 파일/1013/0269/0299 / Exclusive_Duplex_Penthouse_in_the_German_Colony_0171.jpg ... 파일을 압축 (20,912 바이트 내지 20912 바이트)에서 516,...// 0,821 1,013/0,299/Beautiful_views_to_the_Knesset_and_Gan_Saker_016.JPG ... 압축 (570,428 바이트) 내지 (570,428 바이트) ...에서 파일/1,013/0822/0660/Beautiful_new_penthouse_in_luxurious_building_with_pool_158double.jpg .../8,190/0,847 1,013/New_luxurious_penthouse_with_private_entrance_in_Old_Katamon_016.JPG ... (542,071 바이트) 내지 파일/압축 (바이트 1,020,561 내지 1,020,561 바이트) ...에서 (542,071 바이트) ... ... ... ...
누군가가 내게 어떤 문제가 있다고 말할 수 있습니까? 크기가 업데이트되지 않는 이유는 무엇입니까?
고마워요!
두 파일 사이에서'clearstatcache()'를 시도하십시오. –
예루살렘에는 독일 식민지가 있습니까? 흥미 롭 군. (아, 그리고 19 세기에 그다지! 위키 피 디아를 읽는 내 점심 시간이 간다.) 소년, 그 저택을 소유하고 싶다. 아니면 펜트 하우스! * 잠꼬대 *) –
고마워! 그것은 트릭을했다!! – Meir