我有一个脚本,它递归地循环遍历所有子目录并压缩所有 jpeg。我在压缩前后打印文件大小,但打印的数字相同。我正在运行的脚本是:
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
}
}
}
}
我得到的输出是:
压缩文件/1013/0079/3180/Beautifully_renovated_garden_apartment_in_Rehavia_7.JPG... 从(58666 字节)到(58666 字节)... 压缩文件/1013/0088/0559/Exquisite_stand_alone_house_in_Givat_Hamivtar_exceptional_views_3.JPG... 从(49786 字节)到(49786 字节) 49786 字节)... 压缩文件/1013/0088/0587/Exquisite_stand_alone_house_in_Givat_Hamivtar_exceptional_views_6.JPG... 从(18994 字节)到(18994 字节)... 压缩文件/1013/0138/4914/Beautiful_4_rooms_apartment_with_views_to_the_Old_City...从(527801 字节) 到 (527801 字节)... 压缩文件/1013/0208/0656/Fevrier_2011_005.JPG... 从 (35607 字节) 到 (35607 字节)... 压缩文件/1013/0216/6078/Beautiful_townhouse_in_the_heart_of_the_German_Colony_00 .JPG... 从(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... 从(2 字节) 20912 字节)... 压缩文件/1013/0821/0299/Beautiful_views_to_the_Knesset_and_Gan_Saker_016.JPG... 从(570428 字节)到(570428 字节)... 压缩文件/1013/0822/0660/Beautiful_new_penthouse_in_luxurious_building_with_pool_158double.jpg... (1020561 字节) 到 (1020561 字节)... 压缩文件/1013/0847/8190/New_luxurious_penthouse_with_private_entrance_in_Old_Katamon_016.JPG... 从 (542071 字节) 到 (542071 字节)... ... ... ...压缩文件/1013/0269/0299/Exclusive_Duplex_Penthouse_in_the_German_Colony_0171.jpg... 从(20912 字节)到(20912 字节)... 压缩文件/1013/0821/0299/Beautiful_views_to_the_Knesset_and_Gan_Saker_016.JPG... 从(570428 字节) 570428 字节)... 压缩文件/1013/0822/0660/Beautiful_new_penthouse_in_luxurious_building_with_pool_158double.jpg... 从(1020561 字节)到(1020561 字节)... 压缩文件/1013/0847/8190/New_luxurious_penthouse_with_private_entrance_in_Old_K... (542071 字节)到(542071 字节)... ... ... ...压缩文件/1013/0269/0299/Exclusive_Duplex_Penthouse_in_the_German_Colony_0171.jpg... 从(20912 字节)到(20912 字节)... 压缩文件/1013/0821/0299/Beautiful_views_to_the_Knesset_and_Gan_Saker_016.JPG... 从(570428 字节) 570428 字节)... 压缩文件/1013/0822/0660/Beautiful_new_penthouse_in_luxurious_building_with_pool_158double.jpg... 从(1020561 字节)到(1020561 字节)... 压缩文件/1013/0847/8190/New_luxurious_penthouse_with_private_entrance_in_Old_K... (542071 字节)到(542071 字节)... ... ... ...正在压缩文件/1013/0822/0660/Beautiful_new_penthouse_in_luxurious_building_with_pool_158double.jpg... 从(1020561 字节)到(1020561 字节)... 压缩文件/1013/0847/8190/New_luxurious_penthouse_with_private_entrance_in_Old_Katamon_016.JPG... 从(452071 字节) 542071 字节)... ... ... ...正在压缩文件/1013/0822/0660/Beautiful_new_penthouse_in_luxurious_building_with_pool_158double.jpg... 从(1020561 字节)到(1020561 字节)... 压缩文件/1013/0847/8190/New_luxurious_penthouse_with_private_entrance_in_Old_Katamon_016.JPG... 从(452071 字节) 542071 字节)... ... ... ...
有人可以告诉我是什么问题吗?为什么尺寸没有更新?
非常感谢!