<?php
error_reporting(0);

header('Content-type: image/png');

if($_GET['bg']){
$file = 'bg/'.htmlspecialchars(trim($_GET['img']));
}
else{
$file = 'get/'.htmlspecialchars(trim($_GET['img']));
}

$x = intval($_GET['x']);
$y = intval($_GET['y']);

$best = intval($_GET['best']);


if($x > 240){exit;}
if($y > 320){exit;}

$ImgCreate = imagecreatefrompng($file);
$Weight = imageSX($ImgCreate);
$Height = imageSY($ImgCreate);
$NewImg = imagecreatetruecolor($x, $y);
imageCopyResized($NewImg, $ImgCreate, 0, 0, 0, 0, $x, $y, $Weight, $Height);

imagePng($NewImg, null, $best);
?>