<?php
// Create a 100*30 image
$im = imagecreate(400, 300);
$path = '/var/www/cache/' . md5( json_encode($_GET) );
//echo $path; exit();
if ( file_exists($path) ) 
{
//	exit();
   //header('Content-Disposition: attachment; filename="' . $_GET['filename'] . '"');
   header('Content-type: image/png');
   echo file_get_contents($path);
   exit();
}


// White background and blue text
$bg = imagecolorallocate($im, 255, 255, 255);
$textcolor = imagecolorallocate($im, 0, 0, 255);

// Write the string at the top left
imagestring($im, 5, 0, 0, 'Hello ' . json_encode($_GET), $textcolor);

// Output the image
//header('Content-Disposition: attachment; filename="' . $_GET['filename'] . '"');
header('Content-type: image/png');

imagepng($im, $path);
echo file_get_contents($path);

imagedestroy($im);
