its all working fine i have 40 images and i get 40 thumbs..
just displayes errors.
Code: Select all
<?php
$dir1 = "images";
$dh = opendir($dir1);
while (false !== ($filename = readdir($dh))) {
$files[] = $filename;
}
sort($files);
rsort($files);
$dir = "images/";
if (!file_exists($dir."/thumbs")){
mkdir($dir."/thumbs", 0777 );
}
foreach ($files as $file) {
if (!file_exists($dir."thumbs/THUMBS_".$file)){
$minwidth = "150";
$minheight = "150";
$photosize = getimagesize($dir.$file);
// Get image size and scale ratio
$scale = min("150"/$photosize[0], "150"/$photosize[1]);
if ($scale < 1) {
$width = floor($scale*$photosize[0]);
$height = floor($scale*$photosize[1]);
}
else {
$width = $minwidth;
$height = $minheight;
}
if ($photosize['mime']=="image/jpeg") {
$resizedimage = imagecreatetruecolor($width, $height);
$thumbimage = imagecreatefromjpeg($dir.$file);
imagecopyresampled($resizedimage, $thumbimage, 0, 0, 0, 0, $width, $height, $photosize[0], $photosize[1]);
imagejpeg($resizedimage,$dir."/thumbs/THUMBS_".$file,100);
imageDestroy($resizedimage);
imageDestroy($thumbimage);
}
}
}
?>Errors
Warning: getimagesize() [function.getimagesize]: Read error! in /home/tyspicsc/public_html/personal/test.php on line 101
Warning: Division by zero in /home/tyspicsc/public_html/personal/test.php on line 103
Warning: Division by zero in /home/tyspicsc/public_html/personal/test.php on line 103
Warning: getimagesize() [function.getimagesize]: Read error! in /home/tyspicsc/public_html/personal/test.php on line 101
Warning: Division by zero in /home/tyspicsc/public_html/personal/test.php on line 103
Warning: Division by zero in /home/tyspicsc/public_html/personal/test.php on line 103
Warning: getimagesize() [function.getimagesize]: Read error! in /home/tyspicsc/public_html/personal/test.php on line 101
Warning: Division by zero in /home/tyspicsc/public_html/personal/test.php on line 103
Warning: Division by zero in /home/tyspicsc/public_html/personal/test.php on line 103