1 /* Exif metadata utilities.
2  * Derived from Darktable (http://www.darktable.org/)
3  */
4 
5 /*
6 
7     Copyright (C) 2014 Ferrero Andrea
8 
9     This program is free software: you can redistribute it and/or modify
10     it under the terms of the GNU General Public License as published by
11     the Free Software Foundation, either version 3 of the License, or
12     (at your option) any later version.
13 
14     This program is distributed in the hope that it will be useful,
15     but WITHOUT ANY WARRANTY; without even the implied warranty of
16     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17     GNU General Public License for more details.
18 
19     You should have received a copy of the GNU General Public License
20     along with this program. If not, see <http://www.gnu.org/licenses/>.
21 
22 
23  */
24 
25 /*
26 
27     These files are distributed with PhotoFlow - http://aferrero2707.github.io/PhotoFlow/
28 
29  */
30 
31 #ifndef PF_EXIF_DATA_H
32 #define PF_EXIF_DATA_H
33 
34 #include <glib.h>
35 
36 #include <vips/vips.h>
37 
38 #ifdef BUNDLED_EXIV2
39 #include <external/exiv2/include/exiv2/easyaccess.hpp>
40 #include <external/exiv2/include/exiv2/xmp.hpp>
41 #include <external/exiv2/include/exiv2/error.hpp>
42 #include <external/exiv2/include/exiv2/image.hpp>
43 #include <external/exiv2/include/exiv2/exif.hpp>
44 #else
45 //#include <exiv2/easyaccess.hpp>
46 //#include <exiv2/xmp.hpp>
47 //#include <exiv2/error.hpp>
48 //#include <exiv2/image.hpp>
49 //#include <exiv2/exif.hpp>
50 #include <exiv2/exiv2.hpp>
51 #endif
52 
53 
54 #define PF_META_EXIF_NAME "custom-exif-data"
55 #define PF_META_EXIV2_NAME "exiv2-data"
56 //#define PF_META_EXIF_NAME VIPS_META_EXIF_NAME
57 
58 namespace PF
59 {
60 
61 
62 
63 
64 typedef enum {
65   PF_EXIF_ORIENTATION_MIN      = 0,
66   PF_EXIF_ORIENTATION_UNSPECIFIED  = 0,
67   PF_EXIF_ORIENTATION_NORMAL   = 1,
68   PF_EXIF_ORIENTATION_HFLIP    = 2,
69   PF_EXIF_ORIENTATION_ROT_180    = 3,
70   PF_EXIF_ORIENTATION_VFLIP    = 4,
71   PF_EXIF_ORIENTATION_ROT_90_HFLIP = 5,
72   PF_EXIF_ORIENTATION_ROT_90   = 6,
73   PF_EXIF_ORIENTATION_ROT_90_VFLIP = 7,
74   PF_EXIF_ORIENTATION_ROT_270    = 8,
75   PF_EXIF_ORIENTATION_MAX      = 8
76 } ExifOrientation;
77 
78 
79 struct exif_data_t
80 {
81   float exif_exposure;
82   float exif_aperture;
83   float exif_iso;
84   float exif_focal_length;
85   float exif_focus_distance;
86   float exif_crop;
87   char exif_maker[64];
88   char exif_model[64];
89   char exif_lens[128];
90   char exif_lens_alt[128];
91   char exif_datetime_taken[20];
92   char camera_maker[64];
93   char camera_model[64];
94   char camera_alias[64];
95   char camera_makermodel[128];
96   char camera_legacy_makermodel[128];
97 
98   exif_data_t();
99 };
100 
101 bool exif_read(exif_data_t* data, const char* path);
102 
103 void exif_free (gpointer mem);
104 
105 class exiv2_data_t
106 {
107 public:
108   Exiv2::Image::AutoPtr image;
109   uint8_t* blob;
110   int length;
exiv2_data_t()111   exiv2_data_t(): image(NULL), blob(NULL), length(0) {}
112 };
113 
114 void exiv2_free (gpointer mem);
115 
116 exif_data_t* get_exif_data( VipsImage* img );
117 
118 int dt_exif_write_blob(uint8_t *blob, uint32_t size, const char *path, const int sRGB, const int out_width, const int out_height);
119 int dt_exif_read_blob(uint8_t **buf, const char *path, const int imgid, const int out_width,
120                       const int out_height, const int dng_mode);
121 
122 }
123 
124 #endif
125