/************************************************************************************************ * * PhotoGrok Script * * Add menu commands to copy gps coordinates to the clipboard and paste gps data into an image. * Assumes GPSLongituedRef=W and GPSLatitudeRef=N. Modify if needed. * * When pasting gps into image, use the following format: 39.700722 -105.706623. * * WARNING: Pasting gps coordinates alters the exif data. Please make sure you have backups of * your images before using PhotoGrok/ExifTool to modify/add tags (see ExifTool page). ************************************************************************************************/ addMenuCommand("Add GPS", function(nodes){ var gps = request("Enter GPS"); if(gps == null || gps.isEmpty()){ return; } var idx = gps.indexOf(' '); var lat = gps.substring(0, idx); var lon = gps.substring(idx + 1); for(var i = 0; i < nodes.length; i++){ var node = nodes[i]; setStatusText("Adding GPS: " + node.name, true); var cmd = ['-overwrite_original', '-GPSLongitudeRef=W', '-GPSLongitude=' + lon, '-GPSLatitudeRef=N', '-GPSLatitude=' + lat, node.dir + java.io.File.separator + node.name]; var res = execExifTool(cmd); refreshFile(node.dir, node.name); } setStatusText(null, false); }); addMenuCommand("Copy GPS", function(nodes){ var cmd = ['-s', '-n', '-GPSLatitude', '-GPSLongitude', nodes[0].dir + java.io.File.separator + nodes[0].name]; var res = execExifTool(cmd); if(res.length != 2){ showMessage("No GPS"); return; } var copiedLat = parseValue(res[0]); var copiedLon = parseValue(res[1]); var ss = new java.awt.datatransfer.StringSelection(copiedLat + ' ' + copiedLon); var cb = java.awt.Toolkit.getDefaultToolkit().getSystemClipboard(); cb.setContents(ss, null); showMessage('Copied: ' + copiedLat + " " + copiedLon); }); function parseValue(s){ var idx = s.indexOf(':') + 2; return s.substring(idx); }