Thumbnail script working but still creating errors??

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
farkewie
Forum Newbie
Posts: 22
Joined: Sat Jun 02, 2007 11:25 pm

Thumbnail script working but still creating errors??

Post by farkewie »

hi am building my own web album and i have my script creating thumbnails but i am getting errors.

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

Post Reply