SpatiaLite  5.0.0
gaiaexif.h
Go to the documentation of this file.
1 /*
2  gaiaexif.h -- Gaia common EXIF Metadata reading functions
3 
4  version 5.0, 2020 August 1
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-2020
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_COMPRESSED_GEOMETRY_BLOB 9
90 
91 #define GAIA_TIFF_BLOB 10
92 
93 #define GAIA_WEBP_BLOB 11
94 
95 #define GAIA_JP2_BLOB 12
96 
97 #define GAIA_XML_BLOB 13
98 
99 #define GAIA_GPB_BLOB 14
100 
101 #define GAIA_TINYPOINT_BLOB 15
102 
103 /* constants used for EXIF value types */
105 #define GAIA_EXIF_NONE 0
106 
107 #define GAIA_EXIF_BYTE 1
108 
109 #define GAIA_EXIF_SHORT 2
110 
111 #define GAIA_EXIF_STRING 3
112 
113 #define GAIA_EXIF_LONG 4
114 
115 #define GAIA_EXIF_RATIONAL 5
116 
117 #define GAIA_EXIF_SLONG 9
118 
119 #define GAIA_EXIF_SRATIONAL 10
120 
124  typedef struct gaiaExifTagStruct
125  {
126 /* an EXIF TAG */
128  char Gps;
130  unsigned short TagId;
132  unsigned short Type;
134  unsigned short Count;
136  unsigned char TagOffset[4];
138  unsigned char *ByteValue;
140  char *StringValue;
142  unsigned short *ShortValues;
144  unsigned int *LongValues;
146  unsigned int *LongRationals1;
148  unsigned int *LongRationals2;
158  float *FloatValues;
160  double *DoubleValues;
163  } gaiaExifTag;
170 
174  typedef struct gaiaExifTagListStruct
175  {
176 /* an EXIF TAG LIST */
182  int NumTags;
185  } gaiaExifTagList;
192 
193 /* function prototipes */
194 
207  GAIAEXIF_DECLARE gaiaExifTagListPtr gaiaGetExifTags (const unsigned char
208  *blob, int size);
209 
220  GAIAEXIF_DECLARE void gaiaExifTagsFree (gaiaExifTagListPtr tag_list);
221 
231  GAIAEXIF_DECLARE int gaiaGetExifTagsCount (gaiaExifTagListPtr tag_list);
232 
244  tag_list,
245  const int pos);
246 
256  GAIAEXIF_DECLARE int gaiaGetExifTagsCount (gaiaExifTagListPtr tag_list);
257 
268  GAIAEXIF_DECLARE gaiaExifTagPtr gaiaGetExifTagById (const
270  tag_list,
271  const unsigned short
272  tag_id);
273 
284  GAIAEXIF_DECLARE gaiaExifTagPtr gaiaGetExifGpsTagById (const
286  tag_list,
287  const unsigned
288  short tag_id);
289 
300  GAIAEXIF_DECLARE gaiaExifTagPtr gaiaGetExifTagByName (const
302  tag_list,
303  const char *tag_name);
304 
314  GAIAEXIF_DECLARE unsigned short gaiaExifTagGetId (const gaiaExifTagPtr tag);
315 
325  GAIAEXIF_DECLARE void gaiaExifTagGetName (const gaiaExifTagPtr tag,
326  char *tag_name, int len);
327 
337  GAIAEXIF_DECLARE int gaiaIsExifGpsTag (const gaiaExifTagPtr tag);
338 
350  GAIAEXIF_DECLARE unsigned short gaiaExifTagGetValueType (const
352  tag);
353 
363  GAIAEXIF_DECLARE unsigned short gaiaExifTagGetNumValues (const
365  tag);
366 
379  GAIAEXIF_DECLARE unsigned char gaiaExifTagGetByteValue (const
381  tag,
382  const int ind,
383  int *ok);
384 
396  GAIAEXIF_DECLARE void gaiaExifTagGetStringValue (const gaiaExifTagPtr tag,
397  char *str, int len,
398  int *ok);
399 
412  GAIAEXIF_DECLARE unsigned short gaiaExifTagGetShortValue (const
414  tag,
415  const int ind,
416  int *ok);
417 
430  GAIAEXIF_DECLARE unsigned int gaiaExifTagGetLongValue (const
431  gaiaExifTagPtr tag,
432  const int ind,
433  int *ok);
434 
447  GAIAEXIF_DECLARE unsigned int gaiaExifTagGetRational1Value (const
449  tag,
450  const int ind,
451  int *ok);
452 
465  GAIAEXIF_DECLARE unsigned int gaiaExifTagGetRational2Value (const
467  tag,
468  const int ind,
469  int *ok);
470 
483  GAIAEXIF_DECLARE double gaiaExifTagGetRationalValue (const gaiaExifTagPtr
484  tag, const int ind,
485  int *ok);
486 
499  GAIAEXIF_DECLARE short gaiaExifTagGetSignedShortValue (const
500  gaiaExifTagPtr tag,
501  const int ind,
502  int *ok);
503 
516  GAIAEXIF_DECLARE int gaiaExifTagGetSignedLongValue (const gaiaExifTagPtr
517  tag, const int ind,
518  int *ok);
519 
532  GAIAEXIF_DECLARE int gaiaExifTagGetSignedRational1Value (const
534  tag,
535  const int ind,
536  int *ok);
537 
550  GAIAEXIF_DECLARE int gaiaExifTagGetSignedRational2Value (const
552  tag,
553  const int ind,
554  int *ok);
555 
568  GAIAEXIF_DECLARE double gaiaExifTagGetSignedRationalValue (const
570  tag,
571  const int ind,
572  int *ok);
573 
586  GAIAEXIF_DECLARE float gaiaExifTagGetFloatValue (const gaiaExifTagPtr tag,
587  const int ind, int *ok);
588 
601  GAIAEXIF_DECLARE double gaiaExifTagGetDoubleValue (const gaiaExifTagPtr
602  tag, const int ind,
603  int *ok);
604 
615  GAIAEXIF_DECLARE void gaiaExifTagGetHumanReadable (const gaiaExifTagPtr
616  tag, char *str,
617  int len, int *ok);
618 
630  GAIAEXIF_DECLARE int gaiaGuessBlobType (const unsigned char *blob,
631  int size);
645  GAIAEXIF_DECLARE int gaiaGetGpsCoords (const unsigned char *blob,
646  int size, double *longitude,
647  double *latitude);
661  GAIAEXIF_DECLARE int gaiaGetGpsLatLong (const unsigned char *blob,
662  int size, char *latlong,
663  int ll_size);
664 
665 #ifdef __cplusplus
666 }
667 #endif
668 
669 #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:182
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:130
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:191
unsigned int * LongValues
array of LONG values ]
Definition: gaiaexif.h:144
char Gps
GPS data included (0/1)
Definition: gaiaexif.h:128
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:124
unsigned int * LongRationals1
array of RATIONAL values [numerators]
Definition: gaiaexif.h:146
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:154
Container for a list of EXIF tags.
Definition: gaiaexif.h:174
unsigned short Type
EXIF value type.
Definition: gaiaexif.h:132
GAIAEXIF_DECLARE void gaiaExifTagsFree(gaiaExifTagListPtr tag_list)
Destroy a list of EXIF tags.
unsigned char * ByteValue
array of BYTE values
Definition: gaiaexif.h:138
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:152
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:169
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:136
unsigned short * ShortValues
array of SHORT values
Definition: gaiaexif.h:142
gaiaExifTagPtr First
pointer to first item into the linked list
Definition: gaiaexif.h:178
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:158
double * DoubleValues
array of DOUBLE values
Definition: gaiaexif.h:160
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:162
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:140
int * SignedLongRationals2
array of Signed RATIONAL values [denominators]
Definition: gaiaexif.h:156
unsigned short Count
number of values
Definition: gaiaexif.h:134
gaiaExifTagPtr Last
pointer to the last item into the linked list
Definition: gaiaexif.h:180
unsigned int * LongRationals2
array of RATIONAL values [denominators]
Definition: gaiaexif.h:148
gaiaExifTagPtr * TagsArray
an array of pointers to items
Definition: gaiaexif.h:184
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:150
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.