<?php
$bilddatei = $_GET['bild'];
if ($_GET['breite'] == '') {
$grundbild = imagecreatefromjpeg($bilddatei);
$size=GetImageSize($bilddatei);
$origwidth=$size[0];$origheight=$size[1];
if (($origwidth/$origheight)>(1+1/3)){
$newheight=130;
$newwidth=$origwidth*($newheight/$origheight);
} else {
$newwidth=180;
$newheight=$origheight*($newwidth/$origwidth);
}
$temp=@ImageCreateTrueColor(180,130); //Verkleinertes Bild
ImageCopyResampled($temp,$grundbild,0,0,0,0,$newwidth,$newheight,$origwidth,$origheight);
$new = imagecreatefromjpeg('pic.jpg');
imagecopy($new,$temp,10,10,0,0,180,130);
header("Content-type: image/jpeg");
Imagejpeg($new,'',80);
} else {
//Bestimmung der dimensionen des Vorschaubildes
$size = GetImageSize ($bilddatei);
if ($size[0] > $_GET['breite']) {
$origwidth =$size[0];
$origheight =$size[1];
$newwidth = $_GET['breite'];
$newheight=$origheight*($newwidth/$origwidth);
} else {
$newheight = $size[1];
$newwidth = $size[0];
$origheight = $size[1];
$origwidth = $size[0];
}
//Verkleinerung des Bildes
$alt = @ImageCreateFromJPEG ($bilddatei);
$temp = @ImageCreateTrueColor ($newwidth, $newheight);
ImageCopyResampled ($temp,$alt,0,0,0,0,$newwidth,$newheight,$origwidth,$origheight);
header ("Content-type: image/jpeg");
Imagejpeg($temp,'',80);
}
?>