SpatiaLite  4.2.0
 All Data Structures Files Functions Variables Typedefs Macros Pages
gaiaexif.h
Go to the documentation of this file.
1 /*
2  gaiaexif.h -- Gaia common EXIF Metadata reading functions
3 
4  version 4.2, 2014 July 25
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-2013
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_XML_BLOB 11
94 
95 #define GAIA_GPB_BLOB 12
96 
97 /* constants used for EXIF value types */
99 #define GAIA_EXIF_NONE 0
100 
101 #define GAIA_EXIF_BYTE 1
102 
103 #define GAIA_EXIF_SHORT 2
104 
105 #define GAIA_EXIF_STRING 3
106 
107 #define GAIA_EXIF_LONG 4
108 
109 #define GAIA_EXIF_RATIONAL 5
110 
111 #define GAIA_EXIF_SLONG 9
112 
113 #define GAIA_EXIF_SRATIONAL 10
114 
118  typedef struct gaiaExifTagStruct
119  {
120 /* an EXIF TAG */
122  char Gps;
124  unsigned short TagId;
126  unsigned short Type;
128  unsigned short Count;
130  unsigned char TagOffset[4];
132  unsigned char *ByteValue;
134  char *StringValue;
136  unsigned short *ShortValues;
138  unsigned int *LongValues;
140  unsigned int *LongRationals1;
142  unsigned int *LongRationals2;
152  float *FloatValues;
154  double *DoubleValues;
157  } gaiaExifTag;
164 
168  typedef struct gaiaExifTagListStruct
169  {
170 /* an EXIF TAG LIST */
172  gaiaExifTagPtr First;
174  gaiaExifTagPtr Last;
176  int NumTags;
178  gaiaExifTagPtr *TagsArray;
179  } gaiaExifTagList;
186 
187 /* function prototipes */
188 
201  GAIAEXIF_DECLARE gaiaExifTagListPtr gaiaGetExifTags (const unsigned char
202  *blob, int size);
203 
214  GAIAEXIF_DECLARE void gaiaExifTagsFree (gaiaExifTagListPtr tag_list);
215 
225  GAIAEXIF_DECLARE int gaiaGetExifTagsCount (gaiaExifTagListPtr tag_list);
226 
237  GAIAEXIF_DECLARE gaiaExifTagPtr gaiaGetExifTagByPos (gaiaExifTagListPtr
238  tag_list,
239  const int pos);
240 
250  GAIAEXIF_DECLARE int gaiaGetExifTagsCount (gaiaExifTagListPtr tag_list);
251 
262  GAIAEXIF_DECLARE gaiaExifTagPtr gaiaGetExifTagById (const gaiaExifTagListPtr
263  tag_list,
264  const unsigned short
265  tag_id);
266 
277  GAIAEXIF_DECLARE gaiaExifTagPtr gaiaGetExifGpsTagById (const
278  gaiaExifTagListPtr
279  tag_list,
280  const unsigned short
281  tag_id);
282 
293  GAIAEXIF_DECLARE gaiaExifTagPtr gaiaGetExifTagByName (const
294  gaiaExifTagListPtr
295  tag_list,
296  const char *tag_name);
297 
307  GAIAEXIF_DECLARE unsigned short gaiaExifTagGetId (const gaiaExifTagPtr tag);
308 
318  GAIAEXIF_DECLARE void gaiaExifTagGetName (const gaiaExifTagPtr tag,
319  char *tag_name, int len);
320 
330  GAIAEXIF_DECLARE int gaiaIsExifGpsTag (const gaiaExifTagPtr tag);
331 
343  GAIAEXIF_DECLARE unsigned short gaiaExifTagGetValueType (const
344  gaiaExifTagPtr
345  tag);
346 
356  GAIAEXIF_DECLARE unsigned short gaiaExifTagGetNumValues (const
357  gaiaExifTagPtr
358  tag);
359 
372  GAIAEXIF_DECLARE unsigned char gaiaExifTagGetByteValue (const gaiaExifTagPtr
373  tag, const int ind,
374  int *ok);
375 
387  GAIAEXIF_DECLARE void gaiaExifTagGetStringValue (const gaiaExifTagPtr tag,
388  char *str, int len,
389  int *ok);
390 
403  GAIAEXIF_DECLARE unsigned short gaiaExifTagGetShortValue (const
404  gaiaExifTagPtr
405  tag,
406  const int ind,
407  int *ok);
408 
421  GAIAEXIF_DECLARE unsigned int gaiaExifTagGetLongValue (const gaiaExifTagPtr
422  tag, const int ind,
423  int *ok);
424 
437  GAIAEXIF_DECLARE unsigned int gaiaExifTagGetRational1Value (const
438  gaiaExifTagPtr
439  tag,
440  const int ind,
441  int *ok);
442 
455  GAIAEXIF_DECLARE unsigned int gaiaExifTagGetRational2Value (const
456  gaiaExifTagPtr
457  tag,
458  const int ind,
459  int *ok);
460 
473  GAIAEXIF_DECLARE double gaiaExifTagGetRationalValue (const gaiaExifTagPtr
474  tag, const int ind,
475  int *ok);
476 
489  GAIAEXIF_DECLARE short gaiaExifTagGetSignedShortValue (const gaiaExifTagPtr
490  tag, const int ind,
491  int *ok);
492 
505  GAIAEXIF_DECLARE int gaiaExifTagGetSignedLongValue (const gaiaExifTagPtr
506  tag, const int ind,
507  int *ok);
508 
521  GAIAEXIF_DECLARE int gaiaExifTagGetSignedRational1Value (const
522  gaiaExifTagPtr tag,
523  const int ind,
524  int *ok);
525 
538  GAIAEXIF_DECLARE int gaiaExifTagGetSignedRational2Value (const
539  gaiaExifTagPtr tag,
540  const int ind,
541  int *ok);
542 
555  GAIAEXIF_DECLARE double gaiaExifTagGetSignedRationalValue (const
556  gaiaExifTagPtr
557  tag,
558  const int ind,
559  int *ok);
560 
573  GAIAEXIF_DECLARE float gaiaExifTagGetFloatValue (const gaiaExifTagPtr tag,
574  const int ind, int *ok);
575 
588  GAIAEXIF_DECLARE double gaiaExifTagGetDoubleValue (const gaiaExifTagPtr tag,
589  const int ind, int *ok);
590 
601  GAIAEXIF_DECLARE void gaiaExifTagGetHumanReadable (const gaiaExifTagPtr tag,
602  char *str, int len,
603  int *ok);
604 
616  GAIAEXIF_DECLARE int gaiaGuessBlobType (const unsigned char *blob,
617  int size);
631  GAIAEXIF_DECLARE int gaiaGetGpsCoords (const unsigned char *blob, int size,
632  double *longitude, double *latitude);
646  GAIAEXIF_DECLARE int gaiaGetGpsLatLong (const unsigned char *blob, int size,
647  char *latlong, int ll_size);
648 
649 #ifdef __cplusplus
650 }
651 #endif
652 
653 #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:176
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:124
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:185
unsigned int * LongValues
array of LONG values ]
Definition: gaiaexif.h:138
char Gps
GPS data included (0/1)
Definition: gaiaexif.h:122
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:118
unsigned int * LongRationals1
array of RATIONAL values [numerators]
Definition: gaiaexif.h:140
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:148
Container for a list of EXIF tags.
Definition: gaiaexif.h:168
unsigned short Type
EXIF value type.
Definition: gaiaexif.h:126
GAIAEXIF_DECLARE void gaiaExifTagsFree(gaiaExifTagListPtr tag_list)
Destroy a list of EXIF tags.
unsigned char * ByteValue
array of BYTE values
Definition: gaiaexif.h:132
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:146
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:163
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:130
unsigned short * ShortValues
array of SHORT values
Definition: gaiaexif.h:136
gaiaExifTagPtr First
pointer to first item into the linked list
Definition: gaiaexif.h:172
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:152
double * DoubleValues
array of DOUBLE values
Definition: gaiaexif.h:154
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:156
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:134
int * SignedLongRationals2
array of Signed RATIONAL values [denominators]
Definition: gaiaexif.h:150
unsigned short Count
number of values
Definition: gaiaexif.h:128
gaiaExifTagPtr Last
pointer to the last item into the linked list
Definition: gaiaexif.h:174
unsigned int * LongRationals2
array of RATIONAL values [denominators]
Definition: gaiaexif.h:142
gaiaExifTagPtr * TagsArray
an array of pointers to items
Definition: gaiaexif.h:178
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:144
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.