<?php
// Max Sizes
$th_max_width = 250;  // Maximum width of the thumbnail
$th_max_height = 250; // Maximum height of the thumbnail

//-------------------

// File
$filename = $_GET['file'];

// Content type
header('Content-type: image/jpeg');

// Get image sizes
list($width, $height) = getimagesize($filename);

// Resize
$ratio = ($width > $height) ? $th_max_width/$width : $th_max_height/$height;
$newwidth = round($width * $ratio);
$newheight = round($height * $ratio);

// Load
$thumb = imagecreatetruecolor($newwidth, $newheight);
$source = imagecreatefromjpeg($filename);

//Resize
imagecopyresized($thumb, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);

// Output
imagejpeg($thumb);
?>

<?php
exit;
?>