User:Suyash.dwivedi/userscripts/AutoAddLocationEXIF

Wiki's Lazy Coders

Wikidata Location Button

AutoAddLocationEXIF is a powerful user script that extracts GPS coordinates directly from a file's metadata (EXIF data) and inserts the corresponding

Camera location 00′ 00″ N, 0° 00′ 00″ E Kartographer map based on OpenStreetMap.View all coordinates using: OpenStreetMapinfo

template. This tool is specifically helpful for images that contain embedded location data that hasn't yet been added to the wikitext.

Installation

To install this script, add the following line to your common.js page:

 // Auto-Add Location Tag from EXIF Data mw.loader.load('https://commons.wikimedia.org/wiki/User:Suyash.dwivedi/userscripts/AutoAddLocationEXIF.js?action=raw&ctype=text/javascript');

How to use

  • Navigate to a File: page (JPG, JPEG, TIFF, HEIF, or WebP).
  • The script automatically scans the file's EXIF metadata upon loading.
  • If valid GPS coordinates are found and no location template currently exists on the page, a blue button labeled Add location tag from EXIF data will appear at the top of the content area.

Click the button to:

.

Smartly insert the

Camera location 00′ 00″ N, 0° 00′ 00″ E Kartographer map based on OpenStreetMap.View all coordinates using: OpenStreetMapinfo
  • template immediately after the
Description
Source
Author

block (or at the bottom if the template isn't found).

  • The page will reload automatically once the edit is saved.

Features

  • Metadata Extraction: Utilizes the exif-js library to read raw GPS tags from the image file.
  • Smart Placement: Uses a bracket-matching algorithm to find the end of the
Description
Source
Author

template for clean wikitext placement.

  • Format Support: Works with standard photographic formats including JPG, TIFF, and modern formats like HEIF and WebP.
  • Conflict Prevention: The button only appears if the page does not already contain a location, camera location, or location dec template.
  • Zero-Coordinate Filter: Automatically ignores invalid "0,0" coordinates often found in corrupted metadata.
Created by Suyash Dwivedi | Updated on: 8 January 2026
Category:User scripts#AutoAddLocationEXIF Category:Wikimedia Commons tools#AutoAddLocationEXIF
Category:Pages with coordinates Category:User scripts Category:Wikimedia Commons tools