gdalexif.h 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  1. /******************************************************************************
  2. * $Id: gdalexif.h 24549 2012-06-09 20:14:14Z rouault $
  3. *
  4. * Project: JPEG JFIF Driver
  5. * Purpose: Implement GDAL JPEG Support based on IJG libjpeg.
  6. * Author: Frank Warmerdam, warmerdam@pobox.com
  7. *
  8. ******************************************************************************
  9. * Copyright (c) 2000, Frank Warmerdam
  10. *
  11. * Permission is hereby granted, free of charge, to any person obtaining a
  12. * copy of this software and associated documentation files (the "Software"),
  13. * to deal in the Software without restriction, including without limitation
  14. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  15. * and/or sell copies of the Software, and to permit persons to whom the
  16. * Software is furnished to do so, subject to the following conditions:
  17. *
  18. * The above copyright notice and this permission notice shall be included
  19. * in all copies or substantial portions of the Software.
  20. *
  21. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  22. * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  23. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  24. * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  25. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  26. * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  27. * DEALINGS IN THE SOFTWARE.
  28. ****************************************************************************/
  29. #define EXIFOFFSETTAG 0x8769
  30. #define INTEROPERABILITYOFFSET 0xA005
  31. #define GPSOFFSETTAG 0x8825
  32. #define MAXSTRINGLENGTH 65535
  33. #ifdef RENAME_INTERNAL_LIBTIFF_SYMBOLS
  34. #include "../frmts/gtiff/libtiff/gdal_libtiff_symbol_rename.h"
  35. #endif
  36. static const struct gpsname {
  37. GUInt16 tag;
  38. const char* name;
  39. } gpstags [] = {
  40. { 0x00, "EXIF_GPSVersionID" },
  41. { 0x01, "EXIF_GPSLatitudeRef" },
  42. { 0x02, "EXIF_GPSLatitude" },
  43. { 0x03, "EXIF_GPSLongitudeRef" },
  44. { 0x04, "EXIF_GPSLongitude" },
  45. { 0x05, "EXIF_GPSAltitudeRef" },
  46. { 0x06, "EXIF_GPSAltitude" },
  47. { 0x07, "EXIF_GPSTimeStamp" },
  48. { 0x08, "EXIF_GPSSatellites" },
  49. { 0x09, "EXIF_GPSStatus" },
  50. { 0x0a, "EXIF_GPSMeasureMode" },
  51. { 0x0b, "EXIF_GPSDOP" },
  52. { 0x0c, "EXIF_GPSSpeedRef"},
  53. { 0x0d, "EXIF_GPSSpeed"},
  54. { 0x0e, "EXIF_GPSTrackRef"},
  55. { 0x0f, "EXIF_GPSTrack"},
  56. { 0x10, "EXIF_GPSImgDirectionRef"},
  57. { 0x11, "EXIF_GPSImgDirection"},
  58. { 0x12, "EXIF_GPSMapDatum"},
  59. { 0x13, "EXIF_GPSDestLatitudeRef"},
  60. { 0x14, "EXIF_GPSDestLatitude"},
  61. { 0x15, "EXIF_GPSDestLongitudeRef"},
  62. { 0x16, "EXIF_GPSDestLongitude"},
  63. { 0x17, "EXIF_GPSDestBearingRef"},
  64. { 0x18, "EXIF_GPSDestBearing"},
  65. { 0x19, "EXIF_GPSDestDistanceRef"},
  66. { 0x1a, "EXIF_GPSDestDistance"},
  67. { 0x1b, "EXIF_GPSProcessingMethod"},
  68. { 0x1c, "EXIF_GPSAreaInformation"},
  69. { 0x1d, "EXIF_GPSDateStamp"},
  70. { 0x1e, "EXIF_GPSDifferential"},
  71. { 0xffff, ""}
  72. };
  73. static const struct tagname {
  74. GUInt16 tag;
  75. const char* name;
  76. } tagnames [] = {
  77. // { 0x100, "EXIF_Image_Width"},
  78. // { 0x101, "EXIF_Image_Length"},
  79. { 0x102, "EXIF_BitsPerSample"},
  80. { 0x103, "EXIF_Compression"},
  81. { 0x106, "EXIF_PhotometricInterpretation"},
  82. { 0x10A, "EXIF_Fill_Order"},
  83. { 0x10D, "EXIF_Document_Name"},
  84. { 0x10E, "EXIF_ImageDescription"},
  85. { 0x10F, "EXIF_Make"},
  86. { 0x110, "EXIF_Model"},
  87. { 0x111, "EXIF_StripOffsets"},
  88. { 0x112, "EXIF_Orientation"},
  89. { 0x115, "EXIF_SamplesPerPixel"},
  90. { 0x116, "EXIF_RowsPerStrip"},
  91. { 0x117, "EXIF_StripByteCounts"},
  92. { 0x11A, "EXIF_XResolution"},
  93. { 0x11B, "EXIF_YResolution"},
  94. { 0x11C, "EXIF_PlanarConfiguration"},
  95. { 0x128, "EXIF_ResolutionUnit"},
  96. { 0x12D, "EXIF_TransferFunction"},
  97. { 0x131, "EXIF_Software"},
  98. { 0x132, "EXIF_DateTime"},
  99. { 0x13B, "EXIF_Artist"},
  100. { 0x13E, "EXIF_WhitePoint"},
  101. { 0x13F, "EXIF_PrimaryChromaticities"},
  102. { 0x156, "EXIF_Transfer_Range"},
  103. { 0x200, "EXIF_JPEG_Proc"},
  104. { 0x201, "EXIF_JPEGInterchangeFormat"},
  105. { 0x202, "EXIF_JPEGInterchangeFormatLength"},
  106. { 0x211, "EXIF_YCbCrCoefficients"},
  107. { 0x212, "EXIF_YCbCrSubSampling"},
  108. { 0x213, "EXIF_YCbCrPositioning"},
  109. { 0x214, "EXIF_ReferenceBlackWhite"},
  110. { 0x828D, "EXIF_CFA_Repeat_Pattern_Dim"},
  111. { 0x828E, "EXIF_CFA_Pattern"},
  112. { 0x828F, "EXIF_Battery_Level"},
  113. { 0x8298, "EXIF_Copyright"},
  114. { 0x829A, "EXIF_ExposureTime"},
  115. { 0x829D, "EXIF_FNumber"},
  116. { 0x83BB, "EXIF_IPTC/NAA"},
  117. // { 0x8769, "EXIF_Offset"},
  118. { 0x8773, "EXIF_Inter_Color_Profile"},
  119. { 0x8822, "EXIF_ExposureProgram"},
  120. { 0x8824, "EXIF_SpectralSensitivity"},
  121. // { 0x8825, "EXIF_GPSOffset"},
  122. { 0x8827, "EXIF_ISOSpeedRatings"},
  123. { 0x8828, "EXIF_OECF"},
  124. { 0x9000, "EXIF_ExifVersion"},
  125. { 0x9003, "EXIF_DateTimeOriginal"},
  126. { 0x9004, "EXIF_DateTimeDigitized"},
  127. { 0x9101, "EXIF_ComponentsConfiguration"},
  128. { 0x9102, "EXIF_CompressedBitsPerPixel"},
  129. { 0x9201, "EXIF_ShutterSpeedValue"},
  130. { 0x9202, "EXIF_ApertureValue"},
  131. { 0x9203, "EXIF_BrightnessValue"},
  132. { 0x9204, "EXIF_ExposureBiasValue"},
  133. { 0x9205, "EXIF_MaxApertureValue"},
  134. { 0x9206, "EXIF_SubjectDistance"},
  135. { 0x9207, "EXIF_MeteringMode"},
  136. { 0x9208, "EXIF_LightSource"},
  137. { 0x9209, "EXIF_Flash"},
  138. { 0x920A, "EXIF_FocalLength"},
  139. { 0x9214, "EXIF_SubjectArea"},
  140. { 0x927C, "EXIF_MakerNote"},
  141. { 0x9286, "EXIF_UserComment"},
  142. { 0x9290, "EXIF_SubSecTime"},
  143. { 0x9291, "EXIF_SubSecTime_Original"},
  144. { 0x9292, "EXIF_SubSecTime_Digitized"},
  145. { 0xA000, "EXIF_FlashpixVersion"},
  146. { 0xA001, "EXIF_ColorSpace"},
  147. { 0xA002, "EXIF_PixelXDimension"},
  148. { 0xA003, "EXIF_PixelYDimension"},
  149. { 0xA004, "EXIF_RelatedSoundFile"},
  150. // { 0xA005, "EXIF_InteroperabilityOffset"},
  151. { 0xA20B, "EXIF_FlashEnergy"}, // 0x920B in TIFF/EP
  152. { 0xA20C, "EXIF_SpatialFrequencyResponse"}, // 0x920C - -
  153. { 0xA20E, "EXIF_FocalPlaneXResolution"}, // 0x920E - -
  154. { 0xA20F, "EXIF_FocalPlaneYResolution"}, // 0x920F - -
  155. { 0xA210, "EXIF_FocalPlaneResolutionUnit"}, // 0x9210 - -
  156. { 0xA214, "EXIF_SubjectLocation"}, // 0x9214 - -
  157. { 0xA215, "EXIF_ExposureIndex"}, // 0x9215 - -
  158. { 0xA217, "EXIF_SensingMethod"}, // 0x9217 - -
  159. { 0xA300, "EXIF_FileSource"},
  160. { 0xA301, "EXIF_SceneType"},
  161. { 0xA302, "EXIF_CFAPattern"},
  162. { 0xA401, "EXIF_CustomRendered"},
  163. { 0xA402, "EXIF_ExposureMode"},
  164. { 0XA403, "EXIF_WhiteBalance"},
  165. { 0xA404, "EXIF_DigitalZoomRatio"},
  166. { 0xA405, "EXIF_FocalLengthIn35mmFilm"},
  167. { 0xA406, "EXIF_SceneCaptureType"},
  168. { 0xA407, "EXIF_GainControl"},
  169. { 0xA408, "EXIF_Contrast"},
  170. { 0xA409, "EXIF_Saturation"},
  171. { 0xA40A, "EXIF_Sharpness"},
  172. { 0xA40B, "EXIF_DeviceSettingDescription"},
  173. { 0xA40C, "EXIF_SubjectDistanceRange"},
  174. { 0xA420, "EXIF_ImageUniqueID"},
  175. { 0x0000, ""}
  176. };
  177. static const struct intr_tag {
  178. GInt16 tag;
  179. const char* name;
  180. } intr_tags [] = {
  181. { 0x1, "EXIF_Interoperability_Index"},
  182. { 0x2, "EXIF_Interoperability_Version"},
  183. { 0x1000, "EXIF_Related_Image_File_Format"},
  184. { 0x1001, "EXIF_Related_Image_Width"},
  185. { 0x1002, "EXIF_Related_Image_Length"},
  186. { 0x0000, ""}
  187. };
  188. typedef enum {
  189. TIFF_NOTYPE = 0, /* placeholder */
  190. TIFF_BYTE = 1, /* 8-bit unsigned integer */
  191. TIFF_ASCII = 2, /* 8-bit bytes w/ last byte null */
  192. TIFF_SHORT = 3, /* 16-bit unsigned integer */
  193. TIFF_LONG = 4, /* 32-bit unsigned integer */
  194. TIFF_RATIONAL = 5, /* 64-bit unsigned fraction */
  195. TIFF_SBYTE = 6, /* !8-bit signed integer */
  196. TIFF_UNDEFINED = 7, /* !8-bit untyped data */
  197. TIFF_SSHORT = 8, /* !16-bit signed integer */
  198. TIFF_SLONG = 9, /* !32-bit signed integer */
  199. TIFF_SRATIONAL = 10, /* !64-bit signed fraction */
  200. TIFF_FLOAT = 11, /* !32-bit IEEE floating point */
  201. TIFF_DOUBLE = 12, /* !64-bit IEEE floating point */
  202. TIFF_IFD = 13 /* %32-bit unsigned integer (offset) */
  203. } TIFFDataType;
  204. /*
  205. * TIFF Image File Directories are comprised of a table of field
  206. * descriptors of the form shown below. The table is sorted in
  207. * ascending order by tag. The values associated with each entry are
  208. * disjoint and may appear anywhere in the file (so long as they are
  209. * placed on a word boundary).
  210. *
  211. * If the value is 4 bytes or less, then it is placed in the offset
  212. * field to save space. If the value is less than 4 bytes, it is
  213. * left-justified in the offset field.
  214. */
  215. typedef struct {
  216. GUInt16 tdir_tag; /* see below */
  217. GUInt16 tdir_type; /* data type; see below */
  218. GUInt32 tdir_count; /* number of items; length in spec */
  219. GUInt32 tdir_offset; /* byte offset to field data */
  220. } TIFFDirEntry;
  221. CPL_C_START
  222. extern int TIFFDataWidth(TIFFDataType); /* table of tag datatype widths */
  223. extern void TIFFSwabShort(GUInt16*);
  224. extern void TIFFSwabLong(GUInt32*);
  225. extern void TIFFSwabDouble(double*);
  226. extern void TIFFSwabArrayOfShort(GUInt16*, unsigned long);
  227. extern void TIFFSwabArrayOfLong(GUInt32*, unsigned long);
  228. extern void TIFFSwabArrayOfDouble(double*, unsigned long);
  229. CPL_C_END