Hallo zusammen
Ich habe ein Problem mit meiner Bildergallerie.
Ich möchte alle Bilder verkleinert darstellen.
Ich habe zwei Dateien, die eine stellt die Bilder dar, die andere erzeigt diese.
Die erste Datei liest Bilder aus einem Ordner, speichert diese in einem Array und stellt diese anschliessend mit hilfe der zweiten Datei dar.
Darstellung:
<?
$x = 0;
$pfad = "felix/gallery/bilder/Marokko";
$erlaubte_typen = ".jpg .gif";
if ($handle = opendir($pfad)) {
while (false !== ($bild = readdir($handle))) {
$extension = strrchr($bild, ".");
if ($bild != "." && $bild != ".." && (strpos($erlaubte_typen, $extension) !== false)) {
$array[$x] = $bild;
$x++;
}
}
closedir($handle);
}
for($x = 0; $x < count($array); $x++){
$path = $pfad."/".current($array);
echo "<img src="thumb.php?source=".$path."&height=150&width=150">";
next($array);
}
?>
erzeugung der Bilder:
<?
$imgFile = $_GET["source"];
$width = $_GET["width"];
$height = $_GET["height"];
$maxWidth = 200;
$maxHeight = 200;
$image = imagecreatefromstring(file_get_contents($imgFile));
$oldSize = $imgSize = array(imagesx($image), imagesy($image));
if($width > $maxWidth)
{
$height *= $maxWidth / $width;
$width = $maxWidth;
}
if($height > $maxHeight)
{
$width *= $maxHeight / $height;
$height = $maxHeight;
}
$thumbnail = imagecreatetruecolor($width, $height);
imagecopyresampled($thumbnail, $image, 0, 0, 0, 0, $width, $height, $oldSize[0], $oldSize[1]);
imagedestroy($image);
if($output == '')
header('Content-type: image/jpeg');
imagejpeg($thumbnail, $output, 80);
imagedestroy($thumbnail);
?>
Die Pfade stimmen alle und die Datei kann auch Thumbnais erzeugen, trotzdem funktioniert es nicht.
Gruss Jonas