<?php
$filename = $_GET['file'];
$percent = 0.2;
$font = "arial";
$fontsize = 7;
header('Content-type: image/jpeg');
list($width, $height) = getimagesize($filename);
$new_width = $width * $percent;
$new_height = $height * $percent;
$image_p = imagecreatetruecolor($new_width + 2, $new_height + 20);
$backgroundcolor = imagecolorallocate($image_p,5,90,177);
$background = imagefill($image_p,0,0,$backgroundcolor);
$image = imagecreatefromjpeg($filename);
imagecopyresampled($image_p, $image, 1, 1, 0, 0, $new_width, $new_height, $width, $height);
$tcolor = imagecolorallocate($image_p,255,255,255);
$t = "CLICK TO ENLARGE " . $width . "x" . $height;
$fontwidth = imagettfbbox($fontsize,0,$font,$t);
$g = abs($fontwidth[1]) + abs($fontwidth[2]);
imagettftext($image_p,$fontsize,0,$new_width / 2 - ($g / 2),$new_height + 14,$tcolor,$font,$t);
imagejpeg($image_p, null, 100);
?>