| 1 |
#pragma once |
| 2 |
|
| 3 |
#ifdef __cplusplus |
| 4 |
extern "C" { |
| 5 |
#endif |
| 6 |
|
| 7 |
#ifdef _DLL |
| 8 |
#ifdef WIN32 |
| 9 |
#define EXIF_EXPORT __declspec(dllexport) |
| 10 |
#else |
| 11 |
#define EXIF_EXPORT |
| 12 |
#endif |
| 13 |
#else |
| 14 |
#define EXIF_EXPORT |
| 15 |
#endif |
| 16 |
|
| 17 |
//-------------------------------------------------------------------------- |
| 18 |
// JPEG markers consist of one or more 0xFF bytes, followed by a marker |
| 19 |
// code byte (which is not an FF). Here are the marker codes of interest |
| 20 |
// in this application. |
| 21 |
//-------------------------------------------------------------------------- |
| 22 |
|
| 23 |
#define M_SOF0 0xC0 // Start Of Frame N |
| 24 |
#define M_SOF1 0xC1 // N indicates which compression process |
| 25 |
#define M_SOF2 0xC2 // Only SOF0-SOF2 are now in common use |
| 26 |
#define M_SOF3 0xC3 |
| 27 |
#define M_SOF5 0xC5 // NB: codes C4 and CC are NOT SOF markers |
| 28 |
#define M_SOF6 0xC6 |
| 29 |
#define M_SOF7 0xC7 |
| 30 |
#define M_SOF9 0xC9 |
| 31 |
#define M_SOF10 0xCA |
| 32 |
#define M_SOF11 0xCB |
| 33 |
#define M_SOF13 0xCD |
| 34 |
#define M_SOF14 0xCE |
| 35 |
#define M_SOF15 0xCF |
| 36 |
#define M_SOI 0xD8 // Start Of Image (beginning of datastream) |
| 37 |
#define M_EOI 0xD9 // End Of Image (end of datastream) |
| 38 |
#define M_SOS 0xDA // Start Of Scan (begins compressed data) |
| 39 |
#define M_JFIF 0xE0 // Jfif marker |
| 40 |
#define M_EXIF 0xE1 // Exif marker |
| 41 |
#define M_COM 0xFE // COMment |
| 42 |
#define M_DQT 0xDB |
| 43 |
#define M_DHT 0xC4 |
| 44 |
#define M_DRI 0xDD |
| 45 |
#define M_IPTC 0xED // IPTC marker |
| 46 |
|
| 47 |
#define MAX_IPTC_STRING 256 |
| 48 |
|
| 49 |
typedef struct { |
| 50 |
char RecordVersion[MAX_IPTC_STRING]; |
| 51 |
char SupplementalCategories[MAX_IPTC_STRING]; |
| 52 |
char Keywords[MAX_IPTC_STRING]; |
| 53 |
char Caption[MAX_IPTC_STRING]; |
| 54 |
char Author[MAX_IPTC_STRING]; |
| 55 |
char Headline[MAX_IPTC_STRING]; |
| 56 |
char SpecialInstructions[MAX_IPTC_STRING]; |
| 57 |
char Category[MAX_IPTC_STRING]; |
| 58 |
char Byline[MAX_IPTC_STRING]; |
| 59 |
char BylineTitle[MAX_IPTC_STRING]; |
| 60 |
char Credit[MAX_IPTC_STRING]; |
| 61 |
char Source[MAX_IPTC_STRING]; |
| 62 |
char CopyrightNotice[MAX_IPTC_STRING]; |
| 63 |
char ObjectName[MAX_IPTC_STRING]; |
| 64 |
char City[MAX_IPTC_STRING]; |
| 65 |
char State[MAX_IPTC_STRING]; |
| 66 |
char Country[MAX_IPTC_STRING]; |
| 67 |
char TransmissionReference[MAX_IPTC_STRING]; |
| 68 |
char Date[MAX_IPTC_STRING]; |
| 69 |
char Urgency[MAX_IPTC_STRING]; |
| 70 |
char ReferenceService[MAX_IPTC_STRING]; |
| 71 |
char CountryCode[MAX_IPTC_STRING]; |
| 72 |
char TimeCreated[MAX_IPTC_STRING]; |
| 73 |
char SubLocation[MAX_IPTC_STRING]; |
| 74 |
char ImageType[MAX_IPTC_STRING]; |
| 75 |
} IPTCInfo_t; |
| 76 |
|
| 77 |
#define EXIF_COMMENT_CHARSET_CONVERTED -1 // Comments contains converted data |
| 78 |
#define EXIF_COMMENT_CHARSET_UNKNOWN 0 // Exif: Unknown |
| 79 |
#define EXIF_COMMENT_CHARSET_ASCII 2 // Exif: Ascii |
| 80 |
#define EXIF_COMMENT_CHARSET_UNICODE 3 // Exif: Unicode (UTF-16) |
| 81 |
#define EXIF_COMMENT_CHARSET_JIS 4 // Exif: JIS X208-1990 |
| 82 |
|
| 83 |
#define MAX_COMMENT 2000 |
| 84 |
#define MAX_DATE_COPIES 10 |
| 85 |
|
| 86 |
typedef struct { |
| 87 |
char CameraMake [33]; |
| 88 |
char CameraModel [41]; |
| 89 |
char DateTime [21]; |
| 90 |
int Height, Width; |
| 91 |
int Orientation; |
| 92 |
int IsColor; |
| 93 |
int Process; |
| 94 |
int FlashUsed; |
| 95 |
float FocalLength; |
| 96 |
float ExposureTime; |
| 97 |
float ApertureFNumber; |
| 98 |
float Distance; |
| 99 |
float CCDWidth; |
| 100 |
float ExposureBias; |
| 101 |
float DigitalZoomRatio; |
| 102 |
int FocalLength35mmEquiv; // Exif 2.2 tag - usually not present. |
| 103 |
int Whitebalance; |
| 104 |
int MeteringMode; |
| 105 |
int ExposureProgram; |
| 106 |
int ExposureMode; |
| 107 |
int ISOequivalent; |
| 108 |
int LightSource; |
| 109 |
int CommentsCharset; // EXIF_COMMENT_CHARSET_* |
| 110 |
int XPCommentsCharset; |
| 111 |
char Comments[MAX_COMMENT + 1]; // +1 for null termination |
| 112 |
char FileComment[MAX_COMMENT + 1]; |
| 113 |
char XPComment[MAX_COMMENT + 1]; |
| 114 |
char Description[MAX_COMMENT + 1]; |
| 115 |
|
| 116 |
unsigned ThumbnailOffset; // Exif offset to thumbnail |
| 117 |
unsigned ThumbnailSize; // Size of thumbnail. |
| 118 |
unsigned LargestExifOffset; // Last exif data referenced (to check if thumbnail is at end) |
| 119 |
|
| 120 |
char ThumbnailAtEnd; // Exif header ends with the thumbnail |
| 121 |
// (we can only modify the thumbnail if its at the end) |
| 122 |
int ThumbnailSizeOffset; |
| 123 |
|
| 124 |
int DateTimeOffsets[MAX_DATE_COPIES]; |
| 125 |
int numDateTimeTags; |
| 126 |
|
| 127 |
int GpsInfoPresent; |
| 128 |
char GpsLat[31]; |
| 129 |
char GpsLong[31]; |
| 130 |
char GpsAlt[20]; |
| 131 |
} ExifInfo_t; |
| 132 |
|
| 133 |
EXIF_EXPORT bool process_jpeg(const char *filename, ExifInfo_t *exifInfo, IPTCInfo_t *iptcInfo); |
| 134 |
|
| 135 |
#ifdef __cplusplus |
| 136 |
} |
| 137 |
#endif |
| 138 |
|