// Shaun's Exif Helpers.inc // Version 1.0 // Shaun Ivory (shaun@ivory.org) // // Feel free to modify this script. If you do anything interesting with it, // please let me know. // EXIF constants c_ExifGpsLatitudeRef = "GPS Latitude Ref" c_ExifGpsLatitude = "GPS Latitude" c_ExifGpsLongitudeRef = "GPS Longitude Ref" c_ExifGpsLongitude = "GPS Longitude" c_ExifGpsAltitudeRef = "GPS Altitude Ref" c_ExifGpsAltitude = "GPS Altitude" c_ExifGpsTimeStamp = "GPS Time Stamp" c_ExifMake = "Make" c_ExifModel = "Model" c_ExifExposureTime = "Exposure Time" c_ExifAperture = "F-Stop" c_ExifExposureProgram = "Exposure Program" c_ExifIsoSpeedRating = "ISO Speed Ratings" c_ExifDateTimeOriginal = "Date Time Original" c_ExifMaxApertureValue = "Max Aperture Value" c_ExifMeteringMode = "Metering Mode" c_ExifLightSource = "Light Source" c_ExifFlash = "Flash" c_ExifFocalLength = "Focal Length" c_ExifColorSpace = "Color Space" c_ExifWidth = "Pixel X Dimension" c_ExifHeight = "Pixel Y Dimension" function GetRawExifValueIfPresent(strExifValueName) { // Empty string means it wasn't found var strResult = new String(""); // Make sure there is a current document if (app.documents.length) { // Loop through each element in the EXIF properties array for (nCurrentElement = 0, nCount = 0; nCurrentElement < activeDocument.info.exif.length; ++nCurrentElement) { // Get the current element as a string var strCurrentRecord = new String(activeDocument.info.exif[nCurrentElement]); // Find the first comma var nComma = strCurrentRecord.indexOf(","); if (nComma >= 0) { // Everything before the comma is the field name var strCurrentExifName = strCurrentRecord.substr(0, nComma); // Is it a valid string? if (strCurrentExifName.length) { // Is this our element? if (strCurrentExifName == strExifValueName) { // Everything after the comma is the value, so // save it and exit the loop strResult = strCurrentRecord.substr(nComma + 1); break; } } } } } return strResult; }