3 if (!file_exists($_REQUEST['url'])) {
4 header ("Content-type: text/html");
5 echo "<html><head></head><body>Not an image</body></html>";
9 list ($a, $b, $type, $attr) = @getimagesize ($_REQUEST['url']);
13 $type = basename ($_REQUEST['url']);
14 $type = preg_split ('/\./',$type);
15 $type = array_pop ($type);
22 if (function_exists("imagecreatefromjpeg"))
23 $img = @imagecreatefromjpeg ($_REQUEST['url']);
25 show_plain ($_REQUEST['url']);
28 if (function_exists("imagecreatefrompng"))
29 $img = @imagecreatefrompng ($_REQUEST['url']);
31 show_plain ($_REQUEST['url']);
34 if (function_exists("imagecreatefromgif"))
35 $img = @imagecreatefromgif ($_REQUEST['url']);
37 show_plain ($_REQUEST['url']);
40 if (function_exists("imagecreatefromwbmp"))
41 $img = @imagecreatefromwbmp ($_REQUEST['url']);
43 show_plain ($_REQUEST['url']);
46 if (function_exists("imagecreatefromxbm"))
47 $img = @imagecreatefromxbm ($_REQUEST['url']);
49 show_plain ($_REQUEST['url']);
52 if (function_exists("imagecreatefromxpm"))
53 $img = @imagecreatefromxpm ($_REQUEST['url']);
55 show_plain ($_REQUEST['url']);
58 if (function_exists("imagecreatefromgd"))
59 $img = @imagecreatefromgd ($_REQUEST['url']);
61 show_plain ($_REQUEST['url']);
64 if (function_exists("imagecreatefromgd2"))
65 $img = @imagecreatefromgd2 ($_REQUEST['url']);
67 show_plain ($_REQUEST['url']);
70 //we are not stupid...
71 header ("Content-type: text/html");
72 echo "<html><head></head><body>Not an image</body></html>";
77 $width = @imagesx($img);
78 $height = @imagesy($img);
80 $newwidth = $_REQUEST['width'];
81 if (empty($newidth)) $newidth = 50;
83 $newheight = $_REQUEST['height'];
84 if (empty($newheight)) $newheight = round($newwidth * ($height / $width)) ;
86 $thumb = imagecreate($newwidth, $newheight);
87 $img = imagecopyresampled($thumb, $img, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
90 header ("Content-type: image/png");
93 function show_plain () {
94 $mime = mime_content_type ($_REQUEST['url']);
95 header ("Content-type: $mime");
96 readfile($_REQUEST['url']);