"; echo "Tid:".date('h:i:s')."
"; system('mkdir ./images'); system('mkdir ./thumbnail'); } if ($handle = opendir(getcwd())) { //$n anger på vilket nummer som skriptet ska börja på $n = 0; echo $mapp; $run = true; $l = 0; $filearray = array(); // sätter alla filer i en array och sen sorterar de efter while-stasen while (false !== ($file = readdir($handle) )) { // kollar så att filen verkligen är en bild. $imagetype = @getimagesize($file); if($imagetype[2] == '2') { $filearray[$l] = $file; $l++; } } sort($filearray); while ($n+1 < $l){ //Kollar ifall bilden är en bild $imagetype = @getimagesize($filearray[$n]); if($imagetype[2] == '2') { //sätter variablerna till höjd o bredd. list($width, $height, $type, $attr) = getimagesize($filearray[$n]); if ($width > $height) { // stora bilderna storlek $thumb_width = "758"; $thumb_height = "569"; //round(($width/($height/$thumb_height)), 0); // miniatyr bilderna storlek $thumb_width2 = "75"; $thumb_height2 = "51"; echo "
--A-- Filen har storlek:".$width."x".$height.". Nya mått:".$thumb_width." ".$thumb_height." Namn: ".$filearray[$n]; } else { // stora bilderna storlek $thumb_width = "569"; //round(($width/($height/$thumb_height)), 0); $thumb_height = "758"; // miniatyr bilderna storlek $thumb_width2 = "51"; $thumb_height2 = "75"; // $thumb_heigh = ($thumb_width/$width) * $width; echo "
--B-- Filen har storlek:".$width."x".$height.". Nya mått:".$thumb_width." ".$thumb_height." Namn: ".$filearray[$n]; } echo " n=".$n." och l:".$l." ".$filearray[$n]; //Ändra bara storlkene om variablen $run är true if($run == false) $n ++; if($run == true && ($width > "758" && $height > "497")) { $nname = $n+1; // stora bilden echo " <<--- Just nu ändrar jag på bild:".$filearray[$n]." tiil namn:".$nname.".jpg ... "; $image_handle = imagecreatefromjpeg($filearray[$n]); $thumbnail = imagecreatetruecolor($thumb_width, $thumb_height) or $thumbnail = imagecreate($thumb_width, $thumb_height); imagecopyresampled($thumbnail, $image_handle, 0, 0, 0, 0, $thumb_width, $thumb_height, $width, $height); //resample the original onto $thumbnail (which is a blank image) // unlink("user/avatars/$uid.jpg");//now delete the original $bildnamn = "./images/".$filearray[$n]; imagejpeg($thumbnail, $bildnamn, '80'); //actually create a jpg from $thumbnail, store it in location $avatar_url, with quality $thumb_quality imagedestroy($image_handle); //clear buffer #*$! imagedestroy($thumbnail); // thumbnailen $image_handle2 = imagecreatefromjpeg($filearray[$n]); $thumbnail2 = imagecreatetruecolor($thumb_width2, $thumb_height2) or $thumbnail2 = imagecreate($thumb_width2, $thumb_height2); imagecopyresampled($thumbnail2, $image_handle2, 0, 0, 0, 0, $thumb_width2, $thumb_height2, $width, $height); //resample the original onto $thumbnail (which is a blank image) $thumbnamn = "./thumbnail/".$filearray[$n]; imagejpeg($thumbnail2, $thumbnamn, '80'); //actually create a jpg from $thumbnail, store it in location $avatar_url, with quality $thumb_quality imagedestroy($image_handle2); //clear buffer #*$! imagedestroy($thumbnail2); // tar bort den aktuella filen //system('rm '.$filearray[$n], $retval); ob_end_flush();//end output buffering $n ++; } } } closedir($handle); //ta bort tmp-mappen chdir("../"); echo getcwd(); system('rm -r ./tmp/'); echo "
Tid:".date('h:i:s')."
"; } ?>