2 * Copyright (C) 2005 Lars Ellenberg
3 * Copyright (C) 2005 John Ellis
4 * Copyright (C) 2008 - 2016 The Geeqie Team
6 * Author: Lars Ellenberg
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License along
19 * with this program; if not, write to the Free Software Foundation, Inc.,
20 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
27 #include "format-fuji.h"
39 *-----------------------------------------------------------------------------
40 * Raw (RAF) embedded jpeg extraction for Fujifilm
41 *-----------------------------------------------------------------------------
45 gboolean format_fuji_raw(guchar *data, const guint len,
46 guint *image_offset, guint *exif_offset)
52 memcmp(data, "FUJIFILM", 8) != 0)
57 /* offset to jpeg is embedded at bytes 84-87 */
58 io = exif_byte_get_int32(data + 84, EXIF_BYTE_ORDER_MOTOROLA);
59 if (io + 4 > len) return FALSE;
61 /* verify jpeg marker */
62 if (memcmp(data + io, "\xff\xd8\xff\xe1", 4) != 0)
67 /* Exif is stored in the jpeg, so use the same offset */
70 if (image_offset) *image_offset = io;
71 if (exif_offset) *exif_offset = eo;
78 *-----------------------------------------------------------------------------
79 * EXIF Makernote for Fujifilm
80 *-----------------------------------------------------------------------------
83 static ExifTextList FujiTagSharpness[] = {
92 static ExifTextList FujiTagWhiteBalance[]= {
96 { 768, "daylight color-fluorescence" },
97 { 769, "daywhite color-fluorescence" },
98 { 770, "white-fluorescence" },
99 { 1024, "incandescent" },
104 static ExifTextList FujiTagColorTone[]= {
111 static ExifTextList FujiTagFlashMode[]= {
115 { 3, "red-eye reduction" },
119 static ExifTextList FujiTagOffOn[]= {
125 static ExifTextList FujiTagFocusMode[]= {
131 static ExifTextList FujiTagPictureMode[]= {
138 { 256, "aperture priority AE" },
139 { 512, "shutter priority AE" },
144 static ExifTextList FujiTagNoYes[]= {
151 static ExifMarker FujiExifMarkersList[] = {
152 { 0x1000, EXIF_FORMAT_STRING, 8, "Fuji.Quality", "Quality", nullptr },
153 { 0x1001, EXIF_FORMAT_SHORT_UNSIGNED, 1, "Fuji.Sharpness", "Sharpness", FujiTagSharpness },
154 { 0x1002, EXIF_FORMAT_SHORT_UNSIGNED, 1, "Fuji.WhiteBalance", "White balance",FujiTagWhiteBalance },
155 { 0x1003, EXIF_FORMAT_SHORT_UNSIGNED, 1, "Fuji.Color", "Color", FujiTagColorTone },
156 { 0x1004, EXIF_FORMAT_SHORT_UNSIGNED, 1, "Fuji.Tone", "Tone", FujiTagColorTone },
157 { 0x1010, EXIF_FORMAT_SHORT_UNSIGNED, 1, "Fuji.FlashMode", "Flash mode", FujiTagFlashMode },
158 { 0x1011, EXIF_FORMAT_RATIONAL, 1, "Fuji.FlashStrength", "Flash strength", nullptr },
159 { 0x1020, EXIF_FORMAT_SHORT_UNSIGNED, 1, "Fuji.Macro", "Macro", FujiTagOffOn },
160 { 0x1021, EXIF_FORMAT_SHORT_UNSIGNED, 1, "Fuji.FocusMode", "Focus mode", FujiTagFocusMode },
161 { 0x1030, EXIF_FORMAT_SHORT_UNSIGNED, 1, "Fuji.SlowSync", "Slow synchro", FujiTagOffOn },
162 { 0x1031, EXIF_FORMAT_SHORT_UNSIGNED, 1, "Fuji.PictureMode", "Picture mode", FujiTagPictureMode },
163 { 0x1100, EXIF_FORMAT_SHORT_UNSIGNED, 1, "Fuji.ContTake/Bracket",
164 "Continuous / Auto bracket", FujiTagOffOn },
165 { 0x1300, EXIF_FORMAT_SHORT_UNSIGNED, 1, "Fuji.BlurWarning", "Blue warning", FujiTagNoYes },
166 { 0x1301, EXIF_FORMAT_SHORT_UNSIGNED, 1, "Fuji.FocusWarning", "Focus warning",FujiTagNoYes },
167 { 0x1302, EXIF_FORMAT_SHORT_UNSIGNED, 1, "Fuji.AEWarning", "AE warning", FujiTagNoYes },
173 gboolean format_fuji_makernote(ExifData *exif, guchar *tiff, guint offset,
174 guint size, ExifByteOrder)
179 if (offset + 8 + 4 >= size) return FALSE;
181 data = tiff + offset;
183 /* Fuji tag format starts with "FUJIFILM",
184 * followed by 4 bytes indicating offset to IFD directory using Fuji tags,
185 * byte order is always little endian (II).
187 if (memcmp(data, "FUJIFILM", 8) != 0) return FALSE;
189 ifdstart = exif_byte_get_int32(data + 8, EXIF_BYTE_ORDER_INTEL);
190 if (offset + ifdstart >= size) return FALSE;
192 if (exif_parse_IFD_table(exif, tiff + offset, ifdstart, size - offset,
193 EXIF_BYTE_ORDER_INTEL, 0, FujiExifMarkersList) != 0)
201 using dummy_variable = int;
204 /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */