Given a folder of images
http://fixmysite.us/masterasp/providers/images/1/
I’m trying to creaate thumbnail versions and put them within the thumbs directory in that folder
heres my scrit
createThumbs($dir."/",$dir."/thumbs/",100);
and above is where I define the function
function createThumbs( $pathToImages, $pathToThumbs, $thumbWidth )
{
// open the directory
$dir = opendir( $pathToImages );
// loop through it, looking for any/all JPG files:
while (false !== ($fname = readdir( $dir ))) {
// parse path for the extension
$info = pathinfo($pathToImages . $fname);
// continue only if this is a JPEG image
if ( strtolower($info['extension']) == 'jpg' )
{
// load image and get image size
$img = imagecreatefromjpeg( "{$pathToImages}{$fname}" );
$width = imagesx( $img );
$height = imagesy( $img );
// calculate thumbnail size
$new_width = $thumbWidth;
$new_height = floor( $height * ( $thumbWidth / $width ) );
// create a new temporary image
$tmp_img = imagecreatetruecolor( $new_width, $new_height );
// copy and resize old image into new image
imagecopyresized( $tmp_img, $img, 0, 0, 0, 0, $new_width, $new_height, $width, $height );
// save thumbnail into a file
imagejpeg( $tmp_img, "{$pathToThumbs}{$fname}" );
}
}
// close the directory
closedir( $dir );
}
when I run it, I get this?
Warning: imagecreatefromjpeg() [function.imagecreatefromjpeg]: gd-jpeg: JPEG library reports unrecoverable error: in /home/fixmy1/public_html/masterasp/providers/insert.php on line 16
Warning: imagecreatefromjpeg() [function.imagecreatefromjpeg]: ‘images/1/1370928156-mockup3.jpg’ is not a valid JPEG file in /home/fixmy1/public_html/masterasp/providers/insert.php on line 16
Warning: imagesx() expects parameter 1 to be resource, boolean given in /home/fixmy1/public_html/masterasp/providers/insert.php on line 17
Warning: imagesy() expects parameter 1 to be resource, boolean given in /home/fixmy1/public_html/masterasp/providers/insert.php on line 18
Warning: Division by zero in /home/fixmy1/public_html/masterasp/providers/insert.php on line 22
Warning: imagecreatetruecolor() [function.imagecreatetruecolor]: Invalid image dimensions in /home/fixmy1/public_html/masterasp/providers/insert.php on line 25
Warning: imagecopyresized() expects parameter 1 to be resource, boolean given in /home/fixmy1/public_html/masterasp/providers/insert.php on line 28
Warning: imagejpeg() expects parameter 1 to be resource, boolean given in /home/fixmy1/public_html/masterasp/providers/insert.php on line 31
I dont understand what that error means…