"Feature", "id" => $filename]; foreach ($exif as $key => $section) { foreach ($section as $name => $val) { switch("$key.$name") { case "FILE.FileSize": $filesize_bytes = $val; break; case "COMPUTED.Height": $height = $val; break; case "COMPUTED.Width": $width = $val; break; case "GPS.GPSLongitude": $lon = parseDeg($val); break; case "GPS.GPSLatitude": $lat = parseDeg($val); break; case "IFD0.Orientation": $orientation = $val; break; case "EXIF.MakerNote": case "EXIF.ComponentsConfiguration": case "GPS.GPSVersion": case "GPS.GPSAltitudeRef": break; default: // echo "$key.$name=$val\n"; } } } if (isset($lon) && isset($lat)) { $json["geometry"] = [ "type" => "Point", "coordinates" => [$lon, $lat] ]; } $properties = [ ]; if (isset($filesize_bytes)) { $properties["filesize_bytes"] = $filesize_bytes; } if (isset($height)) { $properties["height_px"] = $height; } if (isset($width)) { $properties["width_px"] = $width; } if (isset($orientation)) { switch ($orientation) { case 1: $properties["orientation"] = 0; case 3: $properties["orientation"] = -180; case 6: $properties["orientation"] = 90; case 8: $properties["orientation"] = -90; } } $json["properties"] = $properties; $s = json_encode($json); file_put_contents($cacheFile, $s); return $json; } if (!isset($_GET["file"])) { $d = dir("."); $features = []; while (false !== ($entry = $d->read())) { if(!isValidFilename($entry)) { continue; } array_push($features, processFile($entry)); } $json = ["type" => "FeatureCollection", "features" => $features]; } else { $filename = $_GET["file"]; $json = processFile($filename); } header('Content-Type: application/vnd.geo+json'); echo json_encode($json, JSON_PRETTY_PRINT); echo "\n"; } catch(InvalidArgumentException $e) { header('HTTP/1.1 400 bad request'); } ?>