auf meinem webserver befinden sich in einem verzeichnis ca 20 bilder.
ich will daraus eine galerie machen und die bilder sollen als thumbnail gezeigt werden.
wie erstelle ich thumbnails.
kantenlänge sollte 75 pixel lang sein.
vielen dank

Code: Alles auswählen
<?php
$count = 0;
$i = 0;
$path = "./bilder/";
$handle = opendir($path);
while ($file = readdir ($handle))
{
if (is_file($path.$file) && $file != "." && $file != "..")
{
$inhalt[count($inhalt)] = $file;
$count++;
}
}
closedir($handle);
rsort($inhalt, SORT_NUMERIC);
while ($i != $count)
{
$bilderpfad = "./bilder";
$thumbpfad = "./bilder/thumbnails";
$bildname = $inhalt[$i];
$bild = "$bilderpfad/$bildname";
$thumb = "$thumbpfad/$bildname";
if (!file_exists($thumb))
{
$src_img = ImageCreateFromJPEG($bild);
$width = "50";
$im_width = imageSX($src_img);
$im_height = imageSY($src_img);
$faktor = $width/$im_width;
$new_w = $width;
$new_h = $im_height * $faktor;
$dst_img = imagecreatetruecolor($new_w,$new_h);
// $dst_img = imagecreate($new_w,$new_h);
imagecopyresampled($dst_img,$src_img,0,0,0,0,$new_w,$new_h,imagesx($src_img),imagesy($src_img));
// imagecopyresized($dst_img,$src_img,0,0,0,0,$new_w,$new_h,imagesx($src_img),imagesy($src_img));
imagejpeg($dst_img,$thumb);
}
echo "<a href=\"",$bild,"\"><img src=\"", $thumb, "\" border=\"0\"></a> ";
$i++;
}
?>