4 list ($height, $imgpath) = explode('/', ltrim($Args, '/'), 2);
6 $imgpath = preg_replace('{^(?=[0-9]+/)}', 'data/', $imgpath, 1);
8 if (!function_exists('popen')) {
9 http_response_code(501);
11 header('Content-type: '.mime_content_type($target));
16 if (!file_exists($imgpath)) {
17 http_response_code(404);
21 $target = "thumb/$height/$imgpath";
22 if (!file_exists($target)) {
23 @mkdir(dirname($target), 0777, TRUE);
25 $cmd = implode(' ', array_map('escapeshellarg', [
28 '-resize', "${width}x${height}",
32 $return = shell_exec("$cmd 2>&1");
34 http_response_code(500);
35 trigger_error("thumbnail creation failed: $return", E_USER_WARNING);
40 header('Content-type: '.mime_content_type($target));