<?php
function createimage($width, $height){
$imgh = imagecreate($width, $height);
$bgc = imagecolorallocate($imgh, 230, 230, 230);
return $imgh;
}
if($path){ // Thumbnail
$height = 50; // Maximalhöhe
$width = 120; // Maximalbreite
$img_size = getimagesize($path);
$img_size[4] = $img_size[1]/$height;
$faktor = 100/$img_size[4];
$img_size[1] = $img_size[1]/100;
$img_size[0] = $img_size[0]/100;
$img_size[1] = $img_size[1]*$faktor;
$img_size[0] = $img_size[0]*$faktor;
if($img_size[0] >= 120){
$img_size[4] = $img_size[0]/$width;
$faktor2 = 100/$img_size[4];
if($faktor2 << $faktor){
$img_size[1] = $img_size[1]/100;
$img_size[0] = $img_size[0]/100;
$img_size[1] = $img_size[1]*$faktor2;
$img_size[0] = $img_size[0]*$faktor2;
}
}
$imgh = createimage($img_size[0], $img_size[1]);
$imgh2 = imagecreatefromjpeg($path);
$imgsz = getimagesize($path);
$black = imagecolorallocate($imgh2, 0, 0, 0);
imagecopyresized($imgh, $imgh2, 0, 0, 0, 0, $img_size[0], $img_size[1], $imgsz[0], $imgsz[1]);
header("Content-Type: image/jpeg");
imagejpeg($imgh, '', 100);
imagedestroy($imgh);
} else { // Dateianzeige
$mydir = dir("./");
while($file=$mydir->read()) {
if(getimagesize($file)){
echo '<img src="' . $PHP_SELF . '?path=' . $file . '"><br>';
}
}
}
?>