<?php set_time_limit(10000); error_reporting(E_ALL ^ E_NOTICE); include '../../vendor/booty/lib/Resize.class.php'; // Folder where the (original) images are located with trailing slash at the end $images_dir = '../../'; // Image to resize $image = $_GET['t']; $imgpath = $images_dir . $image; /* Some validation */ if (!@file_exists($imgpath)) { exit('The requested image does not exist.'); } $info = @GetImageSize($imgpath); $mimetype = $info['mime']; header("Content-Type: " . $mimetype); // Get the new with & height $new_width = (int) $_GET['w']; $new_height = (int) $_GET['h']; $im = new Resize($imgpath); if ($mimetype == 'image/png') { imagepng($im->crop($new_width, $new_height, "hola")); } else { imagejpeg($im->crop($new_width, $new_height, "hola")); }