Aso.
<?php
$pfad = substr($wert,0,strripos($wert,'/')+1);
//Pfad vom DocRoot aus
$ordner = '/'.$_GET['ordner'];
//Und jetzt die Präfix Sache
$praefix = 'tn_';
//maximale Abmessungen
$width = 200;
$height = 200;
foreach(glob($_SERVER['DOCUMENT_ROOT'].$ordner.'/*.jpg') as $wert){
list($width_orig, $height_orig) = getimagesize($wert);
$ratio_orig = $width_orig/$height_orig;
//Zielgrössen des Thumbs bestimmen
if ($width/$height > $ratio_orig) {
$width = $height*$ratio_orig;
} else {
$height = $width/$ratio_orig;
}
//Img Ressource für Thumb
$image_p = imagecreatetruecolor($width, $height);
//Img Ressource vom Original
$image = imagecreatefromjpeg($wert);
imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height, $width_orig, $height_orig);
//Thumbs im selben Ordner wie Original speichern
imagejpeg($image_p,$praefix.$wert, 100);
//Ausgabe des Thumbs in HTML
echo '<a href="'.$ordner.'/'.basename($wert).'">
<img src="'.$ordner.'/'.basename(str_replace('.jpg',$praefix.'.jpg',$pfad)).'" /><br />';
}
?>
<html>
<head>
<title>test</title>
</head>
<body bgcolor="white" text="black" link="blue" vlink="purple" alink="red">
<?php
$pfad = substr($wert,0,strripos($wert,'/')+1);
//Pfad vom DocRoot aus
$ordner = '/'.$_GET['ordner'];
//Und jetzt die Präfix Sache
$praefix = 'tn_';
//maximale Abmessungen
$width = 200;
$height = 200;
foreach(glob($_SERVER['DOCUMENT_ROOT'].$ordner.'/*.jpg') as $wert){
list($width_orig, $height_orig) = getimagesize($wert);
$ratio_orig = $width_orig/$height_orig;
//Zielgrössen des Thumbs bestimmen
if ($width/$height > $ratio_orig) {
$width = $height*$ratio_orig;
} else {
$height = $width/$ratio_orig;
}
//Img Ressource für Thumb
$image_p = imagecreatetruecolor($width, $height);
//Img Ressource vom Original
$image = imagecreatefromjpeg($wert);
imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height, $width_orig, $height_orig);
//Thumbs im selben Ordner wie Original speichern
imagejpeg($image_p,$praefix.$wert, 100);
//Ausgabe des Thumbs in HTML
echo '<a href="'.$ordner.'/'.basename($wert).'">
<img src="'.$ordner.'/'.basename(str_replace('.jpg',$praefix.'.jpg',$pfad)).'" /></a><br />';
}
?>
</body>
</html>
Kommentar