SpatiaLite  4.3.0
gaiaexif.h
Go to the documentation of this file.
1 /*
2  gaiaexif.h -- Gaia common EXIF Metadata reading functions
3 
4  version 4.3, 2015 June 29
5 
6  Author: Sandro Furieri a.furieri@lqt.it
7 
8  ------------------------------------------------------------------------------
9 
10  Version: MPL 1.1/GPL 2.0/LGPL 2.1
11 
12  The contents of this file are subject to the Mozilla Public License Version
13  1.1 (the "License"); you may not use this file except in compliance with
14  the License. You may obtain a copy of the License at
15  http://www.mozilla.org/MPL/
16 
17 Software distributed under the License is distributed on an "AS IS" basis,
18 WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
19 for the specific language governing rights and limitations under the
20 License.
21 
22 The Original Code is the SpatiaLite library
23 
24 The Initial Developer of the Original Code is Alessandro Furieri
25 
26 Portions created by the Initial Developer are Copyright (C) 2008-2015
27 the Initial Developer. All Rights Reserved.
28 
29 Contributor(s):
30 
31 Alternatively, the contents of this file may be used under the terms of
32 either the GNU General Public License Version 2 or later (the "GPL"), or
33 the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
34 in which case the provisions of the GPL or the LGPL are applicable instead
35 of those above. If you wish to allow use of your version of this file only
36 under the terms of either the GPL or the LGPL, and not to allow others to
37 use your version of this file under the terms of the MPL, indicate your
38 decision by deleting the provisions above and replace them with the notice
39 and other provisions required by the GPL or the LGPL. If you do not delete
40 the provisions above, a recipient may use your version of this file under
41 the terms of any one of the MPL, the GPL or the LGPL.
42 
43 */
44 
51 #ifndef DOXYGEN_SHOULD_SKIP_THIS
52 #ifdef DLL_EXPORT
53 #define GAIAEXIF_DECLARE __declspec(dllexport)
54 #else
55 #define GAIAEXIF_DECLARE extern
56 #endif
57 #endif
58 
59 #ifndef _GAIAEXIF_H
60 #ifndef DOXYGEN_SHOULD_SKIP_THIS
61 #define _GAIAEXIF_H
62 #endif
63 
64 #ifdef __cplusplus
65 extern "C"
66 {
67 #endif
68 
69 /* constants used for BLOB value types */
71 #define GAIA_HEX_BLOB 0
72 
73 #define GAIA_GIF_BLOB 1
74 
75 #define GAIA_PNG_BLOB 2
76 
77 #define GAIA_JPEG_BLOB 3
78 
79 #define GAIA_EXIF_BLOB 4
80 
81 #define GAIA_EXIF_GPS_BLOB 5
82 
83 #define GAIA_ZIP_BLOB 6
84 
85 #define GAIA_PDF_BLOB 7
86 
87 #define GAIA_GEOMETRY_BLOB 8
88 
89 #define GAIA_TIFF_BLOB 9
90 
91 #define GAIA_WEBP_BLOB 10
92 
93 #define GAIA_JP2_BLOB 11
94 
95 #define GAIA_XML_BLOB 12
96 
97 #define GAIA_GPB_BLOB 13
98 
99 /* constants used for EXIF value types */
101 #define GAIA_EXIF_NONE 0
102 
103 #define GAIA_EXIF_BYTE 1
104 
105 #define GAIA_EXIF_SHORT 2
106 
107 #define GAIA_EXIF_STRING 3
108 
109 #define GAIA_EXIF_LONG 4
110 
111 #define GAIA_EXIF_RATIONAL 5
112 
113 #define GAIA_EXIF_SLONG 9
114 
115 #define GAIA_EXIF_SRATIONAL 10
116 
120  typedef struct gaiaExifTagStruct
121  {
122 /* an EXIF TAG */
124  char Gps;
126  unsigned short TagId;
128  unsigned short Type;
130  unsigned short Count;
132  unsigned char TagOffset[4];
134  unsigned char *ByteValue;
136  char *StringValue;
138  unsigned short *ShortValues;
140  unsigned int *LongValues;
142  unsigned int *LongRationals1;
144  unsigned int *LongRationals2;
154  float *FloatValues;
156  double *DoubleValues;
159  } gaiaExifTag;
166 
170  typedef struct gaiaExifTagListStruct
171  {
172 /* an EXIF TAG LIST */
174  gaiaExifTagPtr First;
176  gaiaExifTagPtr Last;
178  int NumTags;
180  gaiaExifTagPtr *TagsArray;
181  } gaiaExifTagList;
188 
189 /* function prototipes */
190 
203  GAIAEXIF_DECLARE gaiaExifTagListPtr gaiaGetExifTags (const unsigned char
204  *blob, int size);
205 
216  GAIAEXIF_DECLARE void gaiaExifTagsFree (gaiaExifTagListPtr tag_list);
217 
227  GAIAEXIF_DECLARE int gaiaGetExifTagsCount (gaiaExifTagListPtr tag_list);
228 
239  GAIAEXIF_DECLARE gaiaExifTagPtr gaiaGetExifTagByPos (gaiaExifTagListPtr
240  tag_list,
241  const int pos);
242 
252  GAIAEXIF_DECLARE int gaiaGetExifTagsCount (gaiaExifTagListPtr tag_list);
253 
264  GAIAEXIF_DECLARE gaiaExifTagPtr gaiaGetExifTagById (const gaiaExifTagListPtr
265  tag_list,
266  const unsigned short
267  tag_id);
268 
279  GAIAEXIF_DECLARE gaiaExifTagPtr gaiaGetExifGpsTagById (const
280  gaiaExifTagListPtr
281  tag_list,
282  const unsigned short
283  tag_id);
284 
295  GAIAEXIF_DECLARE gaiaExifTagPtr gaiaGetExifTagByName (const
296  gaiaExifTagListPtr
297  tag_list,
298  const char *tag_name);
299 
309  GAIAEXIF_DECLARE unsigned short gaiaExifTagGetId (const gaiaExifTagPtr tag);
310 
320  GAIAEXIF_DECLARE void gaiaExifTagGetName (const gaiaExifTagPtr tag,
321  char *tag_name, int len);
322 
332  GAIAEXIF_DECLARE int gaiaIsExifGpsTag (const gaiaExifTagPtr tag);
333 
345  GAIAEXIF_DECLARE unsigned short gaiaExifTagGetValueType (const
346  gaiaExifTagPtr
347  tag);
348 
358  GAIAEXIF_DECLARE unsigned short gaiaExifTagGetNumValues (const
359  gaiaExifTagPtr
360  tag);
361 
374  GAIAEXIF_DECLARE unsigned char gaiaExifTagGetByteValue (const gaiaExifTagPtr
375  tag, const int ind,
376  int *ok);
377 
389  GAIAEXIF_DECLARE void gaiaExifTagGetStringValue (const gaiaExifTagPtr tag,
390  char *str, int len,
391  int *ok);
392 
405  GAIAEXIF_DECLARE unsigned short gaiaExifTagGetShortValue (const
406  gaiaExifTagPtr
407  tag,
408  const int ind,
409  int *ok);
410 
423  GAIAEXIF_DECLARE unsigned int gaiaExifTagGetLongValue (const gaiaExifTagPtr
424  tag, const int ind,
425  int *ok);
426 
439  GAIAEXIF_DECLARE unsigned int gaiaExifTagGetRational1Value (const
440  gaiaExifTagPtr
441  tag,
442  const int ind,
443  int *ok);
444 
457  GAIAEXIF_DECLARE unsigned int gaiaExifTagGetRational2Value (const
458  gaiaExifTagPtr
459  tag,
460  const int ind,
461  int *ok);
462 
475  GAIAEXIF_DECLARE double gaiaExifTagGetRationalValue (const gaiaExifTagPtr
476  tag, const int ind,
477  int *ok);
478 
491  GAIAEXIF_DECLARE short gaiaExifTagGetSignedShortValue (const gaiaExifTagPtr
492  tag, const int ind,
493  int *ok);
494 
507  GAIAEXIF_DECLARE int gaiaExifTagGetSignedLongValue (const gaiaExifTagPtr
508  tag, const int ind,
509  int *ok);
510 
523  GAIAEXIF_DECLARE int gaiaExifTagGetSignedRational1Value (const
524  gaiaExifTagPtr tag,
525  const int ind,
526  int *ok);
527 
540  GAIAEXIF_DECLARE int gaiaExifTagGetSignedRational2Value (const
541  gaiaExifTagPtr tag,
542  const int ind,
543  int *ok);
544 
557  GAIAEXIF_DECLARE double gaiaExifTagGetSignedRationalValue (const
558  gaiaExifTagPtr
559  tag,
560  const int ind,
561  int *ok);
562 
575  GAIAEXIF_DECLARE float gaiaExifTagGetFloatValue (const gaiaExifTagPtr tag,
576  const int ind, int *ok);
577 
590  GAIAEXIF_DECLARE double gaiaExifTagGetDoubleValue (const gaiaExifTagPtr tag,
591  const int ind, int *ok);
592 
603  GAIAEXIF_DECLARE void gaiaExifTagGetHumanReadable (const gaiaExifTagPtr tag,
604  char *str, int len,
605  int *ok);
606 
618  GAIAEXIF_DECLARE int gaiaGuessBlobType (const unsigned char *blob,
619  int size);
633  GAIAEXIF_DECLARE int gaiaGetGpsCoords (const unsigned char *blob, int size,
634  double *longitude, double *latitude);
648  GAIAEXIF_DECLARE int gaiaGetGpsLatLong (const unsigned char *blob, int size,
649  char *latlong, int ll_size);
650 
651 #ifdef __cplusplus
652 }
653 #endif
654 
655 #endif /* _GAIAEXIF_H */
GAIAEXIF_DECLARE unsigned int gaiaExifTagGetRational1Value(const gaiaExifTagPtr tag, const int ind, int *ok)
Return a RATIONAL [numerator] value from an EXIF tag.
int NumTags
number of items
Definition: gaiaexif.h:178
GAIAEXIF_DECLARE int gaiaGetExifTagsCount(gaiaExifTagListPtr tag_list)
Return the total number of EXIF tags into the list.
unsigned short TagId
EXIF tag ID.
Definition: gaiaexif.h:126
struct gaiaExifTagListStruct gaiaExifTagList
Container for a list of EXIF tags.
GAIAEXIF_DECLARE int gaiaExifTagGetSignedRational2Value(const gaiaExifTagPtr tag, const int ind, int *ok)
Return a SRATIONAL [denominator] value from an EXIF tag.
GAIAEXIF_DECLARE unsigned short gaiaExifTagGetValueType(const gaiaExifTagPtr tag)
Return the value type for an EXIF tag.
GAIAEXIF_DECLARE int gaiaGetGpsLatLong(const unsigned char *blob, int size, char *latlong, int ll_size)
Return a text string representing DMS coordinates from an EXIF-GPS tag.
GAIAEXIF_DECLARE gaiaExifTagPtr gaiaGetExifTagById(const gaiaExifTagListPtr tag_list, const unsigned short tag_id)
Retrieves an EXIF tag by its Tag ID.
GAIAEXIF_DECLARE unsigned short gaiaExifTagGetId(const gaiaExifTagPtr tag)
Return the Tag ID from an EXIF tag.
gaiaExifTagList * gaiaExifTagListPtr
Typedef for EXIF tag structure.
Definition: gaiaexif.h:187
unsigned int * LongValues
array of LONG values ]
Definition: gaiaexif.h:140
char Gps
GPS data included (0/1)
Definition: gaiaexif.h:124
GAIAEXIF_DECLARE void gaiaExifTagGetHumanReadable(const gaiaExifTagPtr tag, char *str, int len, int *ok)
Return a human readable description from an EXIF tag.
GAIAEXIF_DECLARE double gaiaExifTagGetSignedRationalValue(const gaiaExifTagPtr tag, const int ind, int *ok)
Return a Signed RATIONAL value from an EXIF tag.
GAIAEXIF_DECLARE gaiaExifTagPtr gaiaGetExifTagByName(const gaiaExifTagListPtr tag_list, const char *tag_name)
Retrieves an EXIF tag by its name.
GAIAEXIF_DECLARE void gaiaExifTagGetName(const gaiaExifTagPtr tag, char *tag_name, int len)
Return the Tag Name from an EXIF tag.
GAIAEXIF_DECLARE gaiaExifTagPtr gaiaGetExifTagByPos(gaiaExifTagListPtr tag_list, const int pos)
Retrieves an EXIF tag by its relative position into the list.
struct gaiaExifTagStruct gaiaExifTag
Container for an EXIF tag.
GAIAEXIF_DECLARE int gaiaExifTagGetSignedRational1Value(const gaiaExifTagPtr tag, const int ind, int *ok)
Return a SRATIONAL [numerator] value from an EXIF tag.
GAIAEXIF_DECLARE unsigned short gaiaExifTagGetShortValue(const gaiaExifTagPtr tag, const int ind, int *ok)
Return a SHORT value from an EXIF tag.
Container for an EXIF tag.
Definition: gaiaexif.h:120
unsigned int * LongRationals1
array of RATIONAL values [numerators]
Definition: gaiaexif.h:142
GAIAEXIF_DECLARE gaiaExifTagPtr gaiaGetExifGpsTagById(const gaiaExifTagListPtr tag_list, const unsigned short tag_id)
Retrieves an EXIF-GPS tag by its Tag ID.
int * SignedLongRationals1
array of Signed RATIONAL values [numerators]
Definition: gaiaexif.h:150
Container for a list of EXIF tags.
Definition: gaiaexif.h:170
unsigned short Type
EXIF value type.
Definition: gaiaexif.h:128
GAIAEXIF_DECLARE void gaiaExifTagsFree(gaiaExifTagListPtr tag_list)
Destroy a list of EXIF tags.
unsigned char * ByteValue
array of BYTE values
Definition: gaiaexif.h:134
GAIAEXIF_DECLARE unsigned char gaiaExifTagGetByteValue(const gaiaExifTagPtr tag, const int ind, int *ok)
Return a BYTE value from an EXIF tag.
int * SignedLongValues
array of Signed LONG values
Definition: gaiaexif.h:148
GAIAEXIF_DECLARE double gaiaExifTagGetRationalValue(const gaiaExifTagPtr tag, const int ind, int *ok)
Return a RATIONAL value from an EXIF tag.
GAIAEXIF_DECLARE unsigned int gaiaExifTagGetRational2Value(const gaiaExifTagPtr tag, const int ind, int *ok)
Return a RATIONAL [denominator] value from an EXIF tag.
gaiaExifTag * gaiaExifTagPtr
Typedef for EXIF tag structure.
Definition: gaiaexif.h:165
GAIAEXIF_DECLARE int gaiaGetGpsCoords(const unsigned char *blob, int size, double *longitude, double *latitude)
Return longitude and latitude from an EXIF-GPS tag.
unsigned char TagOffset[4]
tag offset [big- little-endian encoded]
Definition: gaiaexif.h:132
unsigned short * ShortValues
array of SHORT values
Definition: gaiaexif.h:138
gaiaExifTagPtr First
pointer to first item into the linked list
Definition: gaiaexif.h:174
GAIAEXIF_DECLARE void gaiaExifTagGetStringValue(const gaiaExifTagPtr tag, char *str, int len, int *ok)
Return a STRING value from an EXIF tag.
GAIAEXIF_DECLARE unsigned short gaiaExifTagGetNumValues(const gaiaExifTagPtr tag)
Return the total count of values from an EXIF tag.
GAIAEXIF_DECLARE int gaiaExifTagGetSignedLongValue(const gaiaExifTagPtr tag, const int ind, int *ok)
Return a Signed LONG value from an EXIF tag.
GAIAEXIF_DECLARE short gaiaExifTagGetSignedShortValue(const gaiaExifTagPtr tag, const int ind, int *ok)
Return a Signed SHORT value from an EXIF tag.
float * FloatValues
array of FLOAT values
Definition: gaiaexif.h:154
double * DoubleValues
array of DOUBLE values
Definition: gaiaexif.h:156
GAIAEXIF_DECLARE gaiaExifTagListPtr gaiaGetExifTags(const unsigned char *blob, int size)
Creates a list of EXIF tags by parsing a BLOB of the JPEG-EXIF type.
struct gaiaExifTagStruct * Next
pointer to next item into the linked list
Definition: gaiaexif.h:158
GAIAEXIF_DECLARE float gaiaExifTagGetFloatValue(const gaiaExifTagPtr tag, const int ind, int *ok)
Return a FLOAT value from an EXIF tag.
GAIAEXIF_DECLARE unsigned int gaiaExifTagGetLongValue(const gaiaExifTagPtr tag, const int ind, int *ok)
Return a LONG value from an EXIF tag.
char * StringValue
array of STRING values
Definition: gaiaexif.h:136
int * SignedLongRationals2
array of Signed RATIONAL values [denominators]
Definition: gaiaexif.h:152
unsigned short Count
number of values
Definition: gaiaexif.h:130
gaiaExifTagPtr Last
pointer to the last item into the linked list
Definition: gaiaexif.h:176
unsigned int * LongRationals2
array of RATIONAL values [denominators]
Definition: gaiaexif.h:144
gaiaExifTagPtr * TagsArray
an array of pointers to items
Definition: gaiaexif.h:180
GAIAEXIF_DECLARE double gaiaExifTagGetDoubleValue(const gaiaExifTagPtr tag, const int ind, int *ok)
Return a DOUBLE value from an EXIF tag.
short * SignedShortValues
array of Signed SHORT values
Definition: gaiaexif.h:146
GAIAEXIF_DECLARE int gaiaGuessBlobType(const unsigned char *blob, int size)
Attempts to guess the actual content-type of some BLOB.
GAIAEXIF_DECLARE int gaiaIsExifGpsTag(const gaiaExifTagPtr tag)
Checks if an EXIF tag actually is an EXIF-GPS tag.