* of them along with clickable links to see the full thing
*/
-#$show_dir = "/export/data/Pictures/showdir";
+// set these variables
+$n_per_line = 6; // number of pics in each line of the table
+$thumb_size = 300; // size of thumbnails
+$med_size = 1024; // size of "medium" image
+
+
$show_dir = "/net/iron/export/quickshow/";
-$n_per_line = 6;
-$this_url = "http://".$_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
+$this_url = "http://".$_SERVER["SERVER_NAME"].$_SERVER["PHP_SELF"];
+
if(isset($_REQUEST["showpic"])) {
} else {
header("Status: 404 Not Found");
}
+} else if(isset($_REQUEST["medpic"])) {
+ $file = $_REQUEST["medpic"];
+ if(preg_match("/.*\/+.*/", $_REQUEST["medpic"])) {
+ error_log("throwing 403");
+ header("Status: 403 i dont think so");
+ return;
+ }
+ $afile = "$show_dir/".$_REQUEST["medpic"];
+ if(file_exists($afile)) {
+ echo "<html><body><h1>Picture $file</h1><a href=\"$this_url?showpic=$file\"><img src=\"$this_url?showmedpic=$file\"></body></html>";
+ } else {
+ header("Status: 403 i dont think so");
+ return;
+ }
+} else if(isset($_REQUEST["showmedpic"])) {
+ if(preg_match("/.*\/+.*/", $_REQUEST["showmedpic"])) {
+ error_log("throwing 403");
+ header("Status: 403 i dont think so");
+ return;
+ }
+ $afile = "$show_dir/".$_REQUEST["showmedpic"];
+ if(file_exists($afile)) {
+ header('Content-Type: image/jpeg');
+ $src = imagecreatefromjpeg($afile);
+ list($width, $height) = getimagesize($afile);
+
+ if($width <= $med_size && $height <= $med_size) {
+ // just pump out the pic
+ error_log("pic pump");
+ header('Content-Type: image/jpeg');
+ echo file_get_contents($afile);
+ return;
+ }
+
+ // else, resize it
+ if($width > $height) {
+ $nw = $med_size;
+ $nh = (int)($height/($width/$med_size));
+ } else {
+ $nh = $med_size;
+ $nw = (int)($width/($height/$med_size));
+
+ }
+
+ /*
+ * 2000
+ * 1800
+ * $nw = 200
+ * $mul = $height/$width/200
+ */
+
+ // error_log("neww = $nw, $nh");
+ $thumb = imagecreatetruecolor($nw, $nh);
+
+ imagecopyresized($thumb, $src, 0, 0, 0, 0, $nw, $nh, $width, $height);
+ imagejpeg($thumb);
+ } else {
+ header("Status: 404 Not Found");
+ }
} else if(isset($_REQUEST["showtmp"])) {
// nothing yet
if(preg_match("/.*\/+.*/", $_REQUEST["showtmp"])) {
list($width, $height) = getimagesize($afile);
if($width > $height) {
- $nw = 200;
- $nh = (int)($height/($width/200));
+ $nw = $thumb_size;
+ $nh = (int)($height/($width/$thumb_size));
} else {
- $nh = 200;
- $nw = (int)($width/($height/200));
+ $nh = $thumb_size;
+ $nw = (int)($width/($height/$thumb_size));
}
* $mul = $height/$width/200
*/
- error_log("neww = $nw, $nh");
+ // error_log("neww = $nw, $nh");
$thumb = imagecreatetruecolor($nw, $nh);
imagecopyresized($thumb, $src, 0, 0, 0, 0, $nw, $nh, $width, $height);
// echo "<pre>";
// print_r($_SERVER);
- //echo "</pre>";
+ // echo "</pre>";
$i = 0;
$dh = opendir($show_dir);
echo "<tr>";
}
- echo "<td><a href=\"$this_url?showpic=$file\"><img src=\"$this_url?showtmp=$file\"></a></td>";
+ echo "<td><a href=\"$this_url?medpic=$file\"><img src=\"$this_url?showtmp=$file\"></a></td>";
if($i == ($n_per_line-1)) {
echo "</tr>";