iVS3D v2.0.0
Loading...
Searching...
No Matches
exif.h
1/**************************************************************************
2 exif.h -- A simple ISO C++ library to parse basic EXIF
3 information from a JPEG file.
4 Based on the description of the EXIF file format at:
5 -- http://park2.wakwak.com/~tsuruzoh/Computer/Digicams/exif-e.html
6 -- http://www.media.mit.edu/pia/Research/deepview/exif.html
7 -- http://www.exif.org/Exif2-2.PDF
8 Copyright (c) 2010-2016 Mayank Lahiri
9 mlahiri@gmail.com
10 All rights reserved.
11 Redistribution and use in source and binary forms, with or without
12 modification, are permitted provided that the following conditions are met:
13 -- Redistributions of source code must retain the above copyright notice,
14 this list of conditions and the following disclaimer.
15 -- Redistributions in binary form must reproduce the above copyright notice,
16 this list of conditions and the following disclaimer in the documentation
17 and/or other materials provided with the distribution.
18 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY EXPRESS
19 OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20 OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
21 NO EVENT SHALL THE FREEBSD PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
22 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
23 BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
25 OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
26 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
27 EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28*/
29#ifndef __EXIF_H
30#define __EXIF_H
31
32#include <string>
33
34namespace easyexif {
35
36//
37// Class responsible for storing and parsing EXIF information from a JPEG blob
38//
39class EXIFInfo {
40 public:
41 // Parsing function for an entire JPEG image buffer.
42 //
43 // PARAM 'data': A pointer to a JPEG image.
44 // PARAM 'length': The length of the JPEG image.
45 // RETURN: PARSE_EXIF_SUCCESS (0) on succes with 'result' filled out
46 // error code otherwise, as defined by the PARSE_EXIF_ERROR_* macros
47 int parseFrom(const unsigned char *data, unsigned length);
48 int parseFrom(const std::string &data);
49 int parseFromPNG(const unsigned char *data, unsigned length);
50
51 // Parsing function for an EXIF segment. This is used internally by parseFrom()
52 // but can be called for special cases where only the EXIF section is
53 // available (i.e., a blob starting with the bytes "Exif\0\0").
54 int parseFromEXIFSegment(const unsigned char *buf, unsigned len);
55
56 // Set all data members to default values.
57 void clear();
58
59 // Data fields filled out by parseFrom()
60 char ByteAlign; // 0 = Motorola byte alignment, 1 = Intel
61 std::string ImageDescription; // Image description
62 std::string Make; // Camera manufacturer's name
63 std::string Model; // Camera model
64 unsigned short Orientation; // Image orientation, start of data corresponds to
65 // 0: unspecified in EXIF data
66 // 1: upper left of image
67 // 3: lower right of image
68 // 6: upper right of image
69 // 8: lower left of image
70 // 9: undefined
71 unsigned short BitsPerSample; // Number of bits per component
72 std::string Software; // Software used
73 std::string DateTime; // File change date and time
74 std::string DateTimeOriginal; // Original file date and time (may not exist)
75 std::string DateTimeDigitized; // Digitization date and time (may not exist)
76 std::string SubSecTimeOriginal; // Sub-second time that original picture was taken
77 std::string Copyright; // File copyright information
78 double ExposureTime; // Exposure time in seconds
79 double FNumber; // F/stop
80 unsigned short ExposureProgram; // Exposure program
81 // 0: Not defined
82 // 1: Manual
83 // 2: Normal program
84 // 3: Aperture priority
85 // 4: Shutter priority
86 // 5: Creative program
87 // 6: Action program
88 // 7: Portrait mode
89 // 8: Landscape mode
90 unsigned short ISOSpeedRatings; // ISO speed
91 double ShutterSpeedValue; // Shutter speed (reciprocal of exposure time)
92 double ExposureBiasValue; // Exposure bias value in EV
93 double SubjectDistance; // Distance to focus point in meters
94 double FocalLength; // Focal length of lens in millimeters
95 unsigned short FocalLengthIn35mm; // Focal length in 35mm film
96 char Flash; // 0 = no flash, 1 = flash used
97 unsigned short FlashReturnedLight;// Flash returned light status
98 // 0: No strobe return detection function
99 // 1: Reserved
100 // 2: Strobe return light not detected
101 // 3: Strobe return light detected
102 unsigned short FlashMode; // Flash mode
103 // 0: Unknown
104 // 1: Compulsory flash firing
105 // 2: Compulsory flash suppression
106 // 3: Automatic mode
107 unsigned short MeteringMode; // Metering mode
108 // 1: average
109 // 2: center weighted average
110 // 3: spot
111 // 4: multi-spot
112 // 5: multi-segment
113 unsigned ImageWidth; // Image width reported in EXIF data
114 unsigned ImageHeight; // Image height reported in EXIF data
115 struct Geolocation_t { // GPS information embedded in file
116 double Latitude; // Image latitude expressed as decimal
117 double Longitude; // Image longitude expressed as decimal
118 double Altitude; // Altitude in meters, relative to sea level
119 char AltitudeRef; // 0 = above sea level, -1 = below sea level
120 double DOP; // GPS degree of precision (DOP)
121 struct Coord_t {
122 double degrees;
123 double minutes;
124 double seconds;
125 char direction;
126 } LatComponents, LonComponents; // Latitude, Longitude expressed in deg/min/sec
127 } GeoLocation;
128 struct LensInfo_t { // Lens information
129 double FStopMin; // Min aperture (f-stop)
130 double FStopMax; // Max aperture (f-stop)
131 double FocalLengthMin; // Min focal length (mm)
132 double FocalLengthMax; // Max focal length (mm)
133 double FocalPlaneXResolution; // Focal plane X-resolution
134 double FocalPlaneYResolution; // Focal plane Y-resolution
135 unsigned short FocalPlaneResolutionUnit; // Focal plane resolution unit
136 // 1: No absolute unit of measurement.
137 // 2: Inch.
138 // 3: Centimeter.
139 // 4: Millimeter.
140 // 5: Micrometer.
141 std::string Make; // Lens manufacturer
142 std::string Model; // Lens model
143 } LensInfo;
144
145
146 EXIFInfo() {
147 clear();
148 }
149};
150
151}
152
153// Parse was successful
154#define PARSE_EXIF_SUCCESS 0
155// No PNG markers found in buffer, possibly invalid PNG file
156#define PARSE_EXIF_ERROR_NO_PNG 1981
157// No JPEG markers found in buffer, possibly invalid JPEG file
158#define PARSE_EXIF_ERROR_NO_JPEG 1982
159// No EXIF header found in file.
160#define PARSE_EXIF_ERROR_NO_EXIF 1983
161// Byte alignment specified in EXIF file was unknown (not Motorola or Intel).
162#define PARSE_EXIF_ERROR_UNKNOWN_BYTEALIGN 1984
163// EXIF header was found, but data was corrupted.
164#define PARSE_EXIF_ERROR_CORRUPT 1985
165
166#endif
167
Definition exif.h:39
Definition exif.h:128