diff --git a/TinyEXIF.cpp b/TinyEXIF.cpp index 6a65dd3..79596fb 100644 --- a/TinyEXIF.cpp +++ b/TinyEXIF.cpp @@ -148,6 +148,8 @@ public: uint32_t GetData() const { return parse32(buf + offs + 8, alignIntel); } 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 Fetch(std::string& val) const { @@ -163,13 +165,19 @@ public: return true; } bool Fetch(uint16_t& val) const { - if (format != 3) + if (!IsShort()) return false; val = parse16(buf + offs + 8, alignIntel); 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 { - if (format != 4) + if (!IsLong()) return false; val = parse32(buf + offs + 8, alignIntel); return true; @@ -528,6 +536,11 @@ int EXIFInfo::parseFromEXIFSegment(const uint8_t* buf, unsigned len) { parser.Fetch(FNumber); break; + case 0x8822: + // Exposure Program + parser.Fetch(ExposureProgram); + break; + case 0x8827: // ISO Speed Rating parser.Fetch(ISOSpeedRatings); @@ -568,8 +581,18 @@ int EXIFInfo::parseFromEXIFSegment(const uint8_t* buf, unsigned len) { parser.Fetch(SubjectDistance); break; + case 0x9207: + // Metering mode + parser.Fetch(MeteringMode); + break; + + case 0x9208: + // Light source + parser.Fetch(LightSource); + break; + case 0x9209: - // Flash used + // Flash info parser.Fetch(Flash); break; @@ -578,9 +601,13 @@ int EXIFInfo::parseFromEXIFSegment(const uint8_t* buf, unsigned len) { parser.Fetch(FocalLength); break; - case 0x9207: - // Metering mode - parser.Fetch(MeteringMode); + case 0x9214: + // Subject area + if (parser.IsShort() && parser.GetLength() > 1) { + SubjectArea.resize(parser.GetLength()); + for (uint32_t i=0; i +#include #ifdef _MSC_VER # ifdef TINYEXIF_EXPORT @@ -124,6 +125,16 @@ public: std::string Copyright; // File copyright information double ExposureTime; // Exposure time in seconds 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 double ShutterSpeedValue; // Shutter speed (reciprocal of exposure time) double ApertureValue; // The lens aperture @@ -131,17 +142,61 @@ public: double ExposureBiasValue; // Exposure bias value in EV double SubjectDistance; // Distance to focus point in meters 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 - // 1: average - // 2: center weighted average - // 3: spot - // 4: multi-spot - // 5: multi-segment + // 0: unknown + // 1: average + // 2: center weighted average + // 3: spot + // 4: multi-spot + // 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 // 0: unknown projection // 1: perspective projection // 2: equirectangular/spherical projection + std::vector 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 double FStopMin; // Min aperture (f-stop) double FStopMax; // Max aperture (f-stop)