<?php
#=============================
# ::MaxResizer by DDoSer::
# icq 4410203
# v. 1.1
#=============================
$ns=0;
error_reporting(0);
$t1=time();
$zag='Фaйлы';
$dir=opendir('image');
while($file=readdir($dir)){
if($file!='..' and $file!='.' and $file!='.jpg'){
if($ns<1000){
if('image' and strpos($file,'-')) $fname=strstr($file,'-'); else $fname=$file;
$fname=strtr($fname,array('_'=>'_','-'=>'-'));
//$fname=str_replace('_','',$fname);
if('image'){
$str=filesize("image/$file");
!!!$file='image'.'/'.$file;
}else $str=filesize($file);
$size=round($str/1024,1);
if(strpos($file,'.')){
$fname=strtok($fname,'.');
$ns++; /*$tsize=$tsize+$str; */ }}}//$cnt++;
/////проверка
if($k<1 or $k>100){$k=75;print'<font color=\"blue\"><b>[качество картинок изменено на 75</b></font><br>';}//проверяем качество
if($ks<1 or $ks>100){$ks=40;print'<font color=\"blue\"><b>[качество скринов изменено на 40</b></font><br>';}//проверяем качество
$q=explode('.',$file);
if($q[1]=='jpg' or $q[1]=='jpeg' or $q[1]=='JPG'){
$from = imageCreateFromJpeg("$file");}
if($q[1]=='gif'){
$from = imageCreateFromGif("$file");}
if($fname){
/////записываем
if($r_32){
if(!file_exists("32x32"))mkDir("32x32");
$to = imageCreateTrueColor(32, 32);
imageCopyResized(
$to, $from, 0, 0, 0, 0, imageSX($to), imageSY($to),
imageSX($from), imageSY($from)
);imageJpeg($to,"32x32/$fname.jpg","$ks");
}
#####
if($r_40){
if(!file_exists("40x40"))mkDir("40x40");
$to = imageCreateTrueColor(40, 40);
imageCopyResized(
$to, $from, 0, 0, 0, 0, imageSX($to), imageSY($to),
imageSX($from), imageSY($from)
);imageJpeg($to,"40x40/$fname.jpg","$ks");
}
#####
if($r_128){
if(!file_exists("128x128"))mkDir("128x128");
$to = imageCreateTrueColor(128, 128);
imageCopyResampled(
$to, $from, 0, 0, 0, 0, imageSX($to), imageSY($to),
imageSX($from), imageSY($from)
);imageJpeg($to,"128x128/$fname.jpg","$k");
}
#####
if($r_160){
if(!file_exists("128x160"))mkDir("128x160");
if(imageSX($from)<imageSY($from)) $to = imageCreateTrueColor(128, 160);
else $to = imageCreateTrueColor(160, 128);
imageCopyResampled(
$to, $from, 0, 0, 0, 0, imageSX($to), imageSY($to),
imageSX($from), imageSY($from)
);}imageJpeg($to,"128x160/$fname.jpg","$k");
#####
if($r_176){
if(!file_exists("176x176"))mkDir("176x176");
$to = imageCreateTrueColor(176, 176);
imageCopyResized(
$to, $from, 0, 0, 0, 0, imageSX($to), imageSY($to),
imageSX($from), imageSY($from)
);imageJpeg($to,"176x176/$fname.jpg","$k");
}
#####
if($r_220){
if(!file_exists("176x220"))mkDir("176x220");
if(imageSX($from)<imageSY($from)) $to = imageCreateTrueColor(176, 220);
else $to = imageCreateTrueColor(220, 176);
imageCopyResized(
$to, $from, 0, 0, 0, 0, imageSX($to), imageSY($to),
imageSX($from), imageSY($from)
);imageJpeg($to,"176x220/$fname.jpg","$k");
}
#####
if($r_240){
if(!file_exists("240x240"))mkDir("240x240");
$to = imageCreateTrueColor(240, 240);
imageCopyResized(
$to, $from, 0, 0, 0, 0, imageSX($to), imageSY($to),
imageSX($from), imageSY($from)
);imageJpeg($to,"240x240/$fname.jpg","$k");
}
#####
if($r_320){
if(!file_exists("240x320"))mkDir("240x320");
if(imageSX($from)<imageSY($from)) $to = imageCreateTrueColor(240, 320);
else $to = imageCreateTrueColor(320, 240);
imageCopyResized(
$to, $from, 0, 0, 0, 0, imageSX($to), imageSY($to),
imageSX($from), imageSY($from)
);imageJpeg($to,"240x320/$fname.jpg","$k");
}
print"<font color='green'>[$fname.jpg - ok</font><br>";
}
/////конец записи
}
closedir($dir);
$t2=time();
$rr=$t2-$t1;
print"<font color='blue'><b>[ Время выполнения(сек.): $rr</b></font><br>";
?>