$d

"; } } else { $files = array(); foreach (scandir($dir) as $f) if (strncmp($f, "thumb_", 6) != 0 && $f[0] != '.' && strcasecmp(substr($f, strlen($f) - 4), ".jpg") == 0) $files[] = $f; } function thumbnails() { global $files, $image_width, $dir, $thumb_pfx; echo "\n\n

"; for ($i = 0; $i < count($files); $i++) { if ($i % 6 == 0) { if ($i > 0) echo ""; echo ""; } echo "\n"; } echo "
" . "
" . "
"; echo "

Click image to locate it on map, or click map marker to see image. Click ⊕ symbol for enlarged image.

"; } function sexagesimal_to_float($x) { eval('$f = ' . $x[0] . "+" . $x[1] . " / 60 + " . $x[2] . " / 3600;"); return $f; } function map() { echo "

"; } function photomap_start($title = "Google Photo Map", $tsize = 120, $gpxfile = NULL) { global $files, $dir, $thumbsize, $thumb_pfx; $thumbsize = $tsize; $thumb_pfx = build_thumbs($files, $dir) ? "thumb_" : ""; if ($thumb_pfx == "") $image_width = " width=$thumbsize "; else $image_width = ""; mapit($files, $dir, $title, $gpxfile); echo "

"; } function photomap_end() { echo << EOT; } function mapit($files, $dir, $title, $gpxfile) { global $api_key, $thumb_pfx, $image_width; echo << $title EOT; } function build_thumbs($files, $dir) { global $thumbsize, $rebuild; if ((fileperms($dir) & 0222) != 0222) return false; foreach($files as $file) { $dest = "$dir/thumb_$file"; if ($rebuild || !file_exists($dest)) create_thumbnail("$dir/$file", $dest, $thumbsize); } return true; } // Code from http://us2.php.net/manual/en/function.imagejpeg.php#68194; modified by MJR function create_thumbnail( $source_file, $destination_file, $max_dimension) { list($img_width,$img_height) = getimagesize($source_file); // Get the original dimensions $aspect_ratio = $img_width / $img_height; if ( ($img_width > $max_dimension) || ($img_height > $max_dimension) ) // If either dimension is too big... { if ( $img_width > $img_height ) // For wide images... { $new_width = $max_dimension; $new_height = $new_width / $aspect_ratio; } elseif ( $img_width < $img_height ) // For tall images... { $new_height = $max_dimension; $new_width = $new_height * $aspect_ratio; } elseif ( $img_width == $img_height ) // For square images... { $new_width = $max_dimension; $new_height = $max_dimension; } else { echo "Error reading image size."; return FALSE; } } else { $new_width = $img_width; $new_height = $img_height; } // If it's already smaller, don't change the size. // Make sure these are integers. $new_width = intval($new_width); $new_height = intval($new_height); $thumbnail = imagecreatetruecolor($new_width,$new_height); // Creates a new image in memory. // MJR: Original dealt with various types; this one deals only with JPEGs $img_source = imagecreatefromjpeg($source_file); // Here we resample and create the new jpeg. imagecopyresampled($thumbnail, $img_source, 0, 0, 0, 0, $new_width, $new_height, $img_width, $img_height); imagejpeg( $thumbnail, $destination_file, 100 ); // Finally, we destroy the two images in memory. imagedestroy($img_source); imagedestroy($thumbnail); } ?>