Skip to main content
Participating Frequently
December 7, 2012
Question

Geotag Data imprinted to the image

  • December 7, 2012
  • 1 reply
  • 2470 views

Does anyone know of a script or action created that can take the geotag data from the exif and write it to the image like a date script in the lower corner.??

This topic has been closed for replies.

1 reply

Paul Riggott
Inspiring
December 8, 2012

Something like this ...

if(documents.length) app.activeDocument.suspendHistory('Add Border', 'main()');

function main(){

var startRulerUnits = preferences.rulerUnits;

app.preferences.rulerUnits = Units.PIXELS;

var doc = activeDocument;

var longitude = getExifString('GPS Longitude');

var latitude = getExifString('GPS Latitude');

var fivePercent = (Math.min(doc.height,doc.width)/100) * 5;

var OffsetX = fivePercent;

var OffsetY = fivePercent/4;

var Black = new SolidColor();

Black.rgb.hexValue = '000000';

var White = new SolidColor();

White.rgb.hexValue = 'ffffff';

app.backgroundColor=Black;

doc.flatten();

doc.resizeCanvas((doc.width + (fivePercent*2)), (doc.height + (fivePercent*2)), AnchorPosition.MIDDLECENTER);

var newTextLayer = activeDocument.artLayers.add();

newTextLayer.kind = LayerKind.TEXT;

newTextLayer.textItem.kind = TextType.POINTTEXT

newTextLayer.textItem.color = White;

newTextLayer.textItem.font = "Georgia";

newTextLayer.textItem.size = 14;

newTextLayer.textItem.contents = "Longitude: " + longitude + " Latitude: " + latitude;

var LB = doc.activeLayer.bounds;

var LHeight = Math.abs(LB[3].value) - Math.abs(LB[1].value);

var percentage = ((fivePercent/LHeight)*50);

doc.activeLayer.resize(percentage,percentage,AnchorPosition.MIDDLECENTER);

LB = doc.activeLayer.bounds;

var X = (activeDocument.width - fivePercent) - LB[2].value;

var Y = (activeDocument.height - OffsetY) - LB[3];

doc.activeLayer.translate(X,Y);

doc.flatten();

preferences.rulerUnits = startRulerUnits;

}

function getExifString(searchString) {

    var exifArray = activeDocument.info.exif;

    for(var a in exifArray){

        if(exifArray[0].toString() ==  searchString){

            return exifArray[1];

            }

        }

    return  searchString + 'Not known';

};

Participating Frequently
December 10, 2012

Oh one thing, I just noticed its not printing the W (long) or the N (lat) after the coordinates. I could drop them in text form in there, but if Id reather it place it there right from the exif. Could you show me how to do that? I really appreciate the help, thanks again!

Paul Riggott
Inspiring
December 10, 2012

I wonder if this is better...

#target photoshop

if(documents.length) app.activeDocument.suspendHistory('Add GPS', 'main()');

function main(){

var longitude = getExifString('GPS Longitude');

var longRef = getExifString('GPS Longitude Ref');

var latitude = getExifString('GPS Latitude');

var latRef = getExifString('GPS Latitude Ref');

var TextInfo = longRef + longitude + " "  + latRef +  latitude;

//Amend to suit

var Percent = 50; /* text will be percentage of the width. */

var Black = new SolidColor();

Black.rgb.hexValue = '000000';

var newTextLayer = activeDocument.artLayers.add();

newTextLayer.kind = LayerKind.TEXT;

newTextLayer.textItem.kind = TextType.POINTTEXT;

newTextLayer.textItem.color = Black;

newTextLayer.textItem.font = "Georgia";

newTextLayer.textItem.size = 10;

newTextLayer.textItem.contents = TextInfo;

var startRulerUnits = app.preferences.rulerUnits;

app.preferences.rulerUnits = Units.PIXELS;

var myDoc = activeDocument;

var LB = myDoc.activeLayer.bounds;

var docHeight = myDoc.height;

var docWidth = myDoc.width;

var LHeight = Math.abs(LB[3].value) - Math.abs(LB[1].value);

var LWidth = Math.abs(LB[2].value) - Math.abs(LB[0].value);   

var percentageWidth = ((docWidth/LWidth)*Percent);

myDoc.activeLayer.resize(percentageWidth,percentageWidth,AnchorPosition.MIDDLECENTER);

LB = myDoc.activeLayer.bounds;

var X = (myDoc.width-5) - LB[2].value;

var Y = (myDoc.height-5) - LB[3].value;

activeDocument.activeLayer.translate(X,Y);

app.preferences.rulerUnits = startRulerUnits;

};

function getExifString(searchString) {

    var exifArray = activeDocument.info.exif;

    for(var a in exifArray){

        if(exifArray[0].toString() ==  searchString){

            return exifArray[1];

            }

        }

    return  searchString + 'Not known';

};