Hello,
a while ago a nice user (tbone) created a custom script for me that uses exiftool.exe to enable various JPG metadata info to be shown in the tooltips. I use it to show linear/progressive JPG info in the tooltip.
However, in one of the latest updates, something got broken and now I only get the same error message every time:
26.04.2022 20:13 Column.File: ExtendedEXIF: Fehler in Zeile 261, Position 3
26.04.2022 20:13 Column.File: ExtendedEXIF: Fehler 0x80070002
Can somebody please help me to fix this issue? I have no idea of programming.
You can find the script itself here:
///////////////////////////////////////////////////////////////////////////////
//v0.1 - o8/2o14
//- initial
//v0.5
//- resolves exiftool path
//- exiftoolpath in quotes
//- black/white list of extensions
//- prepared to support updates
//v0.5.1 - 12/2o14
//- new exiftool column "ICC Profile"
//todos
// - fails to create tmp file for libary paths
///////////////////////////////////////////////////////////////////////////////
// add/edit columns here
///////////////////////////////////////////////////////////////////////////////
var COLUMNS = [
// col-name groupname tagname col-label justify default callback
new Column("LensID", "", "", "Lens ID", "left", "-", GetLens),
new Column("CropFactor", "Composite", "ScaleFactor35efl", "Crop Factor", "right", "", null),
new Column("HFDistance", "Composite", "HyperfocalDistance", "HF Distance", "right", "", null),
new Column("FocusMode", "Panasonic", "FocusMode", "Focus Mode", "left", "", null),
new Column("Shutter", "Panasonic", "ShutterType", "Shutter", "left", "", null),
new Column("Faces", "XMP-mwg-rs", "RegionName", "Faces", "left", "", null), //picasa face region names
new Column("ICCProfile", "", "", "ICC Profile", "left", "", GetICCProfile),
new Column("Ratio", "", "", "Ratio", "right", "", GetRatio, "native"),
new Column("Orientation", "", "", "Orientation", "right", "", GetOrientation, "native"),
new Column("EncodingProcess", "File", "EncodingProcess", "EncodingProcess", "right", "", null)
];
//convert image.jpg -profile sRGB.icc rgb_image.jpg
///////////////////////////////////////////////////////////////////////////////
// callbacks to calculate own values
///////////////////////////////////////////////////////////////////////////////
// GetLens(): fix missing lens-id, by looking for camera model (with fixed lens)
// this is a exiftool type column, providing all known exiftool tags
function GetLens(tags, column, data){
//if column.value is not empty and not equal to default, exif tag was found
if (column.value!="" && column.value!=column.defaultValue){
//keep original exif value by simply returning it
return column.value.
replace("LUMIX","Lumix").
replace("VARIO","Vario").
replace("OLYMPUS M.","Olympus ");
}
//column value is empty or default, try to return custom lens-id based on
//additional exif informatiom
try{
if (tags["ExifIFD"]["FNumber"]=="0") return "Prime lens (manual)";
if (tags["IFD0"]["Model"]=="FC-S3"){
//we inject a crop factor information for this camera here as well,
//to avoid another callback for the cropfactor column
tags["Composite"]["ScaleFactor35efl"]="4.9";
return "Kyocera S3, 38-76mm, F2.8-3.5";
}
if (tags["IFD0"]["Model"]=="DMC-FX01") return "FX-01 28-102mm F2.8-5.6";
if (tags["IFD0"]["Model"]=="DMC-FZ28") return "FZ-28 27-486mm F2.8-4.4";
if (tags["IFD0"]["Model"]=="DMC-FX77") return "FX-77 24-120mm F2.5-5.9";
if (tags["IFD0"]["Model"]=="DMC-FZ150") return "FZ-150 25-600mm F2.8-5.2";
if (tags["IFD0"]["Model"]=="DMC-FZ200") return "FZ-200 25-600mm F2.8";
} catch(e){}
//still here, return the columns default value
return column.defaultValue;
}
///////////////////////////////////////////////////////////////////////////////
// GetICCProfile(): Determine ICC color profile type
function GetICCProfile(tags, column, data){
try{
var profDesc = tags["ICC_Profile"]["ProfileDescription"];
if (profDesc){
if (profDesc.indexOf("sRGB") != -1) return "sRGB";
if (profDesc.indexOf("Adobe RGB") != -1) return "Adobe RGB";
return profDesc;
}
} catch(e){}
return "";
}
///////////////////////////////////////////////////////////////////////////////
// GetRatio(): get image ratio with DOs native image metadata support
// this is a native type column, providing metadata fetched by DO
function GetRatio(metadata, column, data){
return GetImageRatio(metadata.picwidth,metadata.picheight);
}
///////////////////////////////////////////////////////////////////////////////
// GetOrientation(): get image orientation
function GetOrientation(metadata, column, data){
if (metadata.picwidth>metadata.picheight)
return "Landscape";
return "Portrait";
}
///////////////////////////////////////////////////////////////////////////////
// following code is not meant to be edited, but feel free to do so. o)
///////////////////////////////////////////////////////////////////////////////
var shell = new ActiveXObject("WScript.Shell");
var fso = new ActiveXObject("Scripting.FileSystemObject");
String.prototype.lTrim = doLTrim; function doLTrim(){return this.replace(/^\s*/,'');}
String.prototype.rTrim = doRTrim; function doRTrim(){return this.replace(/\s*$/,'');}
String.prototype.trim = doTrim; function doTrim(){return this.lTrim().rTrim();}
///////////////////////////////////////////////////////////////////////////////
function OnInit(data) {
//onOnit
//uid added via script wizard, do not change after publishing this script
var uid = "0EC23487-9ECF-4C42-96D6-793C0B83454F";
//resource center url added via script wizard (required for updating)
var url = "http://resource.dopus.com/viewtopic.php?f=35&t=22729";
data.name = "Column.File: ExtendedEXIF";
data.desc = "Columns for extended/custom exif information.";
data.copyright = "tbone";
data.min_version = "11.5.1"
data.version = "0.5.1";
data.default_enable = true;
for (var c=0;c<COLUMNS.length;c++) {
var column = COLUMNS[c];
var cmd = data.AddColumn();
cmd.multicol = true;
cmd.name = column.name;
cmd.header = column.label;
cmd.label = "EE."+column.label;
cmd.method = "Column_ExtendedEXIF";
cmd.justify = column.justify;
}
data.config["ExifToolExePath"] = "E:\\Internet\\download\\exiftool-12.12\\exiftool.exe";
data.config["TmpFiles.Keep"] = true;
data.config["TmpFiles.Path"] = "%tmp%\\DO.ExtendedEXIF";
data.config["ConsoleOutput"] = false;
data.config["BlackList.Enabled"] = false;
var blacklist = DOpus.NewVector();
data.config["BlackList.Extensions"] = blacklist;
blacklist.push_back('txt');
blacklist.push_back('ini');
blacklist.push_back('cert');
data.config["WhiteList.Enabled"] = true;
var blacklist = DOpus.NewVector();
data.config["WhiteList.Extensions"] = blacklist;
blacklist.push_back('jpg');
blacklist.push_back('jpeg');
blacklist.push_back('nef');
blacklist.push_back('rw2');
}
///////////////////////////////////////////////////////////////////////////////
function Column_ExtendedEXIF(data) {
Log("GetEXIFTags: "+ data.item.path+"\\"+data.item.name);
if (data.item.is_dir){
for (var c=0;c<COLUMNS.length;c++) data.columns(COLUMNS[c].name).value = "";
return true;
}
if (IsBlackListed( new String(data.item.ext).substring(1).toLowerCase() )) {
Log(" Item type failed black/white list check");
return true;
}
//native column?
var nativeColumn = false;
for (var c=0;c<COLUMNS.length;c++) {
var column = COLUMNS[c];
if (column.name==data.col && column.type=="native"){
var nativeColumn = true;
break;
}
}
var tags = null;
try{
if (!nativeColumn){
tags = GetEXIFTagsFromFile( DOpus.FSUtil.Resolve(Script.config.ExifToolExePath)+"",
""+data.item.path,
""+data.item.name,
Script.config["TmpFiles.Keep"],
Script.config["TmpFiles.Path"]);
if (!tags) throw new Error("Something bad happened.");
}
} catch(e){
Log(" GetEXIFTagsFromFile() failed: "+e.message);
throw e;
}
//exiftool type columns
if (!nativeColumn){
for (var c=0;c<COLUMNS.length;c++) {
var column = COLUMNS[c];
if (column.type=="native")
continue;
var tagValue = "";
if (tags[column.group]!=undefined && tags[column.group][column.tag]!=undefined)
tagValue = ""+tags[column.group][column.tag];
else
tagValue = column.defaultValue;
if (column.funcCustom){
column.value = tagValue;
data.columns(column.name).value = column.funcCustom(tags, column, data);
continue;
}
data.columns(column.name).value = tagValue;
}
}
//native type columns
if (nativeColumn){
var itemType = data.item.metadata;
if (itemType!="image" && itemType!="video")
return true;
for (var c=0;c<COLUMNS.length;c++) {
var column = COLUMNS[c];
if (column.type=="exiftool")
continue;
if (column.funcCustom){
data.columns(column.name).value = column.funcCustom(data.item.metadata[itemType], column, data);
continue;
}
data.columns(column.name).value = "";
}
}
return true;
}
///////////////////////////////////////////////////////////////////////////////
function GetEXIFTagsFromFile(exiftoolPath, filePath, fileName, keepTmp, pathTmp) {
var tmpFile = CreateTmpFileName();
var hasTmp = false;
if (pathTmp) tmpFile.path = pathTmp.trim("\\").replace("\%tmp\%",tmpFile.path);
else tmpFile.path = tmpFile.path+"\\DO.ExtendedEXIF";
if (keepTmp){
tmpFile.path = tmpFile.path+"\\"+filePath.substring(3);
tmpFile.name = fileName+".txt";
tmpFile.fullname = tmpFile.path +"\\"+tmpFile.name;
if (fso.FileExists(tmpFile.fullname)){
Log(" Using cached data ["+tmpFile.fullname+"].");
hasTmp = true;
}
} else {
tmpFile.name = filePath.replace(/:\\/g,"_").replace(/\\/g,"_")+".txt";
tmpFile.fullname = tmpFile.path +"\\"+tmpFile.name;
}
if (!CreateFolders(tmpFile.path))
throw new Error("Could not create tmp folder ["+tmpFile.path+"].");
if (!keepTmp || !hasTmp){
var runMe = '"'+exiftoolPath+'"' +
" -w+! %0f\""+tmpFile.fullname+"\""+
" -a -s -G -u -g1"+
" \""+filePath+"\\"+fileName+"\"";
var result = shell.Run( runMe, 0, true);
if (result)
throw new Error("Exiftool.exe failed on ["+filePath+"\\"+fileName+"].");
}
var file = fso.GetFile(tmpFile.fullname);
var ts = file.OpenAsTextStream(1 /*ForReading*/, -2 /*TristateUseDefault*/);
var line = "", tags = new Array();
while (!ts.AtEndOfStream) {
line = ts.ReadLine();
if (line.indexOf("----")!=-1){ //new tag group
var groupName = line.substring(5).replace(" ----","").trim();
var group = new Array();
tags[groupName] = group;
continue;
}
var tagName = line.substring(0,32).trim();
var tagValue = line.substring(34).trim();
group[tagName] = tagValue;
}
ts.Close();
if (!keepTmp)
fso.DeleteFile(tmpFile.fullname, true);
return tags;
}
///////////////////////////////////////////////////////////////////////////////
function CreateTmpFileName(prefix, extension) {
var tFolder = fso.GetSpecialFolder(2); // 2 = temp folder
var tFile = fso.GetTempName();
if (prefix!=undefined) tFile=prefix+tFile;
if (extension!=undefined) tFile+=extension;
return {
path : tFolder.Path,
name : tFile,
fullname: tFolder.Path+'\\'+tFile
};
}
///////////////////////////////////////////////////////////////////////////////
function CreateFolders(fullPath){
//version = 0.5;
fullPath = new String(fullPath);
if (fso==undefined)
var fso = new ActiveXObject("Scripting.FileSystemObject");
if (fso.FolderExists(fullPath)) return true;
var drive = fullPath.substring(0,3);
var dirs = fullPath.split("\\");
var path = ""
for(var i=1;i<dirs.length;i++){
var dir = dirs[i];
if (path!="") path += "\\"; else path = drive;
path += dir;
if (!fso.FolderExists(path)){
try{
fso.CreateFolder(path);
}
catch (e){
return false;
}
}
}
return true;
}
///////////////////////////////////////////////////////////////////////////////
function IsBlackListed(item){
var isBlack = IsItemInList(item, Script.config["BlackList.Enabled"],
Script.config["BlackList.Extensions"]);
var isWhite = IsItemInList(item, Script.config["WhiteList.Enabled"],
Script.config["WhiteList.Extensions"]);
Log(" BlackListed: " + isBlack);
Log(" WhiteListed: " + isWhite);
logMsg = "";
if (isBlack===null) logMsg += " (blacklist disabled)";
if (isWhite===null) logMsg += " (whitelist disabled)";
if (!isBlack && (isWhite || isWhite===null)){
Log(" Item is whitelisted"+logMsg);
return false;
}
Log(" Item is (indirectly?) blacklisted"+logMsg);
return true;
}
//////////////////////////////////////////////////////////////////////////////
function IsItemInList(path, listEnabled, vectorScriptConfig){
if (!listEnabled) return null;
return HasMatchInVector(new String(path), vectorScriptConfig);
}
//////////////////////////////////////////////////////////////////////////////
function HasMatchInVector(text, vector){
try{
for (var i=0;i<vector.length;i++){
entry = new String(vector(i));
//Debug("Text:" +text + " RegEx: " + entry);
var matches = text.match(new RegExp(entry));
if (matches) return true;
}
return false;
} catch(e){
Debug("E Error evaluating regex ["+entry+"], index ["+i+"].");
return false
}
}
///////////////////////////////////////////////////////////////////////////////
function Column(name,group,tag,label,justify,defaultValue,funcCustom,type){
this.name = name;
this.group = group;
this.tag = tag;
this.label = label;
this.justify = justify;
this.defaultValue = defaultValue;
this.funcCustom = funcCustom;
this.type = type; if (type==undefined) this.type="exiftool";
}
///////////////////////////////////////////////////////////////////////////////
function Log(txt){
if (Script.config["ConsoleOutput"]) DOpus.Output(txt);
}
///////////////////////////////////////////////////////////////////////////////
function GetEXIFTagsFromFile_unused(exiftoolPath, filePath) {
var exec = shell.Exec(exiftoolPath + " -a -s -G -u -g1 "+filePath);
var line, output = "", tags = new Array();
while (exec.Status == 0) {
while (!exec.StdOut.AtEndOfStream) {
line = exec.StdOut.ReadLine() ;
if (line.indexOf("----")!=-1){ //new tag group
var groupName = line.substring(5).replace(" ----","").trim();
var group = new Array();
tags[groupName] = group;
continue;
}
var tagName = line.substring(0,32).trim();
var tagValue = line.substring(34).trim();
group[tagName] = tagValue;
}
}
if (exec.ExitCode)
throw new Error("Exiftool.exe failed on ["+filePath+"].");
return tags;
}
///////////////////////////////////////////////////////////////////////////////
function GetImageRatio(x,y){
function FindHCF(m, n){
var temp, reminder;
if (m < n){ temp = m; m = n; n = temp; }
while (true){
reminder = m % n;
if (reminder == 0) return n;
else m = n;
n = reminder;
}
}
if (y>x){ var z=x; x=y; y=z; }
var hcf = FindHCF(x, y);
var factorW = x/hcf; var factorH = y/hcf;
switch (factorW){
case 1: case 2: case 3: case 4: case 5:
case 6: case 9: case 10: case 21:
//return
return factorW+":"+factorH;
}
var ratio = x/y;
if (ratio>0.9 && ratio<1.1){ return "1:1";}
if (ratio>1.09 && ratio<1.3){ return "5:4"; }
if (ratio>1.29 && ratio<1.4){ return "4:3"; }
if (ratio>1.4 && ratio<1.60){ return "3:2";}
if (ratio>1.61 && ratio<1.70){ return "5:3";}
if (ratio>1.7 && ratio<1.88){ return "16:9";}
if (ratio>1.87 && ratio<2.25){ return "2:1";}
if (ratio>2.24 && ratio<2.4){ return "21:9";}
//common ratio could not be found
return factorW+":"+factorH;
}
///////////////////////////////////////////////////////////////////////////////
function OnAboutScript(data){ //v0.1
var cmd = DOpus.Create.Command();
if (!cmd.Commandlist('s').exists("ScriptWizard")){
if (DOpus.Dlg.Request("The 'ScriptWizard' add-in has not been found.\n\n"+
"Install 'ScriptWizard' from [resource.dopus.com].\nThe add-in enables this dialog and also offers "+
"easy updating of scripts and many more.","Yes, take me there!|Cancel", "No About.. ", data.window))
cmd.RunCommand('http://resource.dopus.com/viewtopic.php?f=35&t=23179');}
else
cmd.RunCommand('ScriptWizard ABOUT WIN='+data.window+' FILE="'+Script.File+'"');
}
//MD5 = "b7bc06d32e1d7d76b30f4f9ad947c7c6"; DATE = "2014.12.31 - 00:30:29"
If you need more background info, you can find my old entry for creating the script here
https://resource.dopus.com/t/report-jpg-linear-progressive-save-method/37384/2
and the consersation with the script creator tbone in German here:
https://web.archive.org/web/20210512211148/https://www.haage-partner.de/forum/viewtopic.php?t=5452&f=47&sid=c1b34360c496daf87dfcc5cc440bbf6f
(archive link because the German forum was closed)
Many thanks in advance,
Robert