rendered paste bodyfunction createthumb( $pathToImages, $pathToThumbs, $thumbWidth )
{
$ext = substr($filename, strrpos($filename, '.') + 1);
$dir = opendir( $pathToImages );
while (false !== ($fname = readdir( $dir ))) {
$info = pathinfo($pathToImages . $fname);
$ext = strtolower($ext);
if ( strtolower($info['extension']) == 'jpg'||strtolower($info['extension']) == 'jpeg'||strtolower($info['extension']) == 'gif'||strtolower($info['extension']) == 'png' )
{
switch($ext) {
case "jpg":
$img = imagecreatefromjpeg( "{$pathToImages}{$fname}" );
break;
case "jpeg":
$img = imagecreatefromjpeg( "{$pathToImages}{$fname}" );
break;
case "gif":
$img = imagecreatefromgif( "{$pathToImages}{$fname}" );
break;
case "png":
$img = imagecreatefrompng( "{$pathToImages}{$fname}" );
break;
}
echo $img;
$width = imagesx( $img );
$height = imagesy( $img );
$new_width = $thumbWidth;
$new_height = floor( $height * ( $thumbWidth / $width ) );
$tmp_img = imagecreatetruecolor( $new_width, $new_height );
imagecopyresized( $tmp_img, $img, 0, 0, 0, 0, $new_width, $new_height, $width, $height );
imagejpeg( $tmp_img, $pathToThumbs );
}
}
closedir( $dir );
}