Python tool using Google's Gemini API to uncover the location where photos were taken through AI-powered geo-location analysis.
Python tool using Google’s Gemini API to uncover the location where photos were taken through AI-powered geo-location analysis.
pip install geospyer
geospyer --image path/to/your/image.jpg
Argument | Description |
---|---|
--image |
Required. Path to the image file or URL to analyze |
--context |
Additional context information about the image |
--guess |
Your guess of where the image might have been taken |
--output |
Output file path to save the results (JSON format) |
--api-key |
Custom Gemini API key |
Basic usage:
geospyer --image vacation_photo.jpg
With additional context:
geospyer --image vacation_photo.jpg --context "Taken during summer vacation in 2023"
With location guess:
geospyer --image vacation_photo.jpg --guess "Mediterranean coast"
Saving results to a file:
geospyer --image vacation_photo.jpg --output results.json
Using a custom API key:
geospyer --image vacation_photo.jpg --api-key "your-api-key-here"
GeoSpy uses Google’s Gemini API. You can:
GEMINI_API_KEY=your_key_here
GeoSpy(api_key="your_key_here")
--api-key
parameter in the command lineGet your Gemini API key from Google AI Studio.
from geospyer import GeoSpy
# Initialize GeoSpy
geospy = GeoSpy()
# Analyze an image and get JSON result
result = geospy.locate(image_path="image.jpg")
# Work with the JSON data
if "error" in result:
print(f"Error: {result['error']}")
else:
# Access the first location
if "locations" in result and result["locations"]:
location = result["locations"][0]
print(f"Location: {location['city']}, {location['country']}")
# Get Google Maps URL
if "coordinates" in location:
lat = location["coordinates"]["latitude"]
lng = location["coordinates"]["longitude"]
maps_url = f"https://www.google.com/maps?q={lat},{lng}"
See the examples directory for more detailed usage examples.
The API returns a structured JSON response with:
interpretation
: Comprehensive analysis of the imagelocations
: Array of possible locations with:
GeoSpy is intended for educational and research purposes only. While it uses AI models to estimate the location of where an image was taken, its predictions are not guaranteed to be accurate. Do not use this tool for surveillance, stalking, law enforcement, or any activity that may infringe on personal privacy, violate laws, or cause harm.
The author(s) and contributors are not responsible for any damages, legal issues, or consequences resulting from the use or misuse of this software. Use at your own risk and discretion.
Always comply with local, national, and international laws and regulations when using AI-based tools.
This project is licensed under the MIT License - see the LICENSE file for details.