6 public function handle($uri)
8 if (!isset($_GET['path'])) {
9 return $this->error('400 Bad request', 'Path missing');
12 $path = $GLOBALS['imagestore']['basedir'] . $_GET['path'];
13 if (!file_exists($path)) {
14 return $this->error('404 Not Found', 'File not found');
17 if (!isset($_GET['w'])) {
18 header('Content-type: image/jpeg');
19 header('Content-length: ' . filesize($path));
20 return readfile($path);
24 $img = imagecreatefromjpeg($path);
26 $newWidth = (int) $_GET['w'];
27 //if (isset($_GET['h'])) {
28 // $newHeight = (int) $_GET['h'];
30 $newHeight = intval($newWidth / imagesx($img) * imagesy($img));
33 $thumb = imagecreatetruecolor($newWidth, $newHeight);
36 $thumb, $img, 0, 0, 0, 0,
37 $newWidth, $newHeight, imagesx($img), imagesy($img)
41 header('Content-type: image/jpeg');
46 protected function error($error, $message)
48 header('HTTP/1.0 ' . $error);
49 header('Content-type: text/plain; charset=utf-8');