rendered paste body<?php
require '_config.php';
header ("Content-type: image/png");
$filename = "bild.jpg";
$im = @imagecreatetruecolor(WIDTH, HEIGHT)
or die("trasigt!");
list($width, $height) = getimagesize($filename);
$w = $width/WIDTH;
$h = $height/HEIGHT;
if($w==$h) { // The AR is correct
$nwidth = $w;
$nheight = $h;
}
elseif($w>$h) { // It's too wide!
$nwidth = $width/$h;
$nheight = $height/$h;
}
elseif($w<$h) { // It's too tall!
$nwidth = $width/$w;
$nheight = $height/$w;
}
$newimage = imagecreatetruecolor(WIDTH, HEIGHT);
$image = imagecreatefromjpeg($filename);
imagecopyresampled($newimage, $image, 0, 0, 0, 0, $nwidth, $nheight, $width, $height);
// Output
imagejpeg($newimage, null, 100);
?>