add ExposureProgram, LightSource and SubjectArea tags
This commit is contained in:
42
TinyEXIF.cpp
42
TinyEXIF.cpp
@@ -148,6 +148,8 @@ public:
|
|||||||
uint32_t GetData() const { return parse32(buf + offs + 8, alignIntel); }
|
uint32_t GetData() const { return parse32(buf + offs + 8, alignIntel); }
|
||||||
uint32_t GetSubIFD() const { return tiff_header_start + GetData(); }
|
uint32_t GetSubIFD() const { return tiff_header_start + GetData(); }
|
||||||
|
|
||||||
|
bool IsShort() const { return format == 3; }
|
||||||
|
bool IsLong() const { return format == 4; }
|
||||||
bool IsRational() const { return format == 5 || format == 10; }
|
bool IsRational() const { return format == 5 || format == 10; }
|
||||||
|
|
||||||
bool Fetch(std::string& val) const {
|
bool Fetch(std::string& val) const {
|
||||||
@@ -163,13 +165,19 @@ public:
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
bool Fetch(uint16_t& val) const {
|
bool Fetch(uint16_t& val) const {
|
||||||
if (format != 3)
|
if (!IsShort())
|
||||||
return false;
|
return false;
|
||||||
val = parse16(buf + offs + 8, alignIntel);
|
val = parse16(buf + offs + 8, alignIntel);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
bool Fetch(uint16_t& val, uint32_t idx) const {
|
||||||
|
if (!IsShort() || length <= idx)
|
||||||
|
return false;
|
||||||
|
val = parse16(buf + GetSubIFD() + idx*2, alignIntel);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
bool Fetch(uint32_t& val) const {
|
bool Fetch(uint32_t& val) const {
|
||||||
if (format != 4)
|
if (!IsLong())
|
||||||
return false;
|
return false;
|
||||||
val = parse32(buf + offs + 8, alignIntel);
|
val = parse32(buf + offs + 8, alignIntel);
|
||||||
return true;
|
return true;
|
||||||
@@ -528,6 +536,11 @@ int EXIFInfo::parseFromEXIFSegment(const uint8_t* buf, unsigned len) {
|
|||||||
parser.Fetch(FNumber);
|
parser.Fetch(FNumber);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 0x8822:
|
||||||
|
// Exposure Program
|
||||||
|
parser.Fetch(ExposureProgram);
|
||||||
|
break;
|
||||||
|
|
||||||
case 0x8827:
|
case 0x8827:
|
||||||
// ISO Speed Rating
|
// ISO Speed Rating
|
||||||
parser.Fetch(ISOSpeedRatings);
|
parser.Fetch(ISOSpeedRatings);
|
||||||
@@ -568,8 +581,18 @@ int EXIFInfo::parseFromEXIFSegment(const uint8_t* buf, unsigned len) {
|
|||||||
parser.Fetch(SubjectDistance);
|
parser.Fetch(SubjectDistance);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 0x9207:
|
||||||
|
// Metering mode
|
||||||
|
parser.Fetch(MeteringMode);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 0x9208:
|
||||||
|
// Light source
|
||||||
|
parser.Fetch(LightSource);
|
||||||
|
break;
|
||||||
|
|
||||||
case 0x9209:
|
case 0x9209:
|
||||||
// Flash used
|
// Flash info
|
||||||
parser.Fetch(Flash);
|
parser.Fetch(Flash);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -578,9 +601,13 @@ int EXIFInfo::parseFromEXIFSegment(const uint8_t* buf, unsigned len) {
|
|||||||
parser.Fetch(FocalLength);
|
parser.Fetch(FocalLength);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 0x9207:
|
case 0x9214:
|
||||||
// Metering mode
|
// Subject area
|
||||||
parser.Fetch(MeteringMode);
|
if (parser.IsShort() && parser.GetLength() > 1) {
|
||||||
|
SubjectArea.resize(parser.GetLength());
|
||||||
|
for (uint32_t i=0; i<parser.GetLength(); ++i)
|
||||||
|
parser.Fetch(SubjectArea[i], i);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 0x9291:
|
case 0x9291:
|
||||||
@@ -883,6 +910,7 @@ void EXIFInfo::clear() {
|
|||||||
BitsPerSample = 0;
|
BitsPerSample = 0;
|
||||||
ExposureTime = 0;
|
ExposureTime = 0;
|
||||||
FNumber = 0;
|
FNumber = 0;
|
||||||
|
ExposureProgram = 0;
|
||||||
ISOSpeedRatings = 0;
|
ISOSpeedRatings = 0;
|
||||||
ShutterSpeedValue = 0;
|
ShutterSpeedValue = 0;
|
||||||
ApertureValue = 0;
|
ApertureValue = 0;
|
||||||
@@ -892,7 +920,9 @@ void EXIFInfo::clear() {
|
|||||||
FocalLength = 0;
|
FocalLength = 0;
|
||||||
Flash = 0;
|
Flash = 0;
|
||||||
MeteringMode = 0;
|
MeteringMode = 0;
|
||||||
|
LightSource = 0;
|
||||||
ProjectionType = 0;
|
ProjectionType = 0;
|
||||||
|
SubjectArea.clear();
|
||||||
|
|
||||||
// LensInfo
|
// LensInfo
|
||||||
LensInfo.FocalLengthMax = 0;
|
LensInfo.FocalLengthMax = 0;
|
||||||
|
|||||||
59
TinyEXIF.h
59
TinyEXIF.h
@@ -35,6 +35,7 @@
|
|||||||
#define __TINYEXIF_H__
|
#define __TINYEXIF_H__
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
# ifdef TINYEXIF_EXPORT
|
# ifdef TINYEXIF_EXPORT
|
||||||
@@ -124,6 +125,16 @@ public:
|
|||||||
std::string Copyright; // File copyright information
|
std::string Copyright; // File copyright information
|
||||||
double ExposureTime; // Exposure time in seconds
|
double ExposureTime; // Exposure time in seconds
|
||||||
double FNumber; // F/stop
|
double FNumber; // F/stop
|
||||||
|
uint16_t ExposureProgram; // Exposure program
|
||||||
|
// 0: not defined
|
||||||
|
// 1: manual
|
||||||
|
// 2: normal program
|
||||||
|
// 3: aperture priority
|
||||||
|
// 4: shutter priority
|
||||||
|
// 5: creative program
|
||||||
|
// 6: action program
|
||||||
|
// 7: portrait mode
|
||||||
|
// 8: landscape mode
|
||||||
uint16_t ISOSpeedRatings; // ISO speed
|
uint16_t ISOSpeedRatings; // ISO speed
|
||||||
double ShutterSpeedValue; // Shutter speed (reciprocal of exposure time)
|
double ShutterSpeedValue; // Shutter speed (reciprocal of exposure time)
|
||||||
double ApertureValue; // The lens aperture
|
double ApertureValue; // The lens aperture
|
||||||
@@ -131,17 +142,61 @@ public:
|
|||||||
double ExposureBiasValue; // Exposure bias value in EV
|
double ExposureBiasValue; // Exposure bias value in EV
|
||||||
double SubjectDistance; // Distance to focus point in meters
|
double SubjectDistance; // Distance to focus point in meters
|
||||||
double FocalLength; // Focal length of lens in millimeters
|
double FocalLength; // Focal length of lens in millimeters
|
||||||
uint16_t Flash; // 0: no flash, >0: flash used
|
uint16_t Flash; // Flash info
|
||||||
|
// Flash used (Flash&1)
|
||||||
|
// 0: no flash, >0: flash used
|
||||||
|
// Flash returned light status ((Flash & 6) >> 1)
|
||||||
|
// 0: no strobe return detection function
|
||||||
|
// 1: reserved
|
||||||
|
// 2: strobe return light not detected
|
||||||
|
// 3: strobe return light detected
|
||||||
|
// Flash mode ((Flash & 24) >> 3)
|
||||||
|
// 0: unknown
|
||||||
|
// 1: compulsory flash firing
|
||||||
|
// 2: compulsory flash suppression
|
||||||
|
// 3: auto mode
|
||||||
|
// Flash function ((Flash & 32) >> 5)
|
||||||
|
// 0: flash function present, >0: no flash function
|
||||||
|
// Flash red-eye ((Flash & 64) >> 6)
|
||||||
|
// 0: no red-eye reduction mode or unknown, >0: red-eye reduction supported
|
||||||
uint16_t MeteringMode; // Metering mode
|
uint16_t MeteringMode; // Metering mode
|
||||||
|
// 0: unknown
|
||||||
// 1: average
|
// 1: average
|
||||||
// 2: center weighted average
|
// 2: center weighted average
|
||||||
// 3: spot
|
// 3: spot
|
||||||
// 4: multi-spot
|
// 4: multi-spot
|
||||||
// 5: multi-segment
|
// 5: pattern
|
||||||
|
// 6: partial
|
||||||
|
uint16_t LightSource; // Kind of light source
|
||||||
|
// 0: unknown
|
||||||
|
// 1: daylight
|
||||||
|
// 2: fluorescent
|
||||||
|
// 3: tungsten (incandescent light)
|
||||||
|
// 4: flash
|
||||||
|
// 9: fine weather
|
||||||
|
// 10: cloudy weather
|
||||||
|
// 11: shade
|
||||||
|
// 12: daylight fluorescent (D 5700 - 7100K)
|
||||||
|
// 13: day white fluorescent (N 4600 - 5400K)
|
||||||
|
// 14: cool white fluorescent (W 3900 - 4500K)
|
||||||
|
// 15: white fluorescent (WW 3200 - 3700K)
|
||||||
|
// 17: standard light A
|
||||||
|
// 18: standard light B
|
||||||
|
// 19: standard light C
|
||||||
|
// 20: D55
|
||||||
|
// 21: D65
|
||||||
|
// 22: D75
|
||||||
|
// 23: D50
|
||||||
|
// 24: ISO studio tungsten
|
||||||
uint16_t ProjectionType; // Projection type
|
uint16_t ProjectionType; // Projection type
|
||||||
// 0: unknown projection
|
// 0: unknown projection
|
||||||
// 1: perspective projection
|
// 1: perspective projection
|
||||||
// 2: equirectangular/spherical projection
|
// 2: equirectangular/spherical projection
|
||||||
|
std::vector<uint16_t> SubjectArea; // Location and area of the main subject in the overall scene expressed in relation to the upper left as origin, prior to rotation
|
||||||
|
// 0: unknown
|
||||||
|
// 2: location of the main subject as coordinates (first value is the X coordinate and second is the Y coordinate)
|
||||||
|
// 3: area of the main subject as a circle (first value is the center X coordinate, second is the center Y coordinate, and third is the diameter)
|
||||||
|
// 4: area of the main subject as a rectangle (first value is the center X coordinate, second is the center Y coordinate, third is the width of the area, and fourth is the height of the area)
|
||||||
struct LensInfo_t { // Lens information
|
struct LensInfo_t { // Lens information
|
||||||
double FStopMin; // Min aperture (f-stop)
|
double FStopMin; // Min aperture (f-stop)
|
||||||
double FStopMax; // Max aperture (f-stop)
|
double FStopMax; // Max aperture (f-stop)
|
||||||
|
|||||||
Reference in New Issue
Block a user