Please bookmark this page to avoid losing your image tool!

Image City Finder

(Free & Supports Bulk Upload)

Drag & drop your images here or

The result will appear here...
You can edit the below JavaScript code to customize the image tool.
function processImage(originalImg, language = "en") {
    // Create the main container
    const container = document.createElement('div');
    container.style.fontFamily = 'system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif';
    container.style.padding = '24px';
    container.style.backgroundColor = '#ffffff';
    container.style.border = '1px solid #ebebeb';
    container.style.borderRadius = '16px';
    container.style.boxShadow = '0 8px 16px rgba(0,0,0,0.08)';
    container.style.maxWidth = '600px';
    container.style.boxSizing = 'border-box';
    container.style.margin = '0 auto';
    container.style.color = '#333';
    container.style.textAlign = 'center';

    // Add Title
    const title = document.createElement('h2');
    title.textContent = 'Image City Finder';
    title.style.margin = '0 0 20px 0';
    title.style.color = '#222';
    container.appendChild(title);

    // Add Image Preview
    const imgPreview = document.createElement('img');
    imgPreview.src = originalImg.src;
    imgPreview.style.maxHeight = '200px';
    imgPreview.style.maxWidth = '100%';
    imgPreview.style.borderRadius = '8px';
    imgPreview.style.objectFit = 'contain';
    imgPreview.style.marginBottom = '20px';
    container.appendChild(imgPreview);

    // Add Status Display Section
    const statusContainer = document.createElement('div');
    statusContainer.style.padding = '16px';
    statusContainer.style.backgroundColor = '#f8f9fa';
    statusContainer.style.borderRadius = '8px';
    statusContainer.style.fontSize = '15px';
    statusContainer.style.lineHeight = '1.6';
    container.appendChild(statusContainer);

    // Add Loading Spinner
    const spinner = document.createElement('div');
    spinner.style.display = 'inline-block';
    spinner.innerHTML = `<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="#666" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
        <path d="M21 12a9 9 0 1 1-6.219-8.56"></path>
    </svg>`;
    
    // Animate spinner using Web Animations API
    spinner.animate([
        { transform: 'rotate(0deg)' },
        { transform: 'rotate(360deg)' }
    ], {
        duration: 1000,
        iterations: Infinity
    });
    statusContainer.appendChild(spinner);
    
    // Status text
    const msg = document.createElement('p');
    msg.textContent = 'Extracting GPS EXIF data from image...';
    msg.style.margin = '10px 0 0 0';
    statusContainer.appendChild(msg);

    // Asynchronous Execution Block
    (async () => {
        try {
            // Dynamically load exifr from CDN for parsing EXIF metadata
            await new Promise((resolve, reject) => {
                if (window.exifr) return resolve();
                const script = document.createElement('script');
                script.src = 'https://cdn.jsdelivr.net/npm/exifr@7.1.3/dist/full.umd.js';
                script.onload = resolve;
                script.onerror = reject;
                document.head.appendChild(script);
            });

            // Extract GPS coordinates
            const gps = await window.exifr.gps(originalImg.src);
            
            if (!gps) {
                spinner.style.display = 'none';
                msg.innerHTML = '<span style="color:#d32f2f;font-weight:bold;">No Location Data Found</span><br>This image does not contain EXIF GPS information or it was stripped before uploading.';
                return;
            }

            msg.textContent = `Coordinates detected: ${gps.latitude.toFixed(5)}, ${gps.longitude.toFixed(5)}. Determining city infrastructure...`;

            // Reverse Geocoding with OpenStreetMap Nominatim
            const response = await fetch(`https://nominatim.openstreetmap.org/reverse?format=json&lat=${gps.latitude}&lon=${gps.longitude}&accept-language=${language}`);
            
            if (!response.ok) throw new Error('Network error from geocoding service.');
            
            const data = await response.json();
            spinner.style.display = 'none';

            if (data && data.address) {
                // Parse priority address entities
                const city = data.address.city || data.address.town || data.address.village || data.address.county || data.address.state || 'Unknown Regional Area';
                const country = data.address.country || '';
                
                // Show result
                msg.innerHTML = `
                    <div style="font-size:18px;font-weight:bold;color:#1976d2;margin-bottom:8px;">${city}${country ? ', ' + country : ''}</div>
                    <div style="font-size:14px;color:#555;margin-bottom:12px;">${data.display_name}</div>
                    <div style="font-size:12px;color:#888;">Latitude: ${gps.latitude.toFixed(6)} | Longitude: ${gps.longitude.toFixed(6)}</div>
                `;
                
                // Embed OSM live map
                const iframe = document.createElement('iframe');
                iframe.width = '100%';
                iframe.height = '300';
                iframe.style.border = '1px solid #ddd';
                iframe.style.marginTop = '20px';
                iframe.style.borderRadius = '8px';
                iframe.style.boxSizing = 'border-box';
                
                const lat = gps.latitude;
                const lon = gps.longitude;
                const latSpan = 0.05;
                const lonSpan = 0.05;
                
                iframe.src = `https://www.openstreetmap.org/export/embed.html?bbox=${lon-lonSpan}%2C${lat-latSpan}%2C${lon+lonSpan}%2C${lat+latSpan}&layer=mapnik&marker=${lat}%2C${lon}`;
                
                statusContainer.appendChild(iframe);
            } else {
                msg.innerHTML = '<span style="color:#f57c00;font-weight:bold;">City Unresolved</span><br>GPS coordinates were found, but a city or residential address could not be pinpointed.';
            }
        } catch (err) {
            spinner.style.display = 'none';
            msg.innerHTML = `<span style="color:#d32f2f;font-weight:bold;">Process Error</span><br>${err.message}`;
        }
    })();

    return container;
}

Free Image Tool Creator

Can't find the image tool you're looking for?
Create one based on your own needs now!

Description

The Image City Finder is a tool that identifies the geographical location associated with an image by extracting its embedded GPS EXIF metadata. Once the coordinates are retrieved, the tool uses reverse geocoding to determine the city, region, and country, providing a detailed address and an interactive map view of the location. This tool is useful for photographers wanting to catalog where their shots were taken, travelers looking to identify landmarks from photos, or anyone interested in discovering the specific origin of an image file containing location data.

Leave a Reply

Your email address will not be published. Required fields are marked *