Merge branch 'exiftool1049' into dev

This commit is contained in:
Morgan Hardwood 2017-04-18 21:00:53 +02:00
commit 2c40a4aa50
11 changed files with 2335 additions and 2250 deletions

File diff suppressed because it is too large Load Diff

View File

@ -84,18 +84,22 @@ class FASaturationInterpreter : public ChoiceInterpreter
public: public:
FASaturationInterpreter () FASaturationInterpreter ()
{ {
choices[0] = "Normal"; choices[0] = "Normal";
choices[0x80] = "Medium High"; choices[128] = "Medium High";
choices[0x100] = "High"; choices[256] = "High";
choices[0x180] = "Medium Low"; choices[384] = "Medium Low";
choices[0x200] = "Low"; choices[512] = "Low";
choices[0x300] = "None (B&W)"; choices[768] = "None (B&W)";
choices[0x301] = "B&W Red Filter"; choices[769] = "B&W Red Filter";
choices[0x302] = "B&W Yellow Filter"; choices[770] = "B&W Yellow Filter";
choices[0x303] = "B&W Green Filter"; choices[771] = "B&W Green Filter";
choices[0x310] = "B&W Sepia"; choices[784] = "B&W Sepia";
choices[0x400] = "Low 2"; choices[1024] = "Low 2";
choices[0x8000] = "Film Simulation"; choices[1280] = "Acros";
choices[1281] = "Acros Red Filter";
choices[1282] = "Acros Yellow Filter";
choices[1283] = "Acros Green Filter";
choices[32768] = "Film Simulation";
} }
}; };
FASaturationInterpreter faSaturationInterpreter; FASaturationInterpreter faSaturationInterpreter;

View File

@ -11,7 +11,7 @@ namespace rtexif
{ {
void parseKodakIfdTextualInfo(Tag *textualInfo, Tag* exif_) void parseKodakIfdTextualInfo (Tag *textualInfo, Tag* exif_)
{ {
// parse TextualInfo and copy values into corresponding standard Exif // parse TextualInfo and copy values into corresponding standard Exif
if (textualInfo->getType() != ASCII) { if (textualInfo->getType() != ASCII) {
@ -24,7 +24,7 @@ void parseKodakIfdTextualInfo(Tag *textualInfo, Tag* exif_)
char *p = value; char *p = value;
char *pc, *plf; char *pc, *plf;
while ((pc = strchr(p, ':')) != nullptr && (plf = strchr(pc, '\n')) != nullptr) { while ((pc = strchr (p, ':')) != nullptr && (plf = strchr (pc, '\n')) != nullptr) {
while (*p == ' ') { while (*p == ' ') {
p++; p++;
} }
@ -35,7 +35,7 @@ void parseKodakIfdTextualInfo(Tag *textualInfo, Tag* exif_)
len--; len--;
} }
std::string key = std::string(p, len); std::string key = std::string (p, len);
++pc; ++pc;
while (*pc == ' ') { while (*pc == ' ') {
@ -48,7 +48,7 @@ void parseKodakIfdTextualInfo(Tag *textualInfo, Tag* exif_)
len--; len--;
} }
std::string val = std::string(pc, len); std::string val = std::string (pc, len);
p = ++plf; p = ++plf;
// we pick out a few select tags here // we pick out a few select tags here
@ -56,78 +56,78 @@ void parseKodakIfdTextualInfo(Tag *textualInfo, Tag* exif_)
if (key == "Lens") { if (key == "Lens") {
// Proback645 may have "Lens" but not "Focal Length" // Proback645 may have "Lens" but not "Focal Length"
float flen = atof(val.c_str()); float flen = atof (val.c_str());
if (flen != 0.0) { if (flen != 0.0) {
t = new Tag(exif, lookupAttrib(exifAttribs, "FocalLength")); t = new Tag (exif, lookupAttrib (exifAttribs, "FocalLength"));
t->initRational(flen * 32, 32); t->initRational (flen * 32, 32);
exif->replaceTag(t); exif->replaceTag (t);
} }
} else if (key == "Focal Length") { } else if (key == "Focal Length") {
float flen = atof(val.c_str()); float flen = atof (val.c_str());
if (flen != 0.0) { if (flen != 0.0) {
t = new Tag(exif, lookupAttrib(exifAttribs, "FocalLength")); t = new Tag (exif, lookupAttrib (exifAttribs, "FocalLength"));
t->initRational(flen * 32, 32); t->initRational (flen * 32, 32);
exif->replaceTag(t); exif->replaceTag (t);
} }
} else if (key == "Aperture") { } else if (key == "Aperture") {
float aperture = atof(&val.c_str()[1]); float aperture = atof (&val.c_str()[1]);
if (aperture != 0.0) { if (aperture != 0.0) {
t = new Tag(exif, lookupAttrib(exifAttribs, "FNumber")); t = new Tag (exif, lookupAttrib (exifAttribs, "FNumber"));
t->initRational((int)(aperture * 10), 10); t->initRational ((int) (aperture * 10), 10);
exif->replaceTag(t); exif->replaceTag (t);
} }
} else if (key == "Exposure Bias" || key == "Compensation") { } else if (key == "Exposure Bias" || key == "Compensation") {
float bias = 0.0; float bias = 0.0;
if (val != "Off") { if (val != "Off") {
bias = atof(val.c_str()); bias = atof (val.c_str());
} }
t = new Tag (exif, lookupAttrib(exifAttribs, "ExposureBiasValue")); t = new Tag (exif, lookupAttrib (exifAttribs, "ExposureBiasValue"));
t->initRational ((int)(bias * 1000), 1000); t->initRational ((int) (bias * 1000), 1000);
exif->replaceTag(t); exif->replaceTag (t);
} else if (key == "ISO Speed") { } else if (key == "ISO Speed") {
t = new Tag (exif, lookupAttrib(exifAttribs, "ISOSpeedRatings")); t = new Tag (exif, lookupAttrib (exifAttribs, "ISOSpeedRatings"));
t->initInt(atoi(val.c_str()), SHORT); t->initInt (atoi (val.c_str()), SHORT);
exif->replaceTag(t); exif->replaceTag (t);
} else if (key == "Shutter") { } else if (key == "Shutter") {
const char *p1 = strchr(val.c_str(), '/'); const char *p1 = strchr (val.c_str(), '/');
int a, b; int a, b;
if (p1 == nullptr) { if (p1 == nullptr) {
a = atoi(val.c_str()); a = atoi (val.c_str());
b = 1; b = 1;
} else { } else {
a = atoi(val.c_str()); a = atoi (val.c_str());
b = atoi(&p1[1]); b = atoi (&p1[1]);
} }
t = new Tag (exif, lookupAttrib(exifAttribs, "ExposureTime")); t = new Tag (exif, lookupAttrib (exifAttribs, "ExposureTime"));
t->initRational(a, b); t->initRational (a, b);
exif->replaceTag(t); exif->replaceTag (t);
float ssv = -log2((float)a / (float)b); // convert to APEX value float ssv = -log2 ((float)a / (float)b); // convert to APEX value
t = new Tag (exif, lookupAttrib(exifAttribs, "ShutterSpeedValue")); t = new Tag (exif, lookupAttrib (exifAttribs, "ShutterSpeedValue"));
t->initRational(1000000 * ssv, 1000000); t->initRational (1000000 * ssv, 1000000);
exif->replaceTag(t); exif->replaceTag (t);
} else if (key == "Flash Fired") { } else if (key == "Flash Fired") {
t = new Tag (exif, lookupAttrib(exifAttribs, "Flash")); t = new Tag (exif, lookupAttrib (exifAttribs, "Flash"));
if (val == "No") { if (val == "No") {
t->initInt(0, SHORT); t->initInt (0, SHORT);
} else { } else {
// not sure if "Flash Fired" is only yes/no, only seen "No" in test pictures // not sure if "Flash Fired" is only yes/no, only seen "No" in test pictures
t->initInt(1, SHORT); t->initInt (1, SHORT);
} }
exif->replaceTag(t); exif->replaceTag (t);
} else if (key == "White balance") { // yes should be small 'b' int 'balance'. } else if (key == "White balance") { // yes should be small 'b' int 'balance'.
t = new Tag (exif, lookupAttrib(exifAttribs, "Flash")); t = new Tag (exif, lookupAttrib (exifAttribs, "Flash"));
t->initInt((val == "Auto") ? 0 : 1, SHORT); t->initInt ((val == "Auto") ? 0 : 1, SHORT);
exif->replaceTag(t); exif->replaceTag (t);
} }
} }
} }

View File

@ -38,7 +38,7 @@ public:
virtual std::string toString (Tag* t) virtual std::string toString (Tag* t)
{ {
char buffer[32]; char buffer[32];
sprintf (buffer, "%d", t->toInt(2)); sprintf (buffer, "%d", t->toInt (2));
return buffer; return buffer;
} }
}; };
@ -59,8 +59,8 @@ public:
{ {
int a = t->getValue()[ofs]; int a = t->getValue()[ofs];
if(a > 1) { if (a > 1) {
double i = pow(2., double(a) / 12. - 5.) * 100.; double i = pow (2., double (a) / 12. - 5.) * 100.;
return i; return i;
} else { } else {
return 0.; return 0.;
@ -70,8 +70,8 @@ public:
{ {
int a = t->getValue()[ofs]; int a = t->getValue()[ofs];
if(a > 1) { if (a > 1) {
int i = int(double(powf(2.f, float(a) / 12.f - 5.f)) * 100.f + 0.5f); int i = int (double (powf (2.f, float (a) / 12.f - 5.f)) * 100.f + 0.5f);
return i; return i;
} else { } else {
return 0; return 0;
@ -90,50 +90,50 @@ public:
// unclear if this interpretation is correct! // unclear if this interpretation is correct!
switch (a) { switch (a) {
case 0x0: case 0x0:
return "Off"; return "Off";
case 0x101: case 0x101:
return "Hi 0.3"; return "Hi 0.3";
case 0x102: case 0x102:
return "Hi 0.5"; return "Hi 0.5";
case 0x103: case 0x103:
return "Hi 0.7"; return "Hi 0.7";
case 0x104: case 0x104:
return "Hi 1.0"; return "Hi 1.0";
case 0x105: case 0x105:
return "Hi 1.3"; return "Hi 1.3";
case 0x106: case 0x106:
return "Hi 1.5"; return "Hi 1.5";
case 0x107: case 0x107:
return "Hi 1.7"; return "Hi 1.7";
case 0x108: case 0x108:
return "Hi 2.0"; return "Hi 2.0";
case 0x201: case 0x201:
return "Lo 0.3"; return "Lo 0.3";
case 0x202: case 0x202:
return "Lo 0.5"; return "Lo 0.5";
case 0x203: case 0x203:
return "Lo 0.7"; return "Lo 0.7";
case 0x204: case 0x204:
return "Lo 1.0"; return "Lo 1.0";
default: { default: {
char buffer[32]; char buffer[32];
sprintf(buffer, "0x%04X", a); sprintf (buffer, "0x%04X", a);
return buffer; return buffer;
} }
} }
} }
}; };
@ -222,7 +222,7 @@ public:
amchoices[0x3] = "Group Dynamic"; amchoices[0x3] = "Group Dynamic";
amchoices[0x4] = "Single Area (wide)"; amchoices[0x4] = "Single Area (wide)";
amchoices[0x5] = "Dynamic Area (wide)"; amchoices[0x5] = "Dynamic Area (wide)";
// AFPoint // AFPoint
afpchoices[0x0] = "Center"; afpchoices[0x0] = "Center";
afpchoices[0x1] = "Top"; afpchoices[0x1] = "Top";
afpchoices[0x2] = "Bottom"; afpchoices[0x2] = "Bottom";
@ -251,62 +251,52 @@ public:
af << "Center"; af << "Center";
} else { } else {
af << ", Center"; af << ", Center";
} } else if (aff & 2)
else if (aff & 2)
if (af.str() == "") { if (af.str() == "") {
af << "Top"; af << "Top";
} else { } else {
af << ", Top"; af << ", Top";
} } else if (aff & 4)
else if (aff & 4)
if (af.str() == "") { if (af.str() == "") {
af << "Bottom"; af << "Bottom";
} else { } else {
af << ", Bottom"; af << ", Bottom";
} } else if (aff & 8)
else if (aff & 8)
if (af.str() == "") { if (af.str() == "") {
af << "Left"; af << "Left";
} else { } else {
af << ", Left"; af << ", Left";
} } else if (aff & 16)
else if (aff & 16)
if (af.str() == "") { if (af.str() == "") {
af << "Right"; af << "Right";
} else { } else {
af << ", Right"; af << ", Right";
} } else if (aff & 32)
else if (aff & 32)
if (af.str() == "") { if (af.str() == "") {
af << "Upper-left"; af << "Upper-left";
} else { } else {
af << ", Upper-left"; af << ", Upper-left";
} } else if (aff & 64)
else if (aff & 64)
if (af.str() == "") { if (af.str() == "") {
af << "Upper-right"; af << "Upper-right";
} else { } else {
af << ", Upper-right"; af << ", Upper-right";
} } else if (aff & 128)
else if (aff & 128)
if (af.str() == "") { if (af.str() == "") {
af << " Lower-left"; af << " Lower-left";
} else { } else {
af << ", Lower-left"; af << ", Lower-left";
} } else if (aff & 256)
else if (aff & 256)
if (af.str() == "") { if (af.str() == "") {
af << "Lower-right"; af << "Lower-right";
} else { } else {
af << ", Lower-right"; af << ", Lower-right";
} } else if (aff & 512)
else if (aff & 512)
if (af.str() == "") { if (af.str() == "") {
af << "Far Left"; af << "Far Left";
} else { } else {
af << ", Far Left"; af << ", Far Left";
} } else if (aff & 1024) {
else if (aff & 1024) {
if (af.str() == "") { if (af.str() == "") {
af << "Far Right"; af << "Far Right";
} else { } else {
@ -372,21 +362,21 @@ public:
std::ostringstream ld; std::ostringstream ld;
ld << "Version = " << ver << std::endl; ld << "Version = " << ver << std::endl;
int lenstype = t->getParent()->getTag(0x0083)->toInt(0, BYTE); int lenstype = t->getParent()->getTag (0x0083)->toInt (0, BYTE);
std::ostringstream lid; std::ostringstream lid;
lid.setf (std::ios_base::hex, std::ios_base::basefield); lid.setf (std::ios_base::hex, std::ios_base::basefield);
lid.setf (std::ios_base::uppercase); lid.setf (std::ios_base::uppercase);
Tag *modelTag = t->getParent()->getRoot()->findTag("Model"); Tag *modelTag = t->getParent()->getRoot()->findTag ("Model");
std::string model( modelTag ? modelTag->valueToString() : ""); std::string model ( modelTag ? modelTag->valueToString() : "");
int lidoffs = 7; int lidoffs = 7;
bool d100 = false; bool d100 = false;
if (model.substr(0, 10) == "NIKON D100" || model.substr(0, 9) == "NIKON D1X") { if (model.substr (0, 10) == "NIKON D100" || model.substr (0, 9) == "NIKON D1X") {
lidoffs = 0; lidoffs = 0;
d100 = true; d100 = true;
} else if( ver < 204) { } else if ( ver < 204) {
lidoffs = 7; lidoffs = 7;
d100 = false; d100 = false;
} else { } else {
@ -403,14 +393,14 @@ public:
} }
if (ver >= 201) { if (ver >= 201) {
const unsigned char* serval = t->getParent()->getTag(0x001d)->getValue (); const unsigned char* serval = t->getParent()->getTag (0x001d)->getValue ();
int serial = 0; int serial = 0;
for (int i = 0; serval[i]; i++) { for (int i = 0; serval[i]; i++) {
serial = serial * 10 + (isdigit(serval[i]) ? serval[i] - '0' : serval[i] % 10); serial = serial * 10 + (isdigit (serval[i]) ? serval[i] - '0' : serval[i] % 10);
} }
const unsigned char* scval = t->getParent()->getTag(0x00a7)->getValue (); const unsigned char* scval = t->getParent()->getTag (0x00a7)->getValue ();
int key = 0; int key = 0;
for (int i = 0; i < 4; i++) { for (int i = 0; i < 4; i++) {
@ -431,7 +421,7 @@ public:
if (!d100) { if (!d100) {
int EffectiveMaxApertureValue; int EffectiveMaxApertureValue;
if( ver < 204 ) { if ( ver < 204 ) {
ld << "ExitPupilPosition = " << (int) buffer[0] << std::endl; ld << "ExitPupilPosition = " << (int) buffer[0] << std::endl;
ld << "AFAperture = " << (int) buffer[1] << std::endl; ld << "AFAperture = " << (int) buffer[1] << std::endl;
ld << "FocusPosition = " << (int) buffer[4] << std::endl; ld << "FocusPosition = " << (int) buffer[4] << std::endl;
@ -448,111 +438,111 @@ public:
} }
switch (EffectiveMaxApertureValue) { switch (EffectiveMaxApertureValue) {
case 0x8: case 0x8:
EffectiveMaxApertureString = "1.2"; EffectiveMaxApertureString = "1.2";
break; break;
case 0xc: case 0xc:
EffectiveMaxApertureString = "1.4"; EffectiveMaxApertureString = "1.4";
break; break;
case 0x14: case 0x14:
EffectiveMaxApertureString = "1.8"; EffectiveMaxApertureString = "1.8";
break; break;
case 0x18: case 0x18:
EffectiveMaxApertureString = "2.0"; EffectiveMaxApertureString = "2.0";
break; break;
case 0x20: case 0x20:
EffectiveMaxApertureString = "2.5"; EffectiveMaxApertureString = "2.5";
break; break;
case 0x24: case 0x24:
EffectiveMaxApertureString = "2.8"; EffectiveMaxApertureString = "2.8";
break; break;
case 0x2a: case 0x2a:
EffectiveMaxApertureString = "3.3"; EffectiveMaxApertureString = "3.3";
break; break;
case 0x2c: case 0x2c:
EffectiveMaxApertureString = "3.5"; EffectiveMaxApertureString = "3.5";
break; break;
case 0x30: case 0x30:
EffectiveMaxApertureString = "4.0"; EffectiveMaxApertureString = "4.0";
break; break;
case 0x34: case 0x34:
EffectiveMaxApertureString = "4.5"; EffectiveMaxApertureString = "4.5";
break; break;
case 0x38: case 0x38:
EffectiveMaxApertureString = "5.0"; EffectiveMaxApertureString = "5.0";
break; break;
case 0x3c: case 0x3c:
EffectiveMaxApertureString = "5.6"; EffectiveMaxApertureString = "5.6";
break; break;
case 0x40: case 0x40:
EffectiveMaxApertureString = "6.3"; EffectiveMaxApertureString = "6.3";
break; break;
case 0x44: case 0x44:
EffectiveMaxApertureString = "7.1"; EffectiveMaxApertureString = "7.1";
break; break;
case 0x48: case 0x48:
EffectiveMaxApertureString = "8.0"; EffectiveMaxApertureString = "8.0";
break; break;
case 0x4e: case 0x4e:
EffectiveMaxApertureString = "9.5"; EffectiveMaxApertureString = "9.5";
break; break;
case 0x54: case 0x54:
EffectiveMaxApertureString = "11.0"; EffectiveMaxApertureString = "11.0";
break; break;
case 0x5a: case 0x5a:
EffectiveMaxApertureString = "13.0"; EffectiveMaxApertureString = "13.0";
break; break;
case 0x5e: case 0x5e:
EffectiveMaxApertureString = "15.0"; EffectiveMaxApertureString = "15.0";
break; break;
case 0x60: case 0x60:
EffectiveMaxApertureString = "16.0"; EffectiveMaxApertureString = "16.0";
break; break;
case 0x66: case 0x66:
EffectiveMaxApertureString = "19.0"; EffectiveMaxApertureString = "19.0";
break; break;
case 0x6c: case 0x6c:
EffectiveMaxApertureString = "22.0"; EffectiveMaxApertureString = "22.0";
break; break;
default : default :
EffectiveMaxApertureString = ""; EffectiveMaxApertureString = "";
} }
ld << "EffectiveMaxAperture = " << EffectiveMaxApertureString << std::endl; ld << "EffectiveMaxAperture = " << EffectiveMaxApertureString << std::endl;
} }
for (int i = 0; i < 7; i++) { for (int i = 0; i < 7; i++) {
lid << std::setw(2) << std::setfill('0') << (int)buffer[lidoffs + i] << ' '; lid << std::setw (2) << std::setfill ('0') << (int)buffer[lidoffs + i] << ' ';
} }
lid << std::setw(2) << std::setfill('0') << lenstype; lid << std::setw (2) << std::setfill ('0') << lenstype;
std::map<std::string, std::string>::const_iterator r = lenses.find (lid.str()); std::map<std::string, std::string>::const_iterator r = lenses.find (lid.str());
if (r != lenses.end()) { if (r != lenses.end()) {
if(r == lenses.begin() && EffectiveMaxApertureString != "") { // first entry is for unchipped lenses if (r == lenses.begin() && EffectiveMaxApertureString != "") { // first entry is for unchipped lenses
ld << "Lens = Unknown $FL$mm f/" << EffectiveMaxApertureString; ld << "Lens = Unknown $FL$mm f/" << EffectiveMaxApertureString;
} else { } else {
ld << "Lens = " << r->second; ld << "Lens = " << r->second;
@ -618,6 +608,7 @@ const std::map<std::string, std::string> NALensDataInterpreter::lenses = {
{"00 4C 7C 7C 2C 2C 00 02", "Tamron SP AF 180mm f/3.5 Di Model (B01)"}, {"00 4C 7C 7C 2C 2C 00 02", "Tamron SP AF 180mm f/3.5 Di Model (B01)"},
{"00 53 2B 50 24 24 00 06", "Tamron SP AF 17-50mm f/2.8 XR Di II LD Aspherical (IF) (A16)"}, {"00 53 2B 50 24 24 00 06", "Tamron SP AF 17-50mm f/2.8 XR Di II LD Aspherical (IF) (A16)"},
{"00 54 2B 50 24 24 00 06", "Tamron SP AF 17-50mm f/2.8 XR Di II LD Aspherical (IF) (A16NII)"}, {"00 54 2B 50 24 24 00 06", "Tamron SP AF 17-50mm f/2.8 XR Di II LD Aspherical (IF) (A16NII)"},
{"00 54 38 38 18 18 00 00", "Carl Zeiss Distagon T* 2/25 ZF.2"},
{"00 54 3C 3C 18 18 00 00", "Carl Zeiss Distagon T* 2/28 ZF.2"}, {"00 54 3C 3C 18 18 00 00", "Carl Zeiss Distagon T* 2/28 ZF.2"},
{"00 54 44 44 0C 0C 00 00", "Carl Zeiss Distagon T* 1.4/35 ZF.2"}, {"00 54 44 44 0C 0C 00 00", "Carl Zeiss Distagon T* 1.4/35 ZF.2"},
{"00 54 44 44 18 18 00 00", "Carl Zeiss Distagon T* 2/35 ZF.2"}, {"00 54 44 44 18 18 00 00", "Carl Zeiss Distagon T* 2/35 ZF.2"},
@ -851,6 +842,7 @@ const std::map<std::string, std::string> NALensDataInterpreter::lenses = {
{"4A 48 24 24 24 0C 4D 02", "Samyang AE 14mm f/2.8 ED AS IF UMC"}, {"4A 48 24 24 24 0C 4D 02", "Samyang AE 14mm f/2.8 ED AS IF UMC"},
{"4A 54 29 29 18 0C 4D 02", "Samyang 16mm f/2.0 ED AS UMC CS"}, {"4A 54 29 29 18 0C 4D 02", "Samyang 16mm f/2.0 ED AS UMC CS"},
{"4A 54 62 62 0C 0C 4D 02", "AF Nikkor 85mm f/1.4D IF"}, {"4A 54 62 62 0C 0C 4D 02", "AF Nikkor 85mm f/1.4D IF"},
{"4A 60 36 36 0C 0C 4D 02", "Samyang 24mm f/1.4 ED AS UMC"},
{"4A 60 44 44 0C 0C 4D 02", "Samyang 35mm f/1.4 AS UMC"}, {"4A 60 44 44 0C 0C 4D 02", "Samyang 35mm f/1.4 AS UMC"},
{"4A 60 62 62 0C 0C 4D 02", "Samyang AE 85mm f/1.4 AS IF UMC"}, {"4A 60 62 62 0C 0C 4D 02", "Samyang AE 85mm f/1.4 AS IF UMC"},
{"4B 3C A0 A0 30 30 4E 02", "AF-S Nikkor 500mm f/4D IF-ED"}, {"4B 3C A0 A0 30 30 4E 02", "AF-S Nikkor 500mm f/4D IF-ED"},
@ -907,6 +899,7 @@ const std::map<std::string, std::string> NALensDataInterpreter::lenses = {
{"74 40 37 62 2C 34 78 06", "AF-S Zoom-Nikkor 24-85mm f/3.5-4.5G IF-ED"}, {"74 40 37 62 2C 34 78 06", "AF-S Zoom-Nikkor 24-85mm f/3.5-4.5G IF-ED"},
{"75 40 3C 68 2C 3C 79 06", "AF Zoom-Nikkor 28-100mm f/3.5-5.6G"}, {"75 40 3C 68 2C 3C 79 06", "AF Zoom-Nikkor 28-100mm f/3.5-5.6G"},
{"76 58 50 50 14 14 7A 02", "AF Nikkor 50mm f/1.8D"}, {"76 58 50 50 14 14 7A 02", "AF Nikkor 50mm f/1.8D"},
{"77 44 60 98 34 3C 7B 0E", "Sigma 80-400mm f4.5-5.6 APO DG D OS"},
{"77 44 61 98 34 3C 7B 0E", "Sigma 80-400mm f/4.5-5.6 EX OS"}, {"77 44 61 98 34 3C 7B 0E", "Sigma 80-400mm f/4.5-5.6 EX OS"},
{"77 48 5C 80 24 24 7B 0E", "AF-S VR Zoom-Nikkor 70-200mm f/2.8G IF-ED"}, {"77 48 5C 80 24 24 7B 0E", "AF-S VR Zoom-Nikkor 70-200mm f/2.8G IF-ED"},
{"78 40 37 6E 2C 3C 7C 0E", "AF-S VR Zoom-Nikkor 24-120mm f/3.5-5.6G IF-ED"}, {"78 40 37 6E 2C 3C 7C 0E", "AF-S VR Zoom-Nikkor 24-120mm f/3.5-5.6G IF-ED"},
@ -914,6 +907,7 @@ const std::map<std::string, std::string> NALensDataInterpreter::lenses = {
{"79 40 3C 80 2C 3C 7F 06", "AF Zoom-Nikkor 28-200mm f/3.5-5.6G IF-ED"}, {"79 40 3C 80 2C 3C 7F 06", "AF Zoom-Nikkor 28-200mm f/3.5-5.6G IF-ED"},
{"79 48 3C 5C 24 24 1C 06", "Sigma 28-70mm f/2.8 EX DG"}, {"79 48 3C 5C 24 24 1C 06", "Sigma 28-70mm f/2.8 EX DG"},
{"79 48 5C 5C 24 24 1C 06", "Sigma Macro 70mm f/2.8 EX DG"}, {"79 48 5C 5C 24 24 1C 06", "Sigma Macro 70mm f/2.8 EX DG"},
{"79 54 31 31 0C 0C 4B 06", "Sigma 20mm f/1.4 DG HSM | A"},
{"7A 3B 53 80 30 3C 4B 06", "Sigma 55-200mm f/4-5.6 DC HSM"}, {"7A 3B 53 80 30 3C 4B 06", "Sigma 55-200mm f/4-5.6 DC HSM"},
{"7A 3C 1F 37 30 30 7E 06", "AF-S DX Zoom-Nikkor 12-24mm f/4G IF-ED"}, {"7A 3C 1F 37 30 30 7E 06", "AF-S DX Zoom-Nikkor 12-24mm f/4G IF-ED"},
{"7A 3C 1F 37 30 30 7E 06", "Tokina AT-X 124 AF PRO DX II (AF 12-24mm f/4)"}, {"7A 3C 1F 37 30 30 7E 06", "Tokina AT-X 124 AF PRO DX II (AF 12-24mm f/4)"},
@ -981,6 +975,8 @@ const std::map<std::string, std::string> NALensDataInterpreter::lenses = {
{"9E 40 2D 6A 2C 3C A0 0E", "AF-S DX VR Zoom-Nikkor 18-105mm f/3.5-5.6G ED"}, {"9E 40 2D 6A 2C 3C A0 0E", "AF-S DX VR Zoom-Nikkor 18-105mm f/3.5-5.6G ED"},
{"9F 37 50 A0 34 40 4B 0E", "Sigma 50-500mm f/4.5-6.3 DG OS HSM"}, {"9F 37 50 A0 34 40 4B 0E", "Sigma 50-500mm f/4.5-6.3 DG OS HSM"},
{"9F 58 44 44 14 14 A1 06", "AF-S DX Nikkor 35mm f/1.8G"}, {"9F 58 44 44 14 14 A1 06", "AF-S DX Nikkor 35mm f/1.8G"},
{"A0 40 2D 53 2C 3C CA 0E", "AF-P DX Nikkor 18-55mm f/3.5-5.6G VR"},
{"A0 40 2D 53 2C 3C CA 8E", "AF-P DX Nikkor 18-55mm f/3.5-5.6G"},
{"A0 40 2D 74 2C 3C BB 0E", "AF-S DX Nikkor 18-140mm f/3.5-5.6G ED VR"}, {"A0 40 2D 74 2C 3C BB 0E", "AF-S DX Nikkor 18-140mm f/3.5-5.6G ED VR"},
{"A0 48 2A 5C 24 30 4B 0E", "Sigma 17-70mm f/2.8-4 DC Macro OS HSM"}, {"A0 48 2A 5C 24 30 4B 0E", "Sigma 17-70mm f/2.8-4 DC Macro OS HSM"},
{"A0 54 50 50 0C 0C A2 06", "AF-S Nikkor 50mm f/1.4G"}, {"A0 54 50 50 0C 0C A2 06", "AF-S Nikkor 50mm f/1.4G"},
@ -993,10 +989,13 @@ const std::map<std::string, std::string> NALensDataInterpreter::lenses = {
{"A3 3C 5C 8E 30 3C 4B 0E", "Sigma 70-300mm f/4-5.6 DG OS"}, {"A3 3C 5C 8E 30 3C 4B 0E", "Sigma 70-300mm f/4-5.6 DG OS"},
{"A4 40 2D 8E 2C 40 BF 0E", "AF-S DX Nikkor 18-300mm f/3.5-6.3G ED VR"}, {"A4 40 2D 8E 2C 40 BF 0E", "AF-S DX Nikkor 18-300mm f/3.5-6.3G ED VR"},
{"A4 47 2D 50 24 34 4B 0E", "Sigma 18-50mm f/2.8-4.5 DC OS HSM"}, {"A4 47 2D 50 24 34 4B 0E", "Sigma 18-50mm f/2.8-4.5 DC OS HSM"},
{"A4 48 5C 80 24 24 CF 0E", "AF-S Nikkor 70-200mm f/2.8E FL ED VR"},
{"A4 54 37 37 0C 0C A6 06", "AF-S Nikkor 24mm f/1.4G ED"}, {"A4 54 37 37 0C 0C A6 06", "AF-S Nikkor 24mm f/1.4G ED"},
{"A5 40 2D 88 2C 40 4B 0E", "Sigma 18-250mm f/3.5-6.3 DC OS HSM"}, {"A5 40 2D 88 2C 40 4B 0E", "Sigma 18-250mm f/3.5-6.3 DC OS HSM"},
{"A5 40 3C 8E 2C 3C A7 0E", "AF-S Nikkor 28-300mm f/3.5-5.6G ED VR"}, {"A5 40 3C 8E 2C 3C A7 0E", "AF-S Nikkor 28-300mm f/3.5-5.6G ED VR"},
{"A5 4C 44 44 14 14 C0 06", "AF-S Nikkor 35mm f/1.8G ED"}, {"A5 4C 44 44 14 14 C0 06", "AF-S Nikkor 35mm f/1.8G ED"},
{"A5 54 6A 6A 0C 0C D0 06", "AF-S Nikkor 105mm f/1.4E ED"},
{"A5 54 6A 6A 0C 0C D0 46", "AF-S Nikkor 105mm f/1.4E ED"},
{"A6 48 37 5C 24 24 4B 06", "Sigma 24-70mm f/2.8 IF EX DG HSM"}, {"A6 48 37 5C 24 24 4B 06", "Sigma 24-70mm f/2.8 IF EX DG HSM"},
{"A6 48 8E 8E 24 24 A8 0E", "AF-S VR Nikkor 300mm f/2.8G IF-ED II"}, {"A6 48 8E 8E 24 24 A8 0E", "AF-S VR Nikkor 300mm f/2.8G IF-ED II"},
{"A6 48 98 98 24 24 C1 0E", "AF-S Nikkor 400mm f/2.8E FL ED VR"}, {"A6 48 98 98 24 24 C1 0E", "AF-S Nikkor 400mm f/2.8E FL ED VR"},
@ -1040,9 +1039,12 @@ const std::map<std::string, std::string> NALensDataInterpreter::lenses = {
{"E0 3C 5C 8E 30 3C 4B 06", "Sigma 70-300mm f/4-5.6 APO DG Macro HSM"}, {"E0 3C 5C 8E 30 3C 4B 06", "Sigma 70-300mm f/4-5.6 APO DG Macro HSM"},
{"E1 58 37 37 14 14 1C 02", "Sigma 24mm f/1.8 EX DG Aspherical Macro"}, {"E1 58 37 37 14 14 1C 02", "Sigma 24mm f/1.8 EX DG Aspherical Macro"},
{"E3 54 50 50 24 24 35 02", "Sigma Macro 50mm f/2.8 EX DG"}, {"E3 54 50 50 24 24 35 02", "Sigma Macro 50mm f/2.8 EX DG"},
{"E4 54 64 64 24 24 DF 0E", "Tamron SP 90mm f/2.8 Di VC USD Macro 1:1 (F017)"},
{"E5 54 6A 6A 24 24 35 02", "Sigma Macro 105mm f/2.8 EX DG"}, {"E5 54 6A 6A 24 24 35 02", "Sigma Macro 105mm f/2.8 EX DG"},
{"E6 40 2D 80 2C 40 DF 0E", "Tamron AF 18-200mm f/3.5-6.3 Di II VC (B018)"},
{"E6 41 3C 8E 2C 40 1C 02", "Sigma 28-300mm f/3.5-6.3 DG Macro"}, {"E6 41 3C 8E 2C 40 1C 02", "Sigma 28-300mm f/3.5-6.3 DG Macro"},
{"E8 4C 44 44 14 14 DF 0E", "Tamron SP 35mm f/1.8 VC"}, {"E7 4C 4C 4C 14 14 DF 0E", "Tamron SP 45mm f/1.8 Di VC USD (F013)"},
{"E8 4C 44 44 14 14 DF 0E", "Tamron SP 35mm f/1.8 Di VC USD (F012)"},
{"E9 48 27 3E 24 24 DF 0E", "Tamron SP 15-30mm f/2.8 Di VC USD (A012)"}, {"E9 48 27 3E 24 24 DF 0E", "Tamron SP 15-30mm f/2.8 Di VC USD (A012)"},
{"E9 54 37 5C 24 24 1C 02", "Sigma 24-70mm f/2.8 EX DG Macro"}, {"E9 54 37 5C 24 24 1C 02", "Sigma 24-70mm f/2.8 EX DG Macro"},
{"EA 40 29 8E 2C 40 DF 0E", "Tamron AF 16-300mm f/3.5-6.3 Di II VC PZD (B016)"}, {"EA 40 29 8E 2C 40 DF 0E", "Tamron AF 16-300mm f/3.5-6.3 Di II VC PZD (B016)"},

View File

@ -66,8 +66,8 @@ public:
virtual std::string toString (Tag* t) virtual std::string toString (Tag* t)
{ {
std::ostringstream str; std::ostringstream str;
str.precision(2); str.precision (2);
str << pow(2, t->toInt() / 512.0); str << pow (2, t->toInt() / 512.0);
return str.str(); return str.str();
} }
}; };
@ -122,6 +122,9 @@ public:
lenses["00 24 00"] = "Olympus Zuiko Digital ED 40-150mm f/4.0-5.6"; lenses["00 24 00"] = "Olympus Zuiko Digital ED 40-150mm f/4.0-5.6";
lenses["00 24 10"] = "Olympus M.Zuiko Digital ED 300mm f/4.0 IS Pro"; lenses["00 24 10"] = "Olympus M.Zuiko Digital ED 300mm f/4.0 IS Pro";
lenses["00 25 10"] = "Olympus M.Zuiko Digital ED 8mm f/1.8 Fisheye Pro"; lenses["00 25 10"] = "Olympus M.Zuiko Digital ED 8mm f/1.8 Fisheye Pro";
lenses["00 26 10"] = "Olympus M.Zuiko Digital ED 12-100mm f/4.0 IS Pro";
lenses["00 27 10"] = "Olympus M.Zuiko Digital ED 30mm f/3.5 Macro";
lenses["00 28 10"] = "Olympus M.Zuiko Digital ED 25mm f/1.2 Pro";
lenses["00 30 00"] = "Olympus Zuiko Digital ED 50-200mm f/2.8-3.5 SWD"; lenses["00 30 00"] = "Olympus Zuiko Digital ED 50-200mm f/2.8-3.5 SWD";
lenses["00 31 00"] = "Olympus Zuiko Digital ED 12-60mm f/2.8-4.0 SWD"; lenses["00 31 00"] = "Olympus Zuiko Digital ED 12-60mm f/2.8-4.0 SWD";
lenses["00 32 00"] = "Olympus Zuiko Digital ED 14-35mm f/2.0 SWD"; lenses["00 32 00"] = "Olympus Zuiko Digital ED 14-35mm f/2.0 SWD";
@ -193,9 +196,9 @@ public:
std::ostringstream lid; std::ostringstream lid;
lid.setf (std::ios_base::hex, std::ios_base::basefield); lid.setf (std::ios_base::hex, std::ios_base::basefield);
lid.setf (std::ios_base::uppercase); lid.setf (std::ios_base::uppercase);
lid << std::setw(2) << std::setfill('0') << t->toInt(0) << ' '; //maker lid << std::setw (2) << std::setfill ('0') << t->toInt (0) << ' '; //maker
lid << std::setw(2) << std::setfill('0') << t->toInt(2) << ' '; //model lid << std::setw (2) << std::setfill ('0') << t->toInt (2) << ' '; //model
lid << std::setw(2) << std::setfill('0') << t->toInt(3); // submodel lid << std::setw (2) << std::setfill ('0') << t->toInt (3); // submodel
std::map<std::string, std::string>::iterator r = lenses.find (lid.str()); std::map<std::string, std::string>::iterator r = lenses.find (lid.str());
@ -258,6 +261,7 @@ public:
choices[1] = "Sequential shooting AF"; choices[1] = "Sequential shooting AF";
choices[2] = "Continuous AF"; choices[2] = "Continuous AF";
choices[3] = "Multi AF"; choices[3] = "Multi AF";
choices[4] = "Face detect";
choices[10] = "MF"; choices[10] = "MF";
} }
}; };

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -54,7 +54,7 @@ const enum ByteOrder HOSTORDER = MOTOROLA;
#endif #endif
enum MNKind {NOMK, IFD, HEADERIFD, NIKON3, OLYMPUS2, FUJI, TABLESUBDIR}; enum MNKind {NOMK, IFD, HEADERIFD, NIKON3, OLYMPUS2, FUJI, TABLESUBDIR};
bool extractLensInfo(std::string &fullname, double &minFocal, double &maxFocal, double &maxApertureAtMinFocal, double &maxApertureAtMaxFocal); bool extractLensInfo (std::string &fullname, double &minFocal, double &maxFocal, double &maxApertureAtMinFocal, double &maxApertureAtMaxFocal);
unsigned short sget2 (unsigned char *s, ByteOrder order); unsigned short sget2 (unsigned char *s, ByteOrder order);
int sget4 (unsigned char *s, ByteOrder order); int sget4 (unsigned char *s, ByteOrder order);
@ -135,7 +135,7 @@ public:
Tag* getTagP (const char* name) const; // Try to get the Tag at a given location. 'name' is a path relative to this directory (e.g. "LensInfo/FocalLength") Tag* getTagP (const char* name) const; // Try to get the Tag at a given location. 'name' is a path relative to this directory (e.g. "LensInfo/FocalLength")
Tag* getTag (int ID) const; Tag* getTag (int ID) const;
virtual Tag* findTag (const char* name) const; virtual Tag* findTag (const char* name) const;
bool getXMPTagValue(const char* name, char* value) const; bool getXMPTagValue (const char* name, char* value) const;
void keepTag (int ID); void keepTag (int ID);
virtual void addTag (Tag* a); virtual void addTag (Tag* a);
@ -197,7 +197,7 @@ protected:
TagDirectory* parent; TagDirectory* parent;
TagDirectory** directory; TagDirectory** directory;
MNKind makerNoteKind; MNKind makerNoteKind;
bool parseMakerNote(FILE* f, int base, ByteOrder bom ); bool parseMakerNote (FILE* f, int base, ByteOrder bom );
public: public:
Tag (TagDirectory* parent, FILE* f, int base); // parse next tag from the file Tag (TagDirectory* parent, FILE* f, int base); // parse next tag from the file
@ -236,7 +236,7 @@ public:
} }
signed char* getSignedValue () const signed char* getSignedValue () const
{ {
return reinterpret_cast<signed char*>(value); return reinterpret_cast<signed char*> (value);
} }
const TagAttrib* getAttrib () const const TagAttrib* getAttrib () const
{ {
@ -334,62 +334,62 @@ public:
{ {
char buffer[1024]; char buffer[1024];
t->toString (buffer); t->toString (buffer);
std::string s(buffer); std::string s (buffer);
std::string::size_type p1 = s.find_first_not_of(' '); std::string::size_type p1 = s.find_first_not_of (' ');
if( p1 == std::string::npos ) { if ( p1 == std::string::npos ) {
return s; return s;
} else { } else {
return s.substr(p1, s.find_last_not_of(' ') - p1 + 1); return s.substr (p1, s.find_last_not_of (' ') - p1 + 1);
} }
} }
virtual void fromString (Tag* t, const std::string& value) virtual void fromString (Tag* t, const std::string& value)
{ {
if (t->getType() == SHORT || t->getType() == LONG) { if (t->getType() == SHORT || t->getType() == LONG) {
t->fromInt (atoi(value.c_str())); t->fromInt (atoi (value.c_str()));
} else { } else {
t->fromString (value.c_str()); t->fromString (value.c_str());
} }
} }
// Get the value as a double // Get the value as a double
virtual double toDouble(Tag* t, int ofs = 0) virtual double toDouble (Tag* t, int ofs = 0)
{ {
double ud, dd; double ud, dd;
switch (t->getType()) { switch (t->getType()) {
case SBYTE: case SBYTE:
return double(int(t->getSignedValue()[ofs])); return double (int (t->getSignedValue()[ofs]));
case BYTE: case BYTE:
return (double)((int)t->getValue()[ofs]); return (double) ((int)t->getValue()[ofs]);
case ASCII: case ASCII:
return 0.0; return 0.0;
case SSHORT: case SSHORT:
return (double)int2_to_signed(sget2 (t->getValue() + ofs, t->getOrder())); return (double)int2_to_signed (sget2 (t->getValue() + ofs, t->getOrder()));
case SHORT: case SHORT:
return (double)((int)sget2 (t->getValue() + ofs, t->getOrder())); return (double) ((int)sget2 (t->getValue() + ofs, t->getOrder()));
case SLONG: case SLONG:
case LONG: case LONG:
return (double)((int)sget4 (t->getValue() + ofs, t->getOrder())); return (double) ((int)sget4 (t->getValue() + ofs, t->getOrder()));
case SRATIONAL: case SRATIONAL:
case RATIONAL: case RATIONAL:
ud = (int)sget4 (t->getValue() + ofs, t->getOrder()); ud = (int)sget4 (t->getValue() + ofs, t->getOrder());
dd = (int)sget4 (t->getValue() + ofs + 4, t->getOrder()); dd = (int)sget4 (t->getValue() + ofs + 4, t->getOrder());
return dd == 0. ? 0. : (double)ud / (double)dd; return dd == 0. ? 0. : (double)ud / (double)dd;
case FLOAT: case FLOAT:
return double(sget4 (t->getValue() + ofs, t->getOrder())); return double (sget4 (t->getValue() + ofs, t->getOrder()));
case UNDEFINED: case UNDEFINED:
return 0.; return 0.;
default: default:
return 0.; // Quick fix for missing cases (INVALID, DOUBLE, OLYUNDEF, SUBDIR) return 0.; // Quick fix for missing cases (INVALID, DOUBLE, OLYUNDEF, SUBDIR)
} }
} }
// Get the value as an int // Get the value as an int
@ -402,38 +402,38 @@ public:
} }
switch (astype) { switch (astype) {
case SBYTE: case SBYTE:
return int(t->getSignedValue()[ofs]); return int (t->getSignedValue()[ofs]);
case BYTE: case BYTE:
return t->getValue()[ofs]; return t->getValue()[ofs];
case ASCII: case ASCII:
return 0; return 0;
case SSHORT: case SSHORT:
return (int)int2_to_signed(sget2 (t->getValue() + ofs, t->getOrder())); return (int)int2_to_signed (sget2 (t->getValue() + ofs, t->getOrder()));
case SHORT: case SHORT:
return (int)sget2 (t->getValue() + ofs, t->getOrder()); return (int)sget2 (t->getValue() + ofs, t->getOrder());
case SLONG: case SLONG:
case LONG: case LONG:
return (int)sget4 (t->getValue() + ofs, t->getOrder()); return (int)sget4 (t->getValue() + ofs, t->getOrder());
case SRATIONAL: case SRATIONAL:
case RATIONAL: case RATIONAL:
a = (int)sget4 (t->getValue() + ofs + 4, t->getOrder()); a = (int)sget4 (t->getValue() + ofs + 4, t->getOrder());
return a == 0 ? 0 : (int)sget4 (t->getValue() + ofs, t->getOrder()) / a; return a == 0 ? 0 : (int)sget4 (t->getValue() + ofs, t->getOrder()) / a;
case FLOAT: case FLOAT:
return (int)toDouble(t, ofs); return (int)toDouble (t, ofs);
case UNDEFINED: case UNDEFINED:
return 0; return 0;
default: default:
return 0; // Quick fix for missing cases (INVALID, DOUBLE, OLYUNDEF, SUBDIR) return 0; // Quick fix for missing cases (INVALID, DOUBLE, OLYUNDEF, SUBDIR)
} }
return 0; return 0;
@ -470,28 +470,28 @@ protected:
typedef std::pair< T, std::string> p_t; typedef std::pair< T, std::string> p_t;
container_t choices; container_t choices;
virtual std::string guess(const T lensID, double focalLength, double maxApertureAtFocal, double *lensInfoArray) virtual std::string guess (const T lensID, double focalLength, double maxApertureAtFocal, double *lensInfoArray)
{ {
it_t r; it_t r;
size_t nFound = choices.count( lensID ); size_t nFound = choices.count ( lensID );
switch( nFound ) { switch ( nFound ) {
case 0: { // lens Unknown case 0: { // lens Unknown
std::ostringstream s; std::ostringstream s;
s << lensID; s << lensID;
return s.str(); return s.str();
}
case 1: // lens found
r = choices.find ( lensID );
return r->second;
default:
// More than one hit: we must guess
break;
} }
case 1: // lens found std::string bestMatch ("Unknown");
r = choices.find ( lensID );
return r->second;
default:
// More than one hit: we must guess
break;
}
std::string bestMatch("Unknown");
double a1, a2, f1, f2; double a1, a2, f1, f2;
/* FIRST TRY /* FIRST TRY
@ -499,8 +499,8 @@ protected:
* Get the lens info (min/man focal, min/max aperture) and compare them to the possible choice * Get the lens info (min/man focal, min/max aperture) and compare them to the possible choice
*/ */
if (lensInfoArray) { if (lensInfoArray) {
for ( r = choices.lower_bound( lensID ); r != choices.upper_bound(lensID); ++r ) { for ( r = choices.lower_bound ( lensID ); r != choices.upper_bound (lensID); ++r ) {
if( !extractLensInfo( r->second , f1, f2, a1, a2) ) { if ( !extractLensInfo ( r->second, f1, f2, a1, a2) ) {
continue; continue;
} }
@ -513,17 +513,17 @@ protected:
// No lens found, we update the "unknown" string with the lens info values // No lens found, we update the "unknown" string with the lens info values
if (lensInfoArray[0] == lensInfoArray[1]) { if (lensInfoArray[0] == lensInfoArray[1]) {
bestMatch += Glib::ustring::compose(" (%1mm", int(lensInfoArray[0])); bestMatch += Glib::ustring::compose (" (%1mm", int (lensInfoArray[0]));
} else { } else {
bestMatch += Glib::ustring::compose(" (%1-%2mm", int(lensInfoArray[0]), int(lensInfoArray[1])); bestMatch += Glib::ustring::compose (" (%1-%2mm", int (lensInfoArray[0]), int (lensInfoArray[1]));
} }
if (lensInfoArray[2] == lensInfoArray[3]) { if (lensInfoArray[2] == lensInfoArray[3]) {
bestMatch += Glib::ustring::compose(" f/%1)", Glib::ustring::format(std::fixed, std::setprecision(1), lensInfoArray[2])); bestMatch += Glib::ustring::compose (" f/%1)", Glib::ustring::format (std::fixed, std::setprecision (1), lensInfoArray[2]));
} else } else
bestMatch += Glib::ustring::compose(" f/%1-%2)", bestMatch += Glib::ustring::compose (" f/%1-%2)",
Glib::ustring::format(std::fixed, std::setprecision(1), lensInfoArray[2]), Glib::ustring::format (std::fixed, std::setprecision (1), lensInfoArray[2]),
Glib::ustring::format(std::fixed, std::setprecision(1), lensInfoArray[3])); Glib::ustring::format (std::fixed, std::setprecision (1), lensInfoArray[3]));
} }
/* SECOND TRY /* SECOND TRY
@ -536,45 +536,46 @@ protected:
std::ostringstream candidates; std::ostringstream candidates;
double deltaMin = 1000.; double deltaMin = 1000.;
for ( r = choices.lower_bound( lensID ); r != choices.upper_bound(lensID); ++r ) { for ( r = choices.lower_bound ( lensID ); r != choices.upper_bound (lensID); ++r ) {
double dif; double dif;
if( !extractLensInfo( r->second , f1, f2, a1, a2) ) { if ( !extractLensInfo ( r->second, f1, f2, a1, a2) ) {
continue; continue;
} }
if( f1 == 0. || a1 == 0.) { if ( f1 == 0. || a1 == 0.) {
continue; continue;
} }
if( focalLength < f1 - .5 || focalLength > f2 + 0.5 ) { if ( focalLength < f1 - .5 || focalLength > f2 + 0.5 ) {
continue; continue;
} }
if( maxApertureAtFocal > 0.1) { if ( maxApertureAtFocal > 0.1) {
double lensAperture; double lensAperture;
if( maxApertureAtFocal < a1 - 0.15 || maxApertureAtFocal > a2 + 0.15) {
if ( maxApertureAtFocal < a1 - 0.15 || maxApertureAtFocal > a2 + 0.15) {
continue; continue;
} }
if( a1 == a2 || f1 == f2) { if ( a1 == a2 || f1 == f2) {
lensAperture = a1; lensAperture = a1;
} else { } else {
lensAperture = exp( log(a1) + (log(a2) - log(a1)) / (log(f2) - log(f1)) * (log(focalLength) - log(f1)) ); lensAperture = exp ( log (a1) + (log (a2) - log (a1)) / (log (f2) - log (f1)) * (log (focalLength) - log (f1)) );
} }
dif = std::abs(lensAperture - maxApertureAtFocal); dif = std::abs (lensAperture - maxApertureAtFocal);
} else { } else {
dif = 0; dif = 0;
} }
if( dif < deltaMin ) { if ( dif < deltaMin ) {
deltaMin = dif; deltaMin = dif;
bestMatch = r->second; bestMatch = r->second;
} }
if( dif < 0.15) { if ( dif < 0.15) {
if( candidates.tellp() ) { if ( candidates.tellp() ) {
candidates << "\n or " << r->second; candidates << "\n or " << r->second;
} else { } else {
candidates << r->second; candidates << r->second;
@ -582,7 +583,7 @@ protected:
} }
} }
if( !candidates.tellp() ) { if ( !candidates.tellp() ) {
return bestMatch; return bestMatch;
} else { } else {
return candidates.str(); return candidates.str();
@ -590,7 +591,7 @@ protected:
} }
}; };
inline static int getTypeSize( TagType type ) inline static int getTypeSize ( TagType type )
{ {
return ("11124811248484"[type < 14 ? type : 0] - '0'); return ("11124811248484"[type < 14 ? type : 0] - '0');
} }
@ -627,6 +628,6 @@ extern const TagAttrib sonyCameraSettingsAttribs3[];
//extern const TagAttrib sonyDNGMakerNote[]; //extern const TagAttrib sonyDNGMakerNote[];
extern const TagAttrib olympusAttribs[]; extern const TagAttrib olympusAttribs[];
extern const TagAttrib kodakIfdAttribs[]; extern const TagAttrib kodakIfdAttribs[];
void parseKodakIfdTextualInfo(Tag *textualInfo, Tag* exif); void parseKodakIfdTextualInfo (Tag *textualInfo, Tag* exif);
} }
#endif #endif

View File

@ -664,6 +664,7 @@ public:
{128, "Sigma 35mm f/1.4 DG HSM"}, {128, "Sigma 35mm f/1.4 DG HSM"},
{128, "Sigma 18-35mm f/1.8 DC HSM"}, {128, "Sigma 18-35mm f/1.8 DC HSM"},
{128, "Sigma 50-500mm f/4.5-6.3 APO DG OS HSM"}, {128, "Sigma 50-500mm f/4.5-6.3 APO DG OS HSM"},
{128, "Sigma 24-105mm f/4 DG HSM | Art 013"},
{129, "Tamron Lens (129)"}, {129, "Tamron Lens (129)"},
{129, "Tamron 200-400mm f/5.6 LD"}, {129, "Tamron 200-400mm f/5.6 LD"},
{129, "Tamron 70-300mm f/4-5.6 LD"}, {129, "Tamron 70-300mm f/4-5.6 LD"},
@ -676,11 +677,15 @@ public:
{142, "Voigtlander 70-300mm f/4.5-5.6"}, {142, "Voigtlander 70-300mm f/4.5-5.6"},
{146, "Voigtlander Macro APO-Lanthar 125mm f/2.5 SL"}, {146, "Voigtlander Macro APO-Lanthar 125mm f/2.5 SL"},
{194, "Tamron SP AF 17-50mm f/2.8 XR Di II LD Aspherical [IF]"}, {194, "Tamron SP AF 17-50mm f/2.8 XR Di II LD Aspherical [IF]"},
{202, "Tamron SP AF 70-200mm f/2.8 Di LD [IF] Macro"},
{203, "Tamron SP 70-200mm f/2.8 Di USD"}, {203, "Tamron SP 70-200mm f/2.8 Di USD"},
{204, "Tamron SP 24-70mm f/2.8 Di USD"}, {204, "Tamron SP 24-70mm f/2.8 Di USD"},
{213, "Tamron 16-300mm f/3.5-6.3 Di II PZD"}, {212, "Tamron 28-300mm f/3.5-6.3 Di PZD"},
{213, "Tamron 16-300mm f/3.5-6.3 Di II PZD Macro"},
{214, "Tamron SP 150-600mm f/5-6.3 Di USD"}, {214, "Tamron SP 150-600mm f/5-6.3 Di USD"},
{224, "Tamron SP 90mm f/2.8 Di Macro 1:1 USD"}, {215, "Tamron SP 15-30mm f/2.8 Di USD"},
{218, "Tamron SP 90mm f/2.8 Di Macro 1:1 USD (F017)"},
{224, "Tamron SP 90mm f/2.8 Di Macro 1:1 USD (F004)"},
{255, "Tamron Lens (255)"}, {255, "Tamron Lens (255)"},
{255, "Tamron SP AF 17-50mm f/2.8 XR Di II LD Aspherical"}, {255, "Tamron SP AF 17-50mm f/2.8 XR Di II LD Aspherical"},
{255, "Tamron AF 18-250mm f/3.5-6.3 XR Di II LD"}, {255, "Tamron AF 18-250mm f/3.5-6.3 XR Di II LD"},
@ -691,7 +696,7 @@ public:
{255, "Tamron SP AF 70-200mm f/2.8 Di LD IF Macro"}, {255, "Tamron SP AF 70-200mm f/2.8 Di LD IF Macro"},
{255, "Tamron SP AF 28-75mm f/2.8 XR Di LD Aspherical IF"}, {255, "Tamron SP AF 28-75mm f/2.8 XR Di LD Aspherical IF"},
{255, "Tamron AF 90-300mm f/4.5-5.6 Telemacro"}, {255, "Tamron AF 90-300mm f/4.5-5.6 Telemacro"},
{1868, "Sigma MC-11 Adapter"}, {1868, "Sigma MC-11 SA-E Mount Converter with not-supported Sigma lens"},
{2550, "Minolta AF 50mm f/1.7"}, {2550, "Minolta AF 50mm f/1.7"},
{2551, "Minolta AF 35-70mm f/4 or Other Lens"}, {2551, "Minolta AF 35-70mm f/4 or Other Lens"},
{2551, "Sigma UC AF 28-70mm f/3.5-4.5"}, {2551, "Sigma UC AF 28-70mm f/3.5-4.5"},
@ -814,6 +819,7 @@ public:
{4587, "Tamron AF 70-210mm f/2.8 SP LD"}, {4587, "Tamron AF 70-210mm f/2.8 SP LD"},
{4812, "Metabones Canon EF Speed Booster Ultra"}, {4812, "Metabones Canon EF Speed Booster Ultra"},
{6118, "Canon EF Adapter"}, {6118, "Canon EF Adapter"},
{6528, "Sigma 16mm f/2.8 Filtermatic Fisheye"},
{6553, "E-Mount, T-Mount, Other Lens or no lens"}, {6553, "E-Mount, T-Mount, Other Lens or no lens"},
{6553, "Sony E 16mm f/2.8"}, {6553, "Sony E 16mm f/2.8"},
{6553, "Sony E 18-55mm f/3.5-5.6 OSS"}, {6553, "Sony E 18-55mm f/3.5-5.6 OSS"},
@ -827,6 +833,7 @@ public:
{6553, "Sony E PZ 16-50mm f/3.5-5.6 OSS"}, {6553, "Sony E PZ 16-50mm f/3.5-5.6 OSS"},
{6553, "Sony FE 35mm f/2.8 ZA"}, {6553, "Sony FE 35mm f/2.8 ZA"},
{6553, "Sony FE 24-70mm f/4 ZA OSS"}, {6553, "Sony FE 24-70mm f/4 ZA OSS"},
{6553, "Sony FE 85mm f/1.8"},
{6553, "Sony E 18-200mm f/3.5-6.3 OSS LE"}, {6553, "Sony E 18-200mm f/3.5-6.3 OSS LE"},
{6553, "Sony E 20mm f/2.8"}, {6553, "Sony E 20mm f/2.8"},
{6553, "Sony E 35mm f/1.8 OSS"}, {6553, "Sony E 35mm f/1.8 OSS"},
@ -837,32 +844,42 @@ public:
{6553, "Sony FE 55mm f/1.8 ZA"}, {6553, "Sony FE 55mm f/1.8 ZA"},
{6553, "Sony FE 70-200mm f/4 G OSS"}, {6553, "Sony FE 70-200mm f/4 G OSS"},
{6553, "Sony FE 16-35mm f/4 ZA OSS"}, {6553, "Sony FE 16-35mm f/4 ZA OSS"},
{6553, "Sony FE 50mm f/2.8 Macro"},
{6553, "Sony FE 28-70mm f/3.5-5.6 OSS"}, {6553, "Sony FE 28-70mm f/3.5-5.6 OSS"},
{6553, "Sony FE 35mm f/1.4 ZA"}, {6553, "Sony FE 35mm f/1.4 ZA"},
{6553, "Sony FE 24-240mm f/3.5-6.3 OSS"}, {6553, "Sony FE 24-240mm f/3.5-6.3 OSS"},
{6553, "Sony FE 28mm f/2"}, {6553, "Sony FE 28mm f/2"},
{6553, "Sony FE PZ 28-135mm f/4 G OSS"}, {6553, "Sony FE PZ 28-135mm f/4 G OSS"},
{6553, "Sony FE 100mm f/2.8 STF GM OSS"},
{6553, "Sony FE 24-70mm f/2.8 GM"}, {6553, "Sony FE 24-70mm f/2.8 GM"},
{6553, "Sony FE 50mm f/1.4 ZA"},
{6553, "Sony FE 85mm f/1.4 GM"}, {6553, "Sony FE 85mm f/1.4 GM"},
{6553, "Sony FE 50mm f/1.8"}, {6553, "Sony FE 50mm f/1.8"},
{6553, "Sony FE 21mm f/2.8 (SEL28F20 + SEL075UWC)"}, {6553, "Sony FE 21mm f/2.8 (SEL28F20 + SEL075UWC)"},
{6553, "Sony FE 16mm f/3.5 Fisheye (SEL28F20 + SEL057FEC)"}, {6553, "Sony FE 16mm f/3.5 Fisheye (SEL28F20 + SEL057FEC)"},
{6553, "Sony FE 70-300mm f/4.5-5.6 G OSS"}, {6553, "Sony FE 70-300mm f/4.5-5.6 G OSS"},
{6553, "Sony FE 70-200mm f/2.8 GM OSS"}, {6553, "Sony FE 70-200mm f/2.8 GM OSS"},
{6553, "Sony FE 70-200mm f/2.8 GM OSS + 1.4X Teleconverter"},
{6553, "Sony FE 70-200mm f/2.8 GM OSS + 2X Teleconverter"},
{6553, "Samyang AF 50mm f/1.4 FE"},
{6553, "Samyang AF 14mm f/2.8 FE"},
{6553, "Sigma 19mm f/2.8 [EX] DN"}, {6553, "Sigma 19mm f/2.8 [EX] DN"},
{6553, "Sigma 30mm f/2.8 [EX] DN"}, {6553, "Sigma 30mm f/2.8 [EX] DN"},
{6553, "Sigma 60mm f/2.8 DN"}, {6553, "Sigma 60mm f/2.8 DN"},
{6553, "Sigma 30mm f/1.4 DC DN | C"}, {6553, "Sigma 30mm f/1.4 DC DN | C 016"},
{6553, "Tamron 18-200mm f/3.5-6.3 Di III VC"}, {6553, "Tamron 18-200mm f/3.5-6.3 Di III VC"},
{6553, "Zeiss Batis 25mm f/2"}, {6553, "Tokina Firin 20mm f/2 FE MF"},
{6553, "Zeiss Batis 85mm f/1.8"},
{6553, "Zeiss Batis 18mm f/2.8"},
{6553, "Zeiss Loxia 21mm f/2.8"},
{6553, "Zeiss Loxia 35mm f/2"},
{6553, "Zeiss Loxia 50mm f/2"},
{6553, "Zeiss Touit 12mm f/2.8"}, {6553, "Zeiss Touit 12mm f/2.8"},
{6553, "Zeiss Touit 32mm f/1.8"}, {6553, "Zeiss Touit 32mm f/1.8"},
{6553, "Zeiss Touit 50mm f/2.8 Macro"}, {6553, "Zeiss Touit 50mm f/2.8 Macro"},
{6553, "Zeiss Batis 25mm f/2"},
{6553, "Zeiss Batis 85mm f/1.8"},
{6553, "Zeiss Batis 18mm f/2.8"},
{6553, "Zeiss Batis 135mm f/2.8"},
{6553, "Zeiss Loxia 50mm f/2"},
{6553, "Zeiss Loxia 35mm f/2"},
{6553, "Zeiss Loxia 21mm f/2.8"},
{6553, "Zeiss Loxia 85mm f/2.4"},
{6553, "Arax MC 35mm f/2.8 Tilt+Shift"}, {6553, "Arax MC 35mm f/2.8 Tilt+Shift"},
{6553, "Arax MC 80mm f/2.8 Tilt+Shift"}, {6553, "Arax MC 80mm f/2.8 Tilt+Shift"},
{6553, "Zenitar MF 16mm f/2.8 Fisheye M42"}, {6553, "Zenitar MF 16mm f/2.8 Fisheye M42"},
@ -870,7 +887,7 @@ public:
{6553, "Pentacon Auto 135mm f/2.8"}, {6553, "Pentacon Auto 135mm f/2.8"},
{6553, "Pentacon Auto 29mm f/2.8"}, {6553, "Pentacon Auto 29mm f/2.8"},
{6553, "Helios 44-2 58mm f/2.0"}, {6553, "Helios 44-2 58mm f/2.0"},
{18688, "Sigma MC-11 Adapter"}, {18688, "Sigma MC-11 SA-E Mount Converter with not-supported Sigma lens"},
{25501, "Minolta AF 50mm f/1.7"}, {25501, "Minolta AF 50mm f/1.7"},
{25511, "Minolta AF 35-70mm f/4 or Other Lens"}, {25511, "Minolta AF 35-70mm f/4 or Other Lens"},
{25511, "Sigma UC AF 28-70mm f/3.5-4.5"}, {25511, "Sigma UC AF 28-70mm f/3.5-4.5"},
@ -993,6 +1010,7 @@ public:
{45871, "Tamron AF 70-210mm f/2.8 SP LD"}, {45871, "Tamron AF 70-210mm f/2.8 SP LD"},
{48128, "Metabones Canon EF Speed Booster Ultra"}, {48128, "Metabones Canon EF Speed Booster Ultra"},
{61184, "Canon EF Adapter"}, {61184, "Canon EF Adapter"},
{65280, "Sigma 16mm f/2.8 Filtermatic Fisheye"},
{65535, "E-Mount, T-Mount, Other Lens or no lens"}, {65535, "E-Mount, T-Mount, Other Lens or no lens"},
{65535, "Sony E 16mm f/2.8"}, {65535, "Sony E 16mm f/2.8"},
{65535, "Sony E 18-55mm f/3.5-5.6 OSS"}, {65535, "Sony E 18-55mm f/3.5-5.6 OSS"},
@ -1006,6 +1024,7 @@ public:
{65535, "Sony E PZ 16-50mm f/3.5-5.6 OSS"}, {65535, "Sony E PZ 16-50mm f/3.5-5.6 OSS"},
{65535, "Sony FE 35mm f/2.8 ZA"}, {65535, "Sony FE 35mm f/2.8 ZA"},
{65535, "Sony FE 24-70mm f/4 ZA OSS"}, {65535, "Sony FE 24-70mm f/4 ZA OSS"},
{65535, "Sony FE 85mm f/1.8"},
{65535, "Sony E 18-200mm f/3.5-6.3 OSS LE"}, {65535, "Sony E 18-200mm f/3.5-6.3 OSS LE"},
{65535, "Sony E 20mm f/2.8"}, {65535, "Sony E 20mm f/2.8"},
{65535, "Sony E 35mm f/1.8 OSS"}, {65535, "Sony E 35mm f/1.8 OSS"},
@ -1016,57 +1035,66 @@ public:
{65535, "Sony FE 55mm f/1.8 ZA"}, {65535, "Sony FE 55mm f/1.8 ZA"},
{65535, "Sony FE 70-200mm f/4 G OSS"}, {65535, "Sony FE 70-200mm f/4 G OSS"},
{65535, "Sony FE 16-35mm f/4 ZA OSS"}, {65535, "Sony FE 16-35mm f/4 ZA OSS"},
{65535, "Sony FE 50mm f/2.8 Macro"},
{65535, "Sony FE 28-70mm f/3.5-5.6 OSS"}, {65535, "Sony FE 28-70mm f/3.5-5.6 OSS"},
{65535, "Sony FE 35mm f/1.4 ZA"}, {65535, "Sony FE 35mm f/1.4 ZA"},
{65535, "Sony FE 24-240mm f/3.5-6.3 OSS"}, {65535, "Sony FE 24-240mm f/3.5-6.3 OSS"},
{65535, "Sony FE 28mm f/2"}, {65535, "Sony FE 28mm f/2"},
{65535, "Sony FE PZ 28-135mm f/4 G OSS"}, {65535, "Sony FE PZ 28-135mm f/4 G OSS"},
{65535, "Sony FE 100mm f/2.8 STF GM OSS"},
{65535, "Sony FE 24-70mm f/2.8 GM"}, {65535, "Sony FE 24-70mm f/2.8 GM"},
{65535, "Sony FE 50mm f/1.4 ZA"},
{65535, "Sony FE 85mm f/1.4 GM"}, {65535, "Sony FE 85mm f/1.4 GM"},
{65535, "Sony FE 85mm f/1.8"},
{65535, "Sony FE 50mm f/1.8"}, {65535, "Sony FE 50mm f/1.8"},
{65535, "Sony FE 21mm f/2.8 (SEL28F20 + SEL075UWC)"}, {65535, "Sony FE 21mm f/2.8 (SEL28F20 + SEL075UWC)"},
{65535, "Sony FE 16mm f/3.5 Fisheye (SEL28F20 + SEL057FEC)"}, {65535, "Sony FE 16mm f/3.5 Fisheye (SEL28F20 + SEL057FEC)"},
{65535, "Sony FE 70-300mm f/4.5-5.6 G OSS"}, {65535, "Sony FE 70-300mm f/4.5-5.6 G OSS"},
{65535, "Sony FE 70-200mm f/2.8 GM OSS"}, {65535, "Sony FE 70-200mm f/2.8 GM OSS"},
{65535, "Sony FE 70-200mm f/2.8 GM OSS + 1.4X Teleconverter"},
{65535, "Sony FE 70-200mm f/2.8 GM OSS + 2X Teleconverter"},
{65535, "Samyang AF 50mm f/1.4 FE"},
{65535, "Samyang AF 14mm f/2.8 FE"},
{65535, "Sigma 19mm f/2.8 [EX] DN"}, {65535, "Sigma 19mm f/2.8 [EX] DN"},
{65535, "Sigma 30mm f/2.8 [EX] DN"}, {65535, "Sigma 30mm f/2.8 [EX] DN"},
{65535, "Sigma 60mm f/2.8 DN"}, {65535, "Sigma 60mm f/2.8 DN"},
{65535, "Sigma 30mm f/1.4 DC DN | C"}, {65535, "Sigma 30mm f/1.4 DC DN | C 016"},
{65535, "Tamron 18-200mm f/3.5-6.3 Di III VC"}, {65535, "Tamron 18-200mm f/3.5-6.3 Di III VC"},
{65535, "Zeiss Batis 25mm f/2"}, {65535, "Tokina Firin 20mm f/2 FE MF"},
{65535, "Zeiss Batis 85mm f/1.8"},
{65535, "Zeiss Batis 18mm f/2.8"},
{65535, "Zeiss Loxia 21mm f/2.8"},
{65535, "Zeiss Loxia 35mm f/2"},
{65535, "Zeiss Loxia 50mm f/2"},
{65535, "Zeiss Touit 12mm f/2.8"}, {65535, "Zeiss Touit 12mm f/2.8"},
{65535, "Zeiss Touit 32mm f/1.8"}, {65535, "Zeiss Touit 32mm f/1.8"},
{65535, "Zeiss Touit 50mm f/2.8 Macro"}, {65535, "Zeiss Touit 50mm f/2.8 Macro"},
{65535, "Zeiss Batis 25mm f/2"},
{65535, "Zeiss Batis 85mm f/1.8"},
{65535, "Zeiss Batis 18mm f/2.8"},
{65535, "Zeiss Batis 135mm f/2.8"},
{65535, "Zeiss Loxia 50mm f/2"},
{65535, "Zeiss Loxia 35mm f/2"},
{65535, "Zeiss Loxia 21mm f/2.8"},
{65535, "Zeiss Loxia 85mm f/2.4"},
{65535, "Arax MC 35mm f/2.8 Tilt+Shift"}, {65535, "Arax MC 35mm f/2.8 Tilt+Shift"},
{65535, "Arax MC 80mm f/2.8 Tilt+Shift"}, {65535, "Arax MC 80mm f/2.8 Tilt+Shift"},
{65535, "Zenitar MF 16mm f/2.8 Fisheye M42"}, {65535, "Zenitar MF 16mm f/2.8 Fisheye M42"},
{65535, "Samyang 500mm Mirror f/8.0"}, {65535, "Samyang 500mm Mirror f/8.0"},
{65535, "Pentacon Auto 135mm f/2.8"}, {65535, "Pentacon Auto 135mm f/2.8"},
{65535, "Pentacon Auto 29mm f/2.8"}, {65535, "Pentacon Auto 29mm f/2.8"},
{65535, "Helios 44-2 58mm f/2.0"} {65535, "Helios 44-2 58mm f/2.0"},
}; };
} }
virtual std::string toString (Tag* t) virtual std::string toString (Tag* t)
{ {
int lensID = t->toInt(); int lensID = t->toInt();
Tag *lensInfoTag = t->getParent()->getRoot()->findTag("LensInfo"); Tag *lensInfoTag = t->getParent()->getRoot()->findTag ("LensInfo");
Tag *apertureTag = t->getParent()->getRoot()->findTag("MaxApertureValue"); Tag *apertureTag = t->getParent()->getRoot()->findTag ("MaxApertureValue");
Tag *focalLengthTag = t->getParent()->getRoot()->findTag("FocalLength"); Tag *focalLengthTag = t->getParent()->getRoot()->findTag ("FocalLength");
double maxApertureAtFocal = 0.; double maxApertureAtFocal = 0.;
double focalLength = 0.; double focalLength = 0.;
if( apertureTag ) { if ( apertureTag ) {
maxApertureAtFocal = pow(2.0, apertureTag->toDouble() / 2.0); maxApertureAtFocal = pow (2.0, apertureTag->toDouble() / 2.0);
} }
if( focalLengthTag ) { if ( focalLengthTag ) {
focalLength = focalLengthTag->toDouble(); focalLength = focalLengthTag->toDouble();
} }
@ -1076,9 +1104,9 @@ public:
liArray = lensInfoTag->toDoubleArray(); liArray = lensInfoTag->toDoubleArray();
} }
std::string retval = guess( lensID, focalLength, maxApertureAtFocal, liArray); std::string retval = guess ( lensID, focalLength, maxApertureAtFocal, liArray);
if(liArray) { if (liArray) {
delete [] liArray; delete [] liArray;
} }
@ -1092,88 +1120,104 @@ class SALensID2Interpreter : public IntLensInterpreter< int >
public: public:
SALensID2Interpreter () SALensID2Interpreter ()
{ {
choices.insert(p_t(0, "Unknown E-mount lens or other lens")); choices.insert (p_t (0, "Unknown E-mount lens or other lens"));
choices.insert(p_t(1, "Sony LA-EA1 Adapter")); choices.insert (p_t (1, "Sony LA-EA1 Adapter"));
choices.insert(p_t(2, "Sony LA-EA2 Adapter")); choices.insert (p_t (2, "Sony LA-EA2 Adapter"));
choices.insert(p_t(3, "Sony LA-EA3 Adapter")); choices.insert (p_t (3, "Sony LA-EA3 Adapter"));
choices.insert(p_t(6, "Sony LA-EA4 Adapter")); choices.insert (p_t (6, "Sony LA-EA4 Adapter"));
choices.insert(p_t(44, "Metabones Canon EF Smart Adapter")); choices.insert (p_t (44, "Metabones Canon EF Smart Adapter"));
choices.insert(p_t(78, "Metabones Canon EF Smart Adapter Mark III or Other Adapter")); choices.insert (p_t (78, "Metabones Canon EF Smart Adapter Mark III or Other Adapter"));
choices.insert(p_t(234, "Metabones Canon EF Smart Adapter Mark IV")); choices.insert (p_t (234, "Metabones Canon EF Smart Adapter Mark IV"));
choices.insert(p_t(239, "Metabones Canon EF Speed Booster")); choices.insert (p_t (239, "Metabones Canon EF Speed Booster"));
choices.insert(p_t(32784, "Sony E 16mm f/2.8")); choices.insert (p_t (32784, "Sony E 16mm f/2.8"));
choices.insert(p_t(32785, "Sony E 18-55mm f/3.5-5.6 OSS")); choices.insert (p_t (32785, "Sony E 18-55mm f/3.5-5.6 OSS"));
choices.insert(p_t(32786, "Sony E 55-210mm f/4.5-6.3 OSS")); choices.insert (p_t (32786, "Sony E 55-210mm f/4.5-6.3 OSS"));
choices.insert(p_t(32787, "Sony E 18-200mm f/3.5-6.3 OSS")); choices.insert (p_t (32787, "Sony E 18-200mm f/3.5-6.3 OSS"));
choices.insert(p_t(32788, "Sony E 30mm f/3.5 Macro")); choices.insert (p_t (32788, "Sony E 30mm f/3.5 Macro"));
choices.insert(p_t(32789, "Sony E 24mm f/1.8 ZA")); choices.insert (p_t (32789, "Sony E 24mm f/1.8 ZA or Samyang AF 50mm f/1.4 FE"));
choices.insert(p_t(32790, "Sony E 50mm f/1.8 OSS")); choices.insert (p_t (32789, "Samyang AF 50mm f/1.4 FE"));
choices.insert(p_t(32791, "Sony E 16-70mm f/4 ZA OSS")); choices.insert (p_t (32790, "Sony E 50mm f/1.8 OSS or Samyang AF 14mm f/2.8 FE"));
choices.insert(p_t(32792, "Sony E 10-18mm f/4 OSS")); choices.insert (p_t (32790, "Samyang AF 14mm f/2.8 FE"));
choices.insert(p_t(32793, "Sony E PZ 16-50mm f/3.5-5.6 OSS")); choices.insert (p_t (32791, "Sony E 16-70mm f/4 ZA OSS"));
choices.insert(p_t(32794, "Sony FE 35mm f/2.8 ZA")); choices.insert (p_t (32792, "Sony E 10-18mm f/4 OSS"));
choices.insert(p_t(32795, "Sony FE 24-70mm f/4 ZA OSS")); choices.insert (p_t (32793, "Sony E PZ 16-50mm f/3.5-5.6 OSS"));
choices.insert(p_t(32796, "Sony FE 85mm f/1.8")); choices.insert (p_t (32794, "Sony FE 35mm f/2.8 ZA"));
choices.insert(p_t(32797, "Sony E 18-200mm f/3.5-6.3 OSS LE")); choices.insert (p_t (32795, "Sony FE 24-70mm f/4 ZA OSS"));
choices.insert(p_t(32798, "Sony E 20mm f/2.8")); choices.insert (p_t (32796, "Sony FE 85mm f/1.8"));
choices.insert(p_t(32799, "Sony E 35mm f/1.8 OSS")); choices.insert (p_t (32797, "Sony E 18-200mm f/3.5-6.3 OSS LE"));
choices.insert(p_t(32800, "Sony E PZ 18-105mm f/4 G OSS")); choices.insert (p_t (32798, "Sony E 20mm f/2.8"));
choices.insert(p_t(32802, "Sony FE 90mm f/2.8 Macro G OSS")); choices.insert (p_t (32799, "Sony E 35mm f/1.8 OSS"));
choices.insert(p_t(32803, "Sony E 18-50mm f/4-5.6")); choices.insert (p_t (32800, "Sony E PZ 18-105mm f/4 G OSS"));
choices.insert(p_t(32807, "Sony E PZ 18-200mm f/3.5-6.3 OSS")); choices.insert (p_t (32802, "Sony FE 90mm f/2.8 Macro G OSS"));
choices.insert(p_t(32808, "Sony FE 55mm f/1.8 ZA")); choices.insert (p_t (32803, "Sony E 18-50mm f/4-5.6"));
choices.insert(p_t(32810, "Sony FE 70-200mm f/4 G OSS")); choices.insert (p_t (32807, "Sony E PZ 18-200mm f/3.5-6.3 OSS"));
choices.insert(p_t(32811, "Sony FE 16-35mm f/4 ZA OSS")); choices.insert (p_t (32808, "Sony FE 55mm f/1.8 ZA"));
choices.insert(p_t(32813, "Sony FE 28-70mm f/3.5-5.6 OSS")); choices.insert (p_t (32810, "Sony FE 70-200mm f/4 G OSS"));
choices.insert(p_t(32814, "Sony FE 35mm f/1.4 ZA")); choices.insert (p_t (32811, "Sony FE 16-35mm f/4 ZA OSS"));
choices.insert(p_t(32815, "Sony FE 24-240mm f/3.5-6.3 OSS")); choices.insert (p_t (32812, "Sony FE 50mm f/2.8 Macro"));
choices.insert(p_t(32816, "Sony FE 28mm f/2")); choices.insert (p_t (32813, "Sony FE 28-70mm f/3.5-5.6 OSS"));
choices.insert(p_t(32817, "Sony FE PZ 28-135mm f/4 G OSS")); choices.insert (p_t (32814, "Sony FE 35mm f/1.4 ZA"));
choices.insert(p_t(32821, "Sony FE 24-70mm f/2.8 GM")); choices.insert (p_t (32815, "Sony FE 24-240mm f/3.5-6.3 OSS"));
choices.insert(p_t(32823, "Sony FE 85mm f/1.4 GM")); choices.insert (p_t (32816, "Sony FE 28mm f/2"));
choices.insert(p_t(32824, "Sony FE 50mm f/1.8")); choices.insert (p_t (32817, "Sony FE PZ 28-135mm f/4 G OSS"));
choices.insert(p_t(32826, "Sony FE 21mm f/2.8 (SEL28F20 + SEL075UWC)")); choices.insert (p_t (32819, "Sony FE 100mm f/2.8 STF GM OSS"));
choices.insert(p_t(32827, "Sony FE 16mm f/3.5 Fisheye (SEL28F20 + SEL057FEC)")); choices.insert (p_t (32821, "Sony FE 24-70mm f/2.8 GM"));
choices.insert(p_t(32828, "Sony FE 70-300mm f/4.5-5.6 G OSS")); choices.insert (p_t (32822, "Sony FE 50mm f/1.4 ZA"));
choices.insert(p_t(32830, "Sony FE 70-200mm f/2.8 GM OSS")); choices.insert (p_t (32823, "Sony FE 85mm f/1.4 GM"));
choices.insert(p_t(49201, "Zeiss Touit 12mm f/2.8")); choices.insert (p_t (32824, "Sony FE 50mm f/1.8"));
choices.insert(p_t(49202, "Zeiss Touit 32mm f/1.8")); choices.insert (p_t (32826, "Sony FE 21mm f/2.8 (SEL28F20 + SEL075UWC)"));
choices.insert(p_t(49203, "Zeiss Touit 50mm f/2.8 Macro")); choices.insert (p_t (32827, "Sony FE 16mm f/3.5 Fisheye (SEL28F20 + SEL057FEC)"));
choices.insert(p_t(49216, "Zeiss Batis 25mm f/2")); choices.insert (p_t (32828, "Sony FE 70-300mm f/4.5-5.6 G OSS"));
choices.insert(p_t(49217, "Zeiss Batis 85mm f/1.8")); choices.insert (p_t (32830, "Sony FE 70-200mm f/2.8 GM OSS"));
choices.insert(p_t(49218, "Zeiss Batis 18mm f/2.8")); choices.insert (p_t (33002, "Sigma 85mm f/1.4 DG HSM | A 016 (+ Metabones Ver.50)"));
choices.insert(p_t(49232, "Zeiss Loxia 50mm f/2")); choices.insert (p_t (33072, "Sony FE 70-200mm f/2.8 GM OSS + 1.4X Teleconverter"));
choices.insert(p_t(49233, "Zeiss Loxia 35mm f/2")); choices.insert (p_t (33073, "Sony FE 70-200mm f/2.8 GM OSS + 2X Teleconverter"));
choices.insert(p_t(49234, "Zeiss Loxia 21mm f/2.8")); choices.insert (p_t (33076, "Sony FE 100mm f/2.8 STF GM OSS (macro mode)"));
choices.insert(p_t(50480, "Sigma 30mm f/1.4 DC DN | C 016")); choices.insert (p_t (49201, "Zeiss Touit 12mm f/2.8"));
choices.insert(p_t(50481, "Sigma 50mm f/1.4 DG HSM | A 014 + MC-11")); choices.insert (p_t (49202, "Zeiss Touit 32mm f/1.8"));
choices.insert(p_t(50482, "Sigma 18-300mm f/3.5-6.3 DC MACRO OS HSM | C 014 + MC-11")); choices.insert (p_t (49203, "Zeiss Touit 50mm f/2.8 Macro"));
choices.insert(p_t(50483, "Sigma 18-35mm f/1.8 DC HSM | A 013 + MC-11")); choices.insert (p_t (49216, "Zeiss Batis 25mm f/2"));
choices.insert(p_t(50484, "Sigma 24-35mm f/2 DG HSM | A 015 + MC-11")); choices.insert (p_t (49217, "Zeiss Batis 85mm f/1.8"));
choices.insert(p_t(50486, "Sigma 150-600mm f/5-6.3 DG OS HSM | C 015 + MC-11")); choices.insert (p_t (49218, "Zeiss Batis 18mm f/2.8"));
choices.insert(p_t(50487, "Sigma 20mm f/1.4 DG HSM | A 015 + MC-11")); choices.insert (p_t (49219, "Zeiss Batis 135mm f/2.8"));
choices.insert(p_t(50488, "Sigma 35mm f/1.4 DG HSM | A 012 + MC-11")); choices.insert (p_t (49232, "Zeiss Loxia 50mm f/2"));
choices.insert(p_t(50489, "Sigma 150-600mm f/5-6.3 DG OS HSM | S 014 + MC-11")); choices.insert (p_t (49233, "Zeiss Loxia 35mm f/2"));
choices.insert(p_t(50490, "Sigma 120-300mm f/2.8 DG OS HSM | S 013 + MC-11")); choices.insert (p_t (49234, "Zeiss Loxia 21mm f/2.8"));
choices.insert(p_t(50492, "Sigma 24-105mm f/4 DG OS HSM | A 013 + MC-11")); choices.insert (p_t (49235, "Zeiss Loxia 85mm f/2.4"));
choices.insert(p_t(50493, "Sigma 17-70mm f/2.8-4 DC MACRO OS HSM | C 013 + MC-11")); choices.insert (p_t (50480, "Sigma 30mm f/1.4 DC DN | C 016"));
choices.insert(p_t(50495, "Sigma 50-100mm f/1.8 DC HSM | A 016 + MC-11")); choices.insert (p_t (50481, "Sigma 50mm f/1.4 DG HSM | A 014 + MC-11"));
choices.insert (p_t (50482, "Sigma 18-300mm f/3.5-6.3 DC MACRO OS HSM | C 014 + MC-11"));
choices.insert (p_t (50483, "Sigma 18-35mm f/1.8 DC HSM | A 013 + MC-11"));
choices.insert (p_t (50484, "Sigma 24-35mm f/2 DG HSM | A 015 + MC-11"));
choices.insert (p_t (50486, "Sigma 150-600mm f/5-6.3 DG OS HSM | C 015 + MC-11"));
choices.insert (p_t (50487, "Sigma 20mm f/1.4 DG HSM | A 015 + MC-11"));
choices.insert (p_t (50488, "Sigma 35mm f/1.4 DG HSM | A 012 + MC-11"));
choices.insert (p_t (50489, "Sigma 150-600mm f/5-6.3 DG OS HSM | S 014 + MC-11"));
choices.insert (p_t (50490, "Sigma 120-300mm f/2.8 DG OS HSM | S 013 + MC-11"));
choices.insert (p_t (50492, "Sigma 24-105mm f/4 DG OS HSM | A 013 + MC-11"));
choices.insert (p_t (50493, "Sigma 17-70mm f/2.8-4 DC MACRO OS HSM | C 013 + MC-11"));
choices.insert (p_t (50495, "Sigma 50-100mm f/1.8 DC HSM | A 016 + MC-11"));
choices.insert (p_t (50992, "Voigtlander SUPER WIDE-HELIAR 15mm f/4.5 III"));
choices.insert (p_t (50993, "Voigtlander HELIAR-HYPER WIDE 10mm f/5.6"));
choices.insert (p_t (50994, "Voigtlander ULTRA WIDE-HELIAR 12mm f/5.6 III"));
choices.insert (p_t (50996, "Voigtlander NOKTON 40mm f/1.2 Aspherical"));
choices.insert (p_t (51505, "Samyang AF 14mm f/2.8 FE"));
} }
virtual std::string toString (Tag* t) virtual std::string toString (Tag* t)
{ {
int lensID = t->toInt(); int lensID = t->toInt();
Tag *lensInfoTag = t->getParent()->getRoot()->findTag("LensInfo"); Tag *lensInfoTag = t->getParent()->getRoot()->findTag ("LensInfo");
Tag *apertureTag = t->getParent()->getRoot()->findTag("MaxApertureValue"); Tag *apertureTag = t->getParent()->getRoot()->findTag ("MaxApertureValue");
Tag *focalLengthTag = t->getParent()->getRoot()->findTag("FocalLength"); Tag *focalLengthTag = t->getParent()->getRoot()->findTag ("FocalLength");
double maxApertureAtFocal = 0.; double maxApertureAtFocal = 0.;
double focalLength = 0.; double focalLength = 0.;
if( apertureTag ) { if ( apertureTag ) {
maxApertureAtFocal = pow(2.0, apertureTag->toDouble() / 2.0); maxApertureAtFocal = pow (2.0, apertureTag->toDouble() / 2.0);
} }
if( focalLengthTag ) { if ( focalLengthTag ) {
focalLength = focalLengthTag->toDouble(); focalLength = focalLengthTag->toDouble();
} }
@ -1183,9 +1227,9 @@ public:
liArray = lensInfoTag->toDoubleArray(); liArray = lensInfoTag->toDoubleArray();
} }
std::string retval = guess( lensID, focalLength, maxApertureAtFocal, liArray); std::string retval = guess ( lensID, focalLength, maxApertureAtFocal, liArray);
if(liArray) { if (liArray) {
delete [] liArray; delete [] liArray;
} }
@ -1958,7 +2002,7 @@ public:
{ {
double a = t->toDouble(); double a = t->toDouble();
if(a > 0) { if (a > 0) {
char buffer[32]; char buffer[32];
sprintf (buffer, "%.4f", a); sprintf (buffer, "%.4f", a);
return buffer; return buffer;
@ -1979,8 +2023,8 @@ public:
} }
// Decode the value // Decode the value
if(a > 0) { if (a > 0) {
return pow(2., 6. - (double(a) / 8.)); return pow (2., 6. - (double (a) / 8.));
} else { } else {
return 0.; return 0.;
} }
@ -2001,8 +2045,8 @@ public:
} }
// Decode the value // Decode the value
if(a) { if (a) {
return int(powf(2.f, 6.f - (float(a) / 8.f)) + 0.5f); return int (powf (2.f, 6.f - (float (a) / 8.f)) + 0.5f);
} else { } else {
return 0; return 0;
} }
@ -2016,9 +2060,9 @@ public:
SAFNumberInterpreter () {} SAFNumberInterpreter () {}
virtual std::string toString (Tag* t) virtual std::string toString (Tag* t)
{ {
double a = double(t->toDouble()); double a = double (t->toDouble());
if(a) { if (a) {
char buffer[32]; char buffer[32];
sprintf (buffer, "%.1f", a / 100. ); sprintf (buffer, "%.1f", a / 100. );
return buffer; return buffer;
@ -2039,8 +2083,8 @@ public:
} }
// Decode the value // Decode the value
if(a > 0) { if (a > 0) {
return pow(2., (double(a) / 8. - 1.) / 2.); return pow (2., (double (a) / 8. - 1.) / 2.);
} else { } else {
return 0.; return 0.;
} }
@ -2061,8 +2105,8 @@ public:
} }
// Decode the value // Decode the value
if(a) { if (a) {
return int(powf(2.f, (float(a) / 8.f - 1.f) / 2.f) + 0.5f); return int (powf (2.f, (float (a) / 8.f - 1.f) / 2.f) + 0.5f);
} else { } else {
return 0; return 0;
} }
@ -2078,7 +2122,7 @@ public:
{ {
int a = t->toInt(); int a = t->toInt();
if(a) { if (a) {
char buffer[32]; char buffer[32];
sprintf (buffer, "%d", a ); sprintf (buffer, "%d", a );
return buffer; return buffer;
@ -2102,8 +2146,8 @@ public:
} }
// Decode the value // Decode the value
if(a && a != 254) { // 254 = 'Auto' for CameraSettings3, but we might say the same for CameraSettings & CameraSettings2 (?) if (a && a != 254) { // 254 = 'Auto' for CameraSettings3, but we might say the same for CameraSettings & CameraSettings2 (?)
return int(expf((double(a) / 8.f - 6.f) * logf(2.f)) * 100.f + 0.5f); return int (expf ((double (a) / 8.f - 6.f) * logf (2.f)) * 100.f + 0.5f);
} else { } else {
return 0; return 0;
} }
@ -2127,7 +2171,7 @@ public:
// Get the value // Get the value
int a = t->getValue()[ofs]; int a = t->getValue()[ofs];
// Decode the value // Decode the value
return (double(a) - 128.) / 24.; return (double (a) - 128.) / 24.;
} }
}; };
SAExposureCompSetInterpreter saExposureCompSetInterpreter; SAExposureCompSetInterpreter saExposureCompSetInterpreter;

View File

@ -332,7 +332,7 @@ public:
char buffer[32]; char buffer[32];
double v = t->toDouble(); double v = t->toDouble();
if( v < 0. || v > 1000. ) { if ( v < 0. || v > 1000. ) {
return "undef"; return "undef";
} }
@ -349,9 +349,9 @@ public:
virtual std::string toString (Tag* t) virtual std::string toString (Tag* t)
{ {
char buffer[32]; char buffer[32];
double v = pow(2.0, t->toDouble() / 2.0); double v = pow (2.0, t->toDouble() / 2.0);
if( v < 0. || v > 1000. ) { if ( v < 0. || v > 1000. ) {
return "undef"; return "undef";
} }
@ -370,7 +370,7 @@ public:
char buffer[32]; char buffer[32];
double v = t->toDouble(); double v = t->toDouble();
if( v < -1000. || v > 1000. ) { if ( v < -1000. || v > 1000. ) {
return "undef"; return "undef";
} }
@ -429,7 +429,7 @@ public:
char buffer[32]; char buffer[32];
double v = t->toDouble(); double v = t->toDouble();
if( v > 1000000. || v < 0 ) { if ( v > 1000000. || v < 0 ) {
return "undef"; return "undef";
} }
@ -446,20 +446,22 @@ public:
virtual std::string toString (Tag* t) virtual std::string toString (Tag* t)
{ {
int count = t->getCount(); int count = t->getCount();
if(count <= 8) {
if (count <= 8) {
return std::string(); return std::string();
} }
count = std::min(count, 65535); // limit to 65535 chars to avoid crashes in case of corrupted metadata
count = std::min (count, 65535); // limit to 65535 chars to avoid crashes in case of corrupted metadata
char *buffer = new char[count - 7]; char *buffer = new char[count - 7];
if (!memcmp((char*)t->getValue(), "ASCII\0\0\0", 8)) { if (!memcmp ((char*)t->getValue(), "ASCII\0\0\0", 8)) {
strncpy (buffer, (char*)t->getValue() + 8, count - 8); strncpy (buffer, (char*)t->getValue() + 8, count - 8);
buffer[count - 8] = '\0'; buffer[count - 8] = '\0';
} else { } else {
buffer[0] = 0; buffer[0] = 0;
} }
std::string retVal(buffer); std::string retVal (buffer);
delete [] buffer; delete [] buffer;
return retVal; return retVal;
} }
@ -483,8 +485,8 @@ public:
char colors[] = "RGB"; char colors[] = "RGB";
char buffer[1024]; char buffer[1024];
for( int i = 0; i < t->getCount(); i++) { for ( int i = 0; i < t->getCount(); i++) {
unsigned char c = t->toInt(i, BYTE); unsigned char c = t->toInt (i, BYTE);
buffer[i] = c < 3 ? colors[c] : ' '; buffer[i] = c < 3 ? colors[c] : ' ';
} }

View File

@ -1,9 +1,7 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# This Bash4 script generates lens ID lists for rtexif/*.cc files using # This Bash4 script generates lens ID and other parameter lists for rtexif/*.cc
# the exiftool version installed on the host system, so make sure you have # files using ExifTool. It uses xmlstarlet to parse ExifTool's output.
# the latest version of exiftool installed before running this script.
# It uses xmlstarlet to parse exiftool's output so make sure you have that.
# #
# Run the script from the project root: # Run the script from the project root:
# ./tools/generateLensList # ./tools/generateLensList
@ -13,50 +11,51 @@
# Blame DrSlony # Blame DrSlony
# Please report bugs or enhancements to https://github.com/Beep6581/RawTherapee # Please report bugs or enhancements to https://github.com/Beep6581/RawTherapee
hash exiftool 2>/dev/null || { echo >&2 "Exiftool not found, install it first."; exit 1; } et="$HOME/programs/code-exiftool/exiftool"
hash "$et" 2>/dev/null || { echo >&2 "ExifTool not found, install it first."; exit 1; }
hash xmlstarlet 2>/dev/null || { echo >&2 "XMLStarlet not found, install it first."; exit 1; } hash xmlstarlet 2>/dev/null || { echo >&2 "XMLStarlet not found, install it first."; exit 1; }
unset cam cams unset cam cams
cams=("canon" "nikon" "olympus" "pentax" "sony")
tmpdir="/tmp/rt-generateLensList" tmpdir="/tmp/rt-generateLensList"
head -n 15 "$0" | tail -n 14 printf '%s\n' "ExifTool version: $("$et" -ver)" "" "XMLStarlet version: $(xmlstarlet --version)" | sed 's/^/# /'
printf '%s\n' "exiftool version: $(exiftool -ver)" "" "XMLStarlet version: $(xmlstarlet --version)" | sed 's/^/# /'
if [[ -d ${tmpdir} ]]; then if [[ -d ${tmpdir} ]]; then
printf '%s\n' "" "Removing temp folder: $tmpdir" printf '%s\n' "" "Must remove temp folder from previous run: $tmpdir"
rm -rvI "$tmpdir" || exit 1 rm -rvI "$tmpdir" || exit 1
fi fi
mkdir -p "$tmpdir" || { printf '%s\n' "Error creating $tmpdir" ""; exit 1; } mkdir -p "$tmpdir" || { printf '%s\n' "Error creating $tmpdir" ""; exit 1; }
echo echo
for cam in "${cams[@]}"; do # Canon
if [[ "$cam" != nikon ]]; then printf '%s\n' "Saving ${tmpdir}/canon"
printf '%s\n' "Saving ${tmpdir}/${cam}" xmlstarlet sel -T -t -m "taginfo/table/tag[@name='LensType']/values/key" -v "concat(@id,' ',val)" -n < <("$et" -listx -canon:all) | sort -fuV > "${tmpdir}/canon"
xmlstarlet sel -T -t -m "taginfo/table/tag[@name='LensType']/values/key" -v "concat(@id,' ',val)" -n < <(exiftool -listx -"$cam":all) > "${tmpdir}/cam" || { printf '%s\n' "Saving failed: ${tmpdir}/cam"; exit 1; } sed -r -i -e '/-1\tn\/a/d' -e 's/([0-9]+)[0-9.]*\t/\1, "/' -e 's/^/ choices.insert(p_t(/' -e 's/$/"));/' -e 's| F/([0-9]+)| f/\1|' "${tmpdir}/canon"
sort -fuV "${tmpdir}/cam" > "${tmpdir}/${cam}" # xmlstarlet sel -T -t -m "taginfo/table/tag[@name='EasyMode']/values/key" -v "concat(@id,' ',val)" -n < <(exiftool -listx -canon:all) | sed -r -e '/-1\tn\/a/d' -e 's/([0-9]+)[0-9.]*\t/\1] = "/' -e 's/^/ choices[/' -e 's/$/";/'
rm -f "${tmpdir}/cam"
fi
case $cam in
canon) sed -r -i -e '/-1\tn\/a/d' -e 's/([0-9]+)[0-9.]*\t/\1, "/' -e 's/^/ choices.insert(p_t(/' -e 's/$/"));/' -e 's| F/([0-9]+)| f/\1|' "${tmpdir}/canon" ;;
nikon)
# Nikon LensIDs are composite tags
printf '%s\n' "Saving ${tmpdir}/nikon"
xmlstarlet sel -T -t -m "taginfo/table/tag[@name='LensID']/values/key" -v "concat(@id,' ',val)" -n < <(exiftool -listx -composite:all) > "${tmpdir}/nikon" || { printf '%s\n' "Saving failed: ${tmpdir}/nikon"; exit 1; }
sed -r -i -e '/^... /d' -e 's/^/ lenses["/' -e 's/([A-F0-9]+)[A-F0-9.]*\t/\1"] = "/' -e 's/$/";/' -e 's|(.* ")(.*) F([0-9]+)|\1\2 f/\3|' -e 's| F/([0-9]+)| f/\1|' "${tmpdir}/nikon"
;;
olympus) sed -r -i -e '/0 00 00\tNone/d' -e 's/^/ lenses["0/' -e 's/\t/"] = "/' -e 's/$/";/' -e 's| F([0-9]+)| f/\1|g' "${tmpdir}/olympus" ;;
pentax) sed -r -i -e 's/^/ choices.insert(p_t(256 * /' -e 's/([0-9]+) ([0-9]+)([0-9.]*)/\1 + \2/' -e 's/\t/, "/' -e 's/$/"));/' -e 's| F([0-9]+)| f/\1|' "${tmpdir}/pentax" ;;
sony)
# Sony has more lenses under the LensType2 tag
printf '%s\n' "Saving ${tmpdir}/sony-lenstype2"
xmlstarlet sel -T -t -m "taginfo/table/tag[@name='LensType2']/values/key" -v "concat(@id,' ',val)" -n < <(exiftool -listx -sony:all) > "${tmpdir}/cam" || { printf '%s\n' "Saving failed: ${tmpdir}/cam"; exit 1; }
sort -fuV "${tmpdir}/cam" > "${tmpdir}/sony-lenstype2"
rm -f "${tmpdir}/cam"
sed -r -i -e '/255\tTamron Lens (255)/d' -e 's/([0-9]+)[0-9.]*\t/\1, "/' -e 's/^/ choices.insert(p_t(/' -e 's/$/"));/' -e 's| F([0-9]+)| f/\1|g' "${tmpdir}/sony" "${tmpdir}/sony-lenstype2"
;;
esac
done # Nikon LensIDs are composite tags
printf '%s\n' "Saving ${tmpdir}/nikon"
xmlstarlet sel -T -t -m "taginfo/table/tag[@name='LensID']/values/key" -v "concat(@id,' ',val)" -n < <("$et" -listx -composite:all) > "${tmpdir}/nikon"
sed -r -i -e '/^... /d' -e 's/^/ {"/' -e 's/([A-F0-9]+)[A-F0-9.]*\t/\1", "/' -e 's/$/"},/' -e 's|(.* ")(.*) F([0-9]+)|\1\2 f/\3|' -e 's| F/([0-9]+)| f/\1|' "${tmpdir}/nikon"
# Olympus
printf '%s\n' "Saving ${tmpdir}/olympus"
xmlstarlet sel -T -t -m "taginfo/table/tag[@name='LensType']/values/key" -v "concat(@id,' ',val)" -n < <("$et" -listx -olympus:all) | sort -fuV > "${tmpdir}/olympus"
sed -r -i -e '/0 00 00\tNone/d' -e 's/^/ lenses["0/' -e 's/\t/"] = "/' -e 's/$/";/' -e 's| F([0-9]+)| f/\1|g' "${tmpdir}/olympus"
# Pentax
printf '%s\n' "Saving ${tmpdir}/pentax"
xmlstarlet sel -T -t -m "taginfo/table/tag[@name='LensType']/values/key" -v "concat(@id,' ',val)" -n < <("$et" -listx -pentax:all) | sort -fuV > "${tmpdir}/pentax"
sed -r -i -e 's/^/ choices.insert(p_t(256 * /' -e 's/([0-9]+) ([0-9]+)([0-9.]*)/\1 + \2/' -e 's/\t/, "/' -e 's/$/"));/' -e 's| F([0-9]+)| f/\1|' "${tmpdir}/pentax"
# Sony
printf '%s\n' "Saving ${tmpdir}/sony"
xmlstarlet sel -T -t -m "taginfo/table/tag[@name='LensType']/values/key" -v "concat(@id,' ',val)" -n < <("$et" -listx -sony:all) | sort -fuV > "${tmpdir}/sony"
# Sony has more lenses under the LensType2 tag
printf '%s\n' "Saving ${tmpdir}/sony-lenstype2"
xmlstarlet sel -T -t -m "taginfo/table/tag[@name='LensType2']/values/key" -v "concat(@id,' ',val)" -n < <("$et" -listx -sony:all) | sort -fuV > "${tmpdir}/sony-lenstype2"
sed -r -i -e 's/^/ {/' -e 's/([0-9]+)[0-9.]*\t/\1, "/' -e 's/$/"},/' -e 's| F([0-9]+)| f/\1|g' "${tmpdir}/sony"
sed -r -i -e '/255\tTamron Lens (255)/d' -e 's/([0-9]+)[0-9.]*\t/\1, "/' -e 's/^/ choices.insert(p_t(/' -e 's/$/"));/' -e 's| F([0-9]+)| f/\1|g' "${tmpdir}/sony-lenstype2"