5 * This software is released under the GNU General Public License (GNU GPL).
6 * Please read the included file COPYING for more information.
7 * This software comes with no warranty of any kind, use at your own risk!
23 #include "format_olympus.h"
24 #include "format_raw.h"
30 *-----------------------------------------------------------------------------
31 * EXIF Makernote for Olympus
32 *-----------------------------------------------------------------------------
35 static ExifTextList KonMinTagColorMode[]= {
37 { 1, "black and white" },
39 { 3, "solarization" },
44 static ExifTextList KonMinTagQuality[]= {
53 static ExifTextList OlympusTagJpegQuality[]= {
60 static ExifTextList OlympusTagMacro[]= {
68 static ExifTextList OlympusTagFlashMode[]= {
70 { 1, "red-eye reduction" },
76 static ExifTextList OlympusTagFocusMode[]= {
82 static ExifTextList OlympusTagSharpness[]= {
89 static ExifTextList OlympusTagContrast[]= {
97 static ExifTextList OlympusTag[]= {
105 static ExifMarker OlympusExifMarkersList[] = {
106 { 0x0001, EXIF_FORMAT_LONG_UNSIGNED, -1, "Konica/MinoltaSettings", "Konica / Minolta settings", NULL },
107 { 0x0003, EXIF_FORMAT_LONG_UNSIGNED, -1, "Konica/MinoltaSettings", "Konica / Minolta settings", NULL },
108 { 0x0040, EXIF_FORMAT_LONG_UNSIGNED, -1, "CompressedImageSize", "Compressed image size", NULL },
109 { 0x0081, EXIF_FORMAT_LONG_UNSIGNED, 1, "ThumbnailOffset", "Thumbnail offset", NULL },
110 { 0x0088, EXIF_FORMAT_LONG_UNSIGNED, 1, "ThumbnailOffset", "Thumbnail offset", NULL },
111 { 0x0089, EXIF_FORMAT_LONG_UNSIGNED, 1, "ThumbnailLength", "Thumbnail length", NULL },
112 { 0x0101, EXIF_FORMAT_SHORT_UNSIGNED, 1, "Konica/Minolta.ColorMode", "Color mode", KonMinTagColorMode },
113 { 0x0102, EXIF_FORMAT_SHORT_UNSIGNED, 1, "Konica/Minolta.Quality", "Quality", KonMinTagQuality },
114 { 0x0103, EXIF_FORMAT_SHORT_UNSIGNED, 1, "Konica/Minolta.Quality", "Quality", KonMinTagQuality },
115 { 0x0200, EXIF_FORMAT_LONG_UNSIGNED, 3, "Olympus.SpecialMode", "Special mode", NULL },
116 { 0x0201, EXIF_FORMAT_SHORT_UNSIGNED, 1, "Olympus.JpegQuality", "Jpeg quality", OlympusTagJpegQuality },
117 { 0x0202, EXIF_FORMAT_SHORT_UNSIGNED, 1, "Olympus.Macro", "Macro", OlympusTagMacro },
118 { 0x0204, EXIF_FORMAT_RATIONAL_UNSIGNED, 1, "Olympus.DigitalZoom", "Digital zoom", NULL },
119 { 0x0207, EXIF_FORMAT_STRING, -1, "Olympus.Firmware", "Firmware version", NULL },
120 { 0x0208, EXIF_FORMAT_STRING, -1, "Olympus.PictureInfo", "Picture info", NULL },
121 { 0x0209, EXIF_FORMAT_UNDEFINED, -1, "Olympus.CameraID", "Camera ID", NULL },
122 { 0x020b, EXIF_FORMAT_LONG_UNSIGNED, 1, "Epson.ImageWidth", "Image width", NULL },
123 { 0x020c, EXIF_FORMAT_LONG_UNSIGNED, 1, "Epson.ImageHeight", "Image height", NULL },
124 { 0x020d, EXIF_FORMAT_STRING, -1, "Epson.Manufacturer", "Manufacturer", NULL },
125 { 0x0e00, EXIF_FORMAT_BYTE, -1, "Olympus.PrintImageMatching", "Print image matching", NULL },
126 { 0x1004, EXIF_FORMAT_SHORT_UNSIGNED, 1, "Olympus.FlashMode", "Flash mode", OlympusTagFlashMode },
127 { 0x1006, EXIF_FORMAT_SHORT_UNSIGNED, 1, "Olympus.Bracket", "Bracket", NULL },
128 { 0x100b, EXIF_FORMAT_SHORT_UNSIGNED, 1, "Olympus.FocusMode", "Focus mode", OlympusTagFocusMode },
129 { 0x100c, EXIF_FORMAT_SHORT_UNSIGNED, 1, "Olympus.FocusDistance", "Focus distance", NULL },
130 { 0x100d, EXIF_FORMAT_SHORT_UNSIGNED, 1, "Olympus.Zoom", "Zoom", NULL },
131 { 0x1006, EXIF_FORMAT_SHORT_UNSIGNED, 1, "Olympus.MacroFocus", "Macro focus", NULL },
132 { 0x100f, EXIF_FORMAT_SHORT_UNSIGNED, 1, "Olympus.Sharpness", "Sharpness", OlympusTagSharpness },
133 { 0x1011, EXIF_FORMAT_SHORT_UNSIGNED, 9, "Olympus.ColorMatrix", "Color matrix", NULL },
134 { 0x1012, EXIF_FORMAT_SHORT_UNSIGNED, 4, "Olympus.BlackLevel", "Black level", NULL },
135 { 0x1015, EXIF_FORMAT_SHORT_UNSIGNED, 2, "Olympus.WhiteBalance", "White balance", NULL },
136 { 0x1017, EXIF_FORMAT_SHORT_UNSIGNED, 2, "Olympus.RedBias", "Red bias", NULL },
137 { 0x1018, EXIF_FORMAT_SHORT_UNSIGNED, 2, "Olympus.BlueBias", "Blue bias", NULL },
138 { 0x101a, EXIF_FORMAT_SHORT_UNSIGNED, 1, "Olympus.SerialNumber", "Serial number", NULL },
139 { 0x1023, EXIF_FORMAT_SHORT_UNSIGNED, 1, "Olympus.FlashBias", "Flash bias", NULL },
140 { 0x1029, EXIF_FORMAT_SHORT_UNSIGNED, 1, "Olympus.Contrast", "Contrast", OlympusTagContrast },
141 { 0x102a, EXIF_FORMAT_SHORT_UNSIGNED, 1, "Olympus.SharpnessFactor", "Sharpness factor", NULL },
142 { 0x102b, EXIF_FORMAT_SHORT_UNSIGNED, 6, "Olympus.ColorControl", "Color control", NULL },
143 { 0x102c, EXIF_FORMAT_SHORT_UNSIGNED, 2, "Olympus.ValidBits", "Valid bits", NULL },
144 { 0x102d, EXIF_FORMAT_SHORT_UNSIGNED, 1, "Olympus.CoringFilter", "Coring filter", NULL },
145 { 0x102e, EXIF_FORMAT_LONG_UNSIGNED, 1, "Olympus.FinalWidth", "Final width", NULL },
146 { 0x102f, EXIF_FORMAT_LONG_UNSIGNED, 1, "Olympus.FinalHeight", "Final height", NULL },
147 { 0x1034, EXIF_FORMAT_SHORT_UNSIGNED, 1, "Olympus.CompressionRatio", "Compression ratio", NULL },
151 static ExifTextList OlympusShootingMode[]= {
159 static ExifTextList OlympusPanoramaDirection[]= {
160 { 1, "left to right" },
161 { 2, "right to left" },
162 { 3, "bottom to top" },
163 { 4, "top to bottom" },
167 static ExifTextList OlympusWB[]= {
174 static ExifTextList OlympusWBColorTemp[]= {
185 gint format_olympus_makernote(ExifData *exif, unsigned char *tiff, guint offset,
186 guint size, ExifByteOrder bo)
191 if (offset + 8 + 4 >= size) return FALSE;
193 data = tiff + offset;
195 /* Olympus tag format starts with "OLYMP\x00\x01" or "OLYMP\x00\x02",
196 * plus an unknown byte,
197 * followed by IFD data using Olympus tags.
199 if (memcmp(data, "OLYMP\x00\x01", 7) != 0 &&
200 memcmp(data, "OLYMP\x00\x02", 7) != 0) return FALSE;
202 if (exif_parse_IFD_table(exif, tiff, offset + 8, size,
203 bo, 0, OlympusExifMarkersList) != 0)
208 item = exif_get_item(exif, "Olympus.SpecialMode");
209 if (item && item->data_len == 3 * sizeof(guint32))
211 static ExifMarker marker = { 0x0200, EXIF_FORMAT_STRING, -1,
212 "Olympus.ShootingMode", "Shooting mode", NULL };
213 guint32 *array = item->data;
215 const gchar *pdir = NULL;
219 mode = exif_text_list_find_value(OlympusShootingMode, array[0]);
222 pdir = exif_text_list_find_value(OlympusPanoramaDirection, array[2]);
225 text = g_strdup_printf("%s%s%s, seq %d", (mode) ? mode : "unknown",
226 (pdir) ? " " : "", (pdir) ? pdir : "",
228 l = strlen(text) + 1;
229 item = exif_item_new(marker.format, marker.tag, l, &marker);
230 memcpy(item->data, text, l);
233 exif->items = g_list_prepend(exif->items, item);
236 item = exif_get_item(exif, "Olympus.WhiteBalance");
237 if (item && item->data_len == 2 * sizeof(guint16))
239 static ExifMarker marker = { 0x1015, EXIF_FORMAT_STRING, -1,
240 "Olympus.WhiteBalance", "White balance", NULL };
241 guint16 *array = item->data;
243 const gchar *color = NULL;
247 mode = exif_text_list_find_value(OlympusWB, array[0]);
250 color = exif_text_list_find_value(OlympusWBColorTemp, array[1]);
253 text = g_strdup_printf("%s%s%s", (mode) ? mode : "unknown",
254 (color) ? " " : "", (color) ? color : "");
255 l = strlen(text) + 1;
256 item = exif_item_new(marker.format, marker.tag, l, &marker);
257 memcpy(item->data, text, l);
260 exif->items = g_list_prepend(exif->items, item);