exif-aerial 2.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: b754c96357d99e596c4198ceaff8a2e5e19a7795
4
+ data.tar.gz: 665d875fe1b752a1c9d098f53aef4dd881bcc87f
5
+ SHA512:
6
+ metadata.gz: 675e3119813060ff79e91235eda0ac173435a679adbd90359055e9951195d484708526c23ad70dcaa3e2625c60c884aaa564aa289a8184a124896a452f581af9
7
+ data.tar.gz: 91c3ea8a3a4b831814fc84743bea5c9ff94e6b87a1b58c54fb91477059b3c8e5a523131f63aa31b85ba9e087a79d2f1c8a7ed67ed2b2ee4f3a15341348e9b786
data/ext/exif/data.c ADDED
@@ -0,0 +1,348 @@
1
+ #include "data.h"
2
+ #include "ruby.h"
3
+
4
+ #include <libexif/exif-data.h>
5
+ #include <libexif/exif-loader.h>
6
+ #include <stdint.h>
7
+ #include <time.h>
8
+
9
+ extern VALUE rb_mExif, rb_eNotReadble, rb_eIFDNotFound;
10
+ extern const char *exif_entry_to_ivar(ExifEntry *entry);
11
+
12
+ VALUE rb_cExifData;
13
+ static const char *ifd_name_mapping[] = {"ifd0", "ifd1", "exif", "gps",
14
+ "interoperability"};
15
+ static const char *attr_readers[] = {"ifds",
16
+ "aperture_value",
17
+ "artist",
18
+ "battery_level",
19
+ "bits_per_sample",
20
+ "brightness_value",
21
+ "cfa_pattern",
22
+ "cfa_repeat_pattern_dim",
23
+ "color_space",
24
+ "components_configuration",
25
+ "compressed_bits_per_pixel",
26
+ "compression",
27
+ "contrast",
28
+ "copyright",
29
+ "custom_rendered",
30
+ "date_time",
31
+ "date_time_digitized",
32
+ "date_time_original",
33
+ "device_setting_description",
34
+ "digital_zoom_ratio",
35
+ "document_name",
36
+ "exif_ifd_pointer",
37
+ "exif_version",
38
+ "exposure_bias_value",
39
+ "exposure_index",
40
+ "exposure_mode",
41
+ "exposure_program",
42
+ "exposure_time",
43
+ "file_source",
44
+ "fill_order",
45
+ "flash",
46
+ "flash_energy",
47
+ "flash_pix_version",
48
+ "fnumber",
49
+ "focal_length",
50
+ "focal_length_in_35mm_film",
51
+ "focal_plane_resolution_unit",
52
+ "focal_plane_x_resolution",
53
+ "focal_plane_y_resolution",
54
+ "gain_control",
55
+ "gamma",
56
+ "gps_altitude",
57
+ "gps_altitude_ref",
58
+ "gps_area_information",
59
+ "gps_date_stamp",
60
+ "gps_dest_bearing",
61
+ "gps_dest_bearing_ref",
62
+ "gps_dest_distance",
63
+ "gps_dest_distance_ref",
64
+ "gps_dest_latitude",
65
+ "gps_dest_latitude_ref",
66
+ "gps_dest_longitude",
67
+ "gps_dest_longitude_ref",
68
+ "gps_differential",
69
+ "gps_dop",
70
+ "gps_img_direction",
71
+ "gps_img_direction_ref",
72
+ "gps_info_ifd_pointer",
73
+ "gps_latitude",
74
+ "gps_latitude_ref",
75
+ "gps_longitude",
76
+ "gps_longitude_ref",
77
+ "gps_map_datum",
78
+ "gps_measure_mode",
79
+ "gps_processing_method",
80
+ "gps_satellites",
81
+ "gps_speed",
82
+ "gps_speed_ref",
83
+ "gps_status",
84
+ "gps_time_stamp",
85
+ "gps_track",
86
+ "gps_track_ref",
87
+ "gps_version_id",
88
+ "image_description",
89
+ "image_length",
90
+ "image_resources",
91
+ "image_unique_id",
92
+ "image_width",
93
+ "inter_color_profile",
94
+ "interoperability_ifd_pointer",
95
+ "interoperability_index",
96
+ "interoperability_version",
97
+ "iptc_naa",
98
+ "iso_speed_ratings",
99
+ "jpeg_interchange_format",
100
+ "jpeg_interchange_format_length",
101
+ "jpeg_proc",
102
+ "light_source",
103
+ "make",
104
+ "maker_note",
105
+ "max_aperture_value",
106
+ "metering_mode",
107
+ "model",
108
+ "new_cfa_pattern",
109
+ "new_subfile_type",
110
+ "oecf",
111
+ "orientation",
112
+ "padding",
113
+ "photometric_interpretation",
114
+ "pixel_x_dimension",
115
+ "pixel_y_dimension",
116
+ "planar_configuration",
117
+ "primary_chromaticities",
118
+ "print_image_matching",
119
+ "reference_black_white",
120
+ "related_image_file_format",
121
+ "related_image_length",
122
+ "related_image_width",
123
+ "related_sound_file",
124
+ "resolution_unit",
125
+ "rows_per_strip",
126
+ "samples_per_pixel",
127
+ "saturation",
128
+ "scene_capture_type",
129
+ "scene_type",
130
+ "sensing_method",
131
+ "sharpness",
132
+ "shutter_speed_value",
133
+ "software",
134
+ "spatial_frequency_response",
135
+ "spectral_sensitivity",
136
+ "strip_byte_counts",
137
+ "strip_offsets",
138
+ "sub_ifds",
139
+ "sub_sec_time",
140
+ "sub_sec_time_digitized",
141
+ "sub_sec_time_original",
142
+ "subject_area",
143
+ "subject_distance",
144
+ "subject_distance_range",
145
+ "subject_location",
146
+ "tiff_ep_standard_id",
147
+ "time_zone_offset",
148
+ "transfer_function",
149
+ "transfer_range",
150
+ "user_comment",
151
+ "white_balance",
152
+ "white_point",
153
+ "x_resolution",
154
+ "xml_packet",
155
+ "xp_author",
156
+ "xp_comment",
157
+ "xp_keywords",
158
+ "xp_subject",
159
+ "xp_title",
160
+ "y_resolution",
161
+ "ycbcr_coefficients",
162
+ "ycbcr_positioning",
163
+ "ycbcr_sub_sampling"};
164
+
165
+ static VALUE new (VALUE self, VALUE input);
166
+ static VALUE dump(VALUE self);
167
+ static VALUE brackets(VALUE self, VALUE ifd_symbol);
168
+ static void each_content(ExifContent *ec, void *user_data);
169
+ static void each_entry(ExifEntry *, void *user_data);
170
+ static VALUE exif_entry_to_rb_value(ExifEntry *);
171
+ static VALUE rational_to_num(ExifRational rational);
172
+ static VALUE srational_to_num(ExifSRational srational);
173
+
174
+ void init_data() {
175
+ int length;
176
+
177
+ rb_cExifData = rb_define_class_under(rb_mExif, "Data", rb_cObject);
178
+ length = sizeof(attr_readers) / sizeof(char *);
179
+ for (int i = 0; i < length; ++i)
180
+ rb_define_attr(rb_cExifData, attr_readers[i], 1, 0);
181
+ rb_define_alias(rb_cExifData, "to_h", "ifds");
182
+ rb_define_singleton_method(rb_cExifData, "new", new, 1);
183
+ rb_define_method(rb_cExifData, "dump", dump, 0);
184
+ rb_define_method(rb_cExifData, "[]", brackets, 1);
185
+ }
186
+
187
+ VALUE new (VALUE self, VALUE input) {
188
+ ExifData *ed;
189
+ VALUE read_data;
190
+
191
+ switch (TYPE(input)) {
192
+ case T_STRING:
193
+ read_data = input;
194
+ break;
195
+ case T_FILE:
196
+ read_data = rb_funcall(input, rb_intern("read"), 0);
197
+ break;
198
+ default:
199
+ rb_raise(rb_eTypeError, "wrong argument type %s (expected String or IO)",
200
+ rb_obj_classname(input));
201
+ }
202
+
203
+ ExifLoader *loader = exif_loader_new();
204
+ exif_loader_write(loader, (unsigned char *)RSTRING_PTR(read_data),
205
+ RSTRING_LEN(read_data));
206
+ ed = exif_loader_get_data(loader);
207
+ exif_loader_unref(loader);
208
+ if (!ed)
209
+ rb_raise(rb_eNotReadble, "File not readable or no EXIF data in file.");
210
+
211
+ VALUE rb_data = Data_Wrap_Struct(self, NULL, exif_data_free, ed);
212
+ rb_iv_set(rb_data, "@ifds", rb_hash_new());
213
+ exif_data_foreach_content(ed, each_content, &rb_data);
214
+ return rb_data;
215
+ }
216
+
217
+ static VALUE dump(VALUE self) {
218
+ ExifData *ed;
219
+ Data_Get_Struct(self, ExifData, ed);
220
+ exif_data_dump(ed);
221
+ return Qnil;
222
+ }
223
+
224
+ static VALUE brackets(VALUE self, VALUE ifd_symbol) {
225
+ return rb_hash_aref(rb_iv_get(self, "@ifds"), ifd_symbol);
226
+ }
227
+
228
+ static void each_content(ExifContent *ec, void *self_ptr) {
229
+ VALUE *self;
230
+ ExifIfd ifd;
231
+
232
+ ifd = exif_content_get_ifd(ec);
233
+ if (ifd == EXIF_IFD_COUNT)
234
+ rb_raise(rb_eIFDNotFound, "Con't get IFD.");
235
+ rb_hash_aset(rb_iv_get(*(VALUE *)self_ptr, "@ifds"),
236
+ ID2SYM(rb_intern(ifd_name_mapping[ifd])), rb_hash_new());
237
+ exif_content_foreach_entry(ec, each_entry, self_ptr);
238
+ }
239
+
240
+ static void each_entry(ExifEntry *entry, void *self_ptr) {
241
+ VALUE value;
242
+ const char *ivar_name;
243
+
244
+ ivar_name = exif_entry_to_ivar(entry);
245
+ value = exif_entry_to_rb_value(entry);
246
+ rb_hash_aset(rb_hash_aref(rb_iv_get(*(VALUE *)self_ptr, "@ifds"),
247
+ ID2SYM(rb_intern(
248
+ ifd_name_mapping[exif_entry_get_ifd(entry)]))),
249
+ ID2SYM(rb_intern(ivar_name + 1)), value);
250
+ if (TYPE(rb_ivar_defined(*(VALUE *)self_ptr, rb_intern(ivar_name))) ==
251
+ T_FALSE) {
252
+ rb_iv_set(*(VALUE *)self_ptr, ivar_name, value);
253
+ }
254
+ }
255
+
256
+ #define TYPECAST(value1, value2) \
257
+ do { \
258
+ if (entry->components > 1) { \
259
+ ret = rb_ary_new2(entry->components); \
260
+ for (i = 0; i < entry->components; i++) \
261
+ rb_ary_push(ret, value1); \
262
+ } else \
263
+ ret = value2; \
264
+ } while (0)
265
+
266
+ #define TYPECAST_BYTE(c_to_rb, type) \
267
+ TYPECAST(c_to_rb((type)entry->data[i]), c_to_rb((type)entry->data[0]))
268
+
269
+ #define TYPECAST_EXIF(c_to_rb, exif_get) \
270
+ TYPECAST(c_to_rb(exif_get_##exif_get(entry->data + i * size, order)), \
271
+ c_to_rb(exif_get_##exif_get(entry->data, order)))
272
+
273
+ static VALUE exif_entry_to_rb_value(ExifEntry *entry) {
274
+ ExifData *data;
275
+ ExifByteOrder order;
276
+ ExifRational rational;
277
+ ExifSRational srational;
278
+ VALUE ret;
279
+ size_t len, i;
280
+ unsigned char size;
281
+
282
+ data = entry->parent->parent;
283
+ order = exif_data_get_byte_order(data);
284
+ ret = Qnil;
285
+ size = exif_format_get_size(entry->format);
286
+
287
+ switch (entry->format) {
288
+ case EXIF_FORMAT_UNDEFINED:
289
+ ret = rb_str_new((const char *)entry->data, entry->size);
290
+ break;
291
+ case EXIF_FORMAT_BYTE:
292
+ TYPECAST_BYTE(INT2FIX, uint8_t);
293
+ case EXIF_FORMAT_SBYTE:
294
+ TYPECAST_BYTE(INT2FIX, int8_t);
295
+ break;
296
+ case EXIF_FORMAT_SHORT:
297
+ TYPECAST_EXIF(INT2FIX, short);
298
+ break;
299
+ case EXIF_FORMAT_SSHORT:
300
+ TYPECAST_EXIF(INT2FIX, sshort);
301
+ break;
302
+ case EXIF_FORMAT_LONG:
303
+ TYPECAST_EXIF(ULONG2NUM, long);
304
+ break;
305
+ case EXIF_FORMAT_SLONG:
306
+ TYPECAST_EXIF(LONG2NUM, slong);
307
+ break;
308
+ case EXIF_FORMAT_ASCII:
309
+ ret = rb_str_new2((const char *)entry->data);
310
+ break;
311
+ case EXIF_FORMAT_RATIONAL:
312
+ TYPECAST_EXIF(rational_to_num, rational);
313
+ break;
314
+ case EXIF_FORMAT_SRATIONAL:
315
+ TYPECAST_EXIF(srational_to_num, srational);
316
+ break;
317
+ case EXIF_FORMAT_DOUBLE:
318
+ case EXIF_FORMAT_FLOAT:
319
+ ret = rb_float_new(*(double *)entry->data);
320
+ break;
321
+ }
322
+
323
+ return ret;
324
+ }
325
+
326
+ #undef TYPECAST
327
+ #undef TYPECAST_BYTE
328
+ #undef TYPECAST_EXIF
329
+
330
+ VALUE rational_to_num(ExifRational rational) {
331
+ if (rational.numerator == 0 && rational.denominator == 0)
332
+ return DBL2NUM(NAN);
333
+ else if (rational.denominator == 0)
334
+ return DBL2NUM(INFINITY);
335
+ else
336
+ return rb_rational_new(ULONG2NUM(rational.numerator),
337
+ ULONG2NUM(rational.denominator));
338
+ }
339
+
340
+ VALUE srational_to_num(ExifSRational srational) {
341
+ if (srational.numerator == 0 && srational.denominator == 0)
342
+ return DBL2NUM(NAN);
343
+ else if (srational.denominator == 0)
344
+ return DBL2NUM(srational.numerator > 0 ? INFINITY : -INFINITY);
345
+ else
346
+ return rb_rational_new(LONG2NUM(srational.numerator),
347
+ LONG2NUM(srational.denominator));
348
+ }
data/ext/exif/data.h ADDED
@@ -0,0 +1,3 @@
1
+ #pragma once
2
+
3
+ void init_data();
data/ext/exif/exif.c ADDED
@@ -0,0 +1,16 @@
1
+ #include "data.h"
2
+ #include "ruby.h"
3
+
4
+ VALUE rb_mExif, rb_eError, rb_eNotReadble, rb_eIFDNotFound, rb_eUnknownDataType;
5
+
6
+ void Init_exif(void) {
7
+ rb_mExif = rb_define_module("Exif");
8
+
9
+ rb_eError = rb_define_class_under(rb_mExif, "Error", rb_eStandardError);
10
+ rb_eNotReadble = rb_define_class_under(rb_mExif, "NotReadble", rb_eError);
11
+ rb_eIFDNotFound = rb_define_class_under(rb_mExif, "IFDNotFound", rb_eError);
12
+ rb_eUnknownDataType =
13
+ rb_define_class_under(rb_mExif, "UnknownDataType", rb_eError);
14
+
15
+ init_data();
16
+ }
@@ -0,0 +1,452 @@
1
+ #include <libexif/exif-entry.h>
2
+
3
+ const char *exif_entry_to_ivar(ExifEntry *ee) {
4
+ ExifIfd ifd;
5
+ ExifTag tag;
6
+
7
+ ifd = exif_entry_get_ifd(ee);
8
+ tag = ee->tag;
9
+
10
+ switch ((int)tag) {
11
+ case EXIF_TAG_INTEROPERABILITY_INDEX: /* EXIF_TAG_GPS_LATITUDE_REF */
12
+ return ifd == EXIF_IFD_GPS ? "@gps_latitude_ref"
13
+ : "@interoperability_index";
14
+ break;
15
+ case EXIF_TAG_INTEROPERABILITY_VERSION: /* EXIF_TAG_GPS_LATITUDE */
16
+ return ifd == EXIF_IFD_GPS ? "@gps_latitude" : "@interoperability_version";
17
+ break;
18
+ case EXIF_TAG_NEW_SUBFILE_TYPE:
19
+ return "@new_subfile_type";
20
+ break;
21
+ case EXIF_TAG_IMAGE_WIDTH:
22
+ return "@image_width";
23
+ break;
24
+ case EXIF_TAG_IMAGE_LENGTH:
25
+ return "@image_length";
26
+ break;
27
+ case EXIF_TAG_BITS_PER_SAMPLE:
28
+ return "@bits_per_sample";
29
+ break;
30
+ case EXIF_TAG_COMPRESSION:
31
+ return "@compression";
32
+ break;
33
+ case EXIF_TAG_PHOTOMETRIC_INTERPRETATION:
34
+ return "@photometric_interpretation";
35
+ break;
36
+ case EXIF_TAG_FILL_ORDER:
37
+ return "@fill_order";
38
+ break;
39
+ case EXIF_TAG_DOCUMENT_NAME:
40
+ return "@document_name";
41
+ break;
42
+ case EXIF_TAG_IMAGE_DESCRIPTION:
43
+ return "@image_description";
44
+ break;
45
+ case EXIF_TAG_MAKE:
46
+ return "@make";
47
+ break;
48
+ case EXIF_TAG_MODEL:
49
+ return "@model";
50
+ break;
51
+ case EXIF_TAG_STRIP_OFFSETS:
52
+ return "@strip_offsets";
53
+ break;
54
+ case EXIF_TAG_ORIENTATION:
55
+ return "@orientation";
56
+ break;
57
+ case EXIF_TAG_SAMPLES_PER_PIXEL:
58
+ return "@samples_per_pixel";
59
+ break;
60
+ case EXIF_TAG_ROWS_PER_STRIP:
61
+ return "@rows_per_strip";
62
+ break;
63
+ case EXIF_TAG_STRIP_BYTE_COUNTS:
64
+ return "@strip_byte_counts";
65
+ break;
66
+ case EXIF_TAG_X_RESOLUTION:
67
+ return "@x_resolution";
68
+ break;
69
+ case EXIF_TAG_Y_RESOLUTION:
70
+ return "@y_resolution";
71
+ break;
72
+ case EXIF_TAG_PLANAR_CONFIGURATION:
73
+ return "@planar_configuration";
74
+ break;
75
+ case EXIF_TAG_RESOLUTION_UNIT:
76
+ return "@resolution_unit";
77
+ break;
78
+ case EXIF_TAG_TRANSFER_FUNCTION:
79
+ return "@transfer_function";
80
+ break;
81
+ case EXIF_TAG_SOFTWARE:
82
+ return "@software";
83
+ break;
84
+ case EXIF_TAG_DATE_TIME:
85
+ return "@date_time";
86
+ break;
87
+ case EXIF_TAG_ARTIST:
88
+ return "@artist";
89
+ break;
90
+ case EXIF_TAG_WHITE_POINT:
91
+ return "@white_point";
92
+ break;
93
+ case EXIF_TAG_PRIMARY_CHROMATICITIES:
94
+ return "@primary_chromaticities";
95
+ break;
96
+ case EXIF_TAG_SUB_IFDS:
97
+ return "@sub_ifds";
98
+ break;
99
+ case EXIF_TAG_TRANSFER_RANGE:
100
+ return "@transfer_range";
101
+ break;
102
+ case EXIF_TAG_JPEG_PROC:
103
+ return "@jpeg_proc";
104
+ break;
105
+ case EXIF_TAG_JPEG_INTERCHANGE_FORMAT:
106
+ return "@jpeg_interchange_format";
107
+ break;
108
+ case EXIF_TAG_JPEG_INTERCHANGE_FORMAT_LENGTH:
109
+ return "@jpeg_interchange_format_length";
110
+ break;
111
+ case EXIF_TAG_YCBCR_COEFFICIENTS:
112
+ return "@ycbcr_coefficients";
113
+ break;
114
+ case EXIF_TAG_YCBCR_SUB_SAMPLING:
115
+ return "@ycbcr_sub_sampling";
116
+ break;
117
+ case EXIF_TAG_YCBCR_POSITIONING:
118
+ return "@ycbcr_positioning";
119
+ break;
120
+ case EXIF_TAG_REFERENCE_BLACK_WHITE:
121
+ return "@reference_black_white";
122
+ break;
123
+ case EXIF_TAG_XML_PACKET:
124
+ return "@xml_packet";
125
+ break;
126
+ case EXIF_TAG_RELATED_IMAGE_FILE_FORMAT:
127
+ return "@related_image_file_format";
128
+ break;
129
+ case EXIF_TAG_RELATED_IMAGE_WIDTH:
130
+ return "@related_image_width";
131
+ break;
132
+ case EXIF_TAG_RELATED_IMAGE_LENGTH:
133
+ return "@related_image_length";
134
+ break;
135
+ case EXIF_TAG_CFA_REPEAT_PATTERN_DIM:
136
+ return "@cfa_repeat_pattern_dim";
137
+ break;
138
+ case EXIF_TAG_CFA_PATTERN:
139
+ return "@cfa_pattern";
140
+ break;
141
+ case EXIF_TAG_BATTERY_LEVEL:
142
+ return "@battery_level";
143
+ break;
144
+ case EXIF_TAG_COPYRIGHT:
145
+ return "@copyright";
146
+ break;
147
+ case EXIF_TAG_EXPOSURE_TIME:
148
+ return "@exposure_time";
149
+ break;
150
+ case EXIF_TAG_FNUMBER:
151
+ return "@fnumber";
152
+ break;
153
+ case EXIF_TAG_IPTC_NAA:
154
+ return "@iptc_naa";
155
+ break;
156
+ case EXIF_TAG_IMAGE_RESOURCES:
157
+ return "@image_resources";
158
+ break;
159
+ case EXIF_TAG_EXIF_IFD_POINTER:
160
+ return "@exif_ifd_pointer";
161
+ break;
162
+ case EXIF_TAG_INTER_COLOR_PROFILE:
163
+ return "@inter_color_profile";
164
+ break;
165
+ case EXIF_TAG_EXPOSURE_PROGRAM:
166
+ return "@exposure_program";
167
+ break;
168
+ case EXIF_TAG_SPECTRAL_SENSITIVITY:
169
+ return "@spectral_sensitivity";
170
+ break;
171
+ case EXIF_TAG_GPS_INFO_IFD_POINTER:
172
+ return "@gps_info_ifd_pointer";
173
+ break;
174
+ case EXIF_TAG_ISO_SPEED_RATINGS:
175
+ return "@iso_speed_ratings";
176
+ break;
177
+ case EXIF_TAG_OECF:
178
+ return "@oecf";
179
+ break;
180
+ case EXIF_TAG_TIME_ZONE_OFFSET:
181
+ return "@time_zone_offset";
182
+ break;
183
+ case EXIF_TAG_EXIF_VERSION:
184
+ return "@exif_version";
185
+ break;
186
+ case EXIF_TAG_DATE_TIME_ORIGINAL:
187
+ return "@date_time_original";
188
+ break;
189
+ case EXIF_TAG_DATE_TIME_DIGITIZED:
190
+ return "@date_time_digitized";
191
+ break;
192
+ case EXIF_TAG_COMPONENTS_CONFIGURATION:
193
+ return "@components_configuration";
194
+ break;
195
+ case EXIF_TAG_COMPRESSED_BITS_PER_PIXEL:
196
+ return "@compressed_bits_per_pixel";
197
+ break;
198
+ case EXIF_TAG_SHUTTER_SPEED_VALUE:
199
+ return "@shutter_speed_value";
200
+ break;
201
+ case EXIF_TAG_APERTURE_VALUE:
202
+ return "@aperture_value";
203
+ break;
204
+ case EXIF_TAG_BRIGHTNESS_VALUE:
205
+ return "@brightness_value";
206
+ break;
207
+ case EXIF_TAG_EXPOSURE_BIAS_VALUE:
208
+ return "@exposure_bias_value";
209
+ break;
210
+ case EXIF_TAG_MAX_APERTURE_VALUE:
211
+ return "@max_aperture_value";
212
+ break;
213
+ case EXIF_TAG_SUBJECT_DISTANCE:
214
+ return "@subject_distance";
215
+ break;
216
+ case EXIF_TAG_METERING_MODE:
217
+ return "@metering_mode";
218
+ break;
219
+ case EXIF_TAG_LIGHT_SOURCE:
220
+ return "@light_source";
221
+ break;
222
+ case EXIF_TAG_FLASH:
223
+ return "@flash";
224
+ break;
225
+ case EXIF_TAG_FOCAL_LENGTH:
226
+ return "@focal_length";
227
+ break;
228
+ case EXIF_TAG_SUBJECT_AREA:
229
+ return "@subject_area";
230
+ break;
231
+ case EXIF_TAG_TIFF_EP_STANDARD_ID:
232
+ return "@tiff_ep_standard_id";
233
+ break;
234
+ case EXIF_TAG_MAKER_NOTE:
235
+ return "@maker_note";
236
+ break;
237
+ case EXIF_TAG_USER_COMMENT:
238
+ return "@user_comment";
239
+ break;
240
+ case EXIF_TAG_SUB_SEC_TIME:
241
+ return "@sub_sec_time";
242
+ break;
243
+ case EXIF_TAG_SUB_SEC_TIME_ORIGINAL:
244
+ return "@sub_sec_time_original";
245
+ break;
246
+ case EXIF_TAG_SUB_SEC_TIME_DIGITIZED:
247
+ return "@sub_sec_time_digitized";
248
+ break;
249
+ case EXIF_TAG_XP_TITLE:
250
+ return "@xp_title";
251
+ break;
252
+ case EXIF_TAG_XP_COMMENT:
253
+ return "@xp_comment";
254
+ break;
255
+ case EXIF_TAG_XP_AUTHOR:
256
+ return "@xp_author";
257
+ break;
258
+ case EXIF_TAG_XP_KEYWORDS:
259
+ return "@xp_keywords";
260
+ break;
261
+ case EXIF_TAG_XP_SUBJECT:
262
+ return "@xp_subject";
263
+ break;
264
+ case EXIF_TAG_FLASH_PIX_VERSION:
265
+ return "@flash_pix_version";
266
+ break;
267
+ case EXIF_TAG_COLOR_SPACE:
268
+ return "@color_space";
269
+ break;
270
+ case EXIF_TAG_PIXEL_X_DIMENSION:
271
+ return "@pixel_x_dimension";
272
+ break;
273
+ case EXIF_TAG_PIXEL_Y_DIMENSION:
274
+ return "@pixel_y_dimension";
275
+ break;
276
+ case EXIF_TAG_RELATED_SOUND_FILE:
277
+ return "@related_sound_file";
278
+ break;
279
+ case EXIF_TAG_INTEROPERABILITY_IFD_POINTER:
280
+ return "@interoperability_ifd_pointer";
281
+ break;
282
+ case EXIF_TAG_FLASH_ENERGY:
283
+ return "@flash_energy";
284
+ break;
285
+ case EXIF_TAG_SPATIAL_FREQUENCY_RESPONSE:
286
+ return "@spatial_frequency_response";
287
+ break;
288
+ case EXIF_TAG_FOCAL_PLANE_X_RESOLUTION:
289
+ return "@focal_plane_x_resolution";
290
+ break;
291
+ case EXIF_TAG_FOCAL_PLANE_Y_RESOLUTION:
292
+ return "@focal_plane_y_resolution";
293
+ break;
294
+ case EXIF_TAG_FOCAL_PLANE_RESOLUTION_UNIT:
295
+ return "@focal_plane_resolution_unit";
296
+ break;
297
+ case EXIF_TAG_SUBJECT_LOCATION:
298
+ return "@subject_location";
299
+ break;
300
+ case EXIF_TAG_EXPOSURE_INDEX:
301
+ return "@exposure_index";
302
+ break;
303
+ case EXIF_TAG_SENSING_METHOD:
304
+ return "@sensing_method";
305
+ break;
306
+ case EXIF_TAG_FILE_SOURCE:
307
+ return "@file_source";
308
+ break;
309
+ case EXIF_TAG_SCENE_TYPE:
310
+ return "@scene_type";
311
+ break;
312
+ case EXIF_TAG_NEW_CFA_PATTERN:
313
+ return "@new_cfa_pattern";
314
+ break;
315
+ case EXIF_TAG_CUSTOM_RENDERED:
316
+ return "@custom_rendered";
317
+ break;
318
+ case EXIF_TAG_EXPOSURE_MODE:
319
+ return "@exposure_mode";
320
+ break;
321
+ case EXIF_TAG_WHITE_BALANCE:
322
+ return "@white_balance";
323
+ break;
324
+ case EXIF_TAG_DIGITAL_ZOOM_RATIO:
325
+ return "@digital_zoom_ratio";
326
+ break;
327
+ case EXIF_TAG_FOCAL_LENGTH_IN_35MM_FILM:
328
+ return "@focal_length_in_35mm_film";
329
+ break;
330
+ case EXIF_TAG_SCENE_CAPTURE_TYPE:
331
+ return "@scene_capture_type";
332
+ break;
333
+ case EXIF_TAG_GAIN_CONTROL:
334
+ return "@gain_control";
335
+ break;
336
+ case EXIF_TAG_CONTRAST:
337
+ return "@contrast";
338
+ break;
339
+ case EXIF_TAG_SATURATION:
340
+ return "@saturation";
341
+ break;
342
+ case EXIF_TAG_SHARPNESS:
343
+ return "@sharpness";
344
+ break;
345
+ case EXIF_TAG_DEVICE_SETTING_DESCRIPTION:
346
+ return "@device_setting_description";
347
+ break;
348
+ case EXIF_TAG_SUBJECT_DISTANCE_RANGE:
349
+ return "@subject_distance_range";
350
+ break;
351
+ case EXIF_TAG_IMAGE_UNIQUE_ID:
352
+ return "@image_unique_id";
353
+ break;
354
+ case EXIF_TAG_GAMMA:
355
+ return "@gamma";
356
+ break;
357
+ case EXIF_TAG_PRINT_IMAGE_MATCHING:
358
+ return "@print_image_matching";
359
+ break;
360
+ case EXIF_TAG_PADDING:
361
+ return "@padding";
362
+ break;
363
+ case EXIF_TAG_GPS_VERSION_ID:
364
+ return "@gps_version_id";
365
+ break;
366
+ case EXIF_TAG_GPS_LONGITUDE_REF:
367
+ return "@gps_longitude_ref";
368
+ break;
369
+ case EXIF_TAG_GPS_LONGITUDE:
370
+ return "@gps_longitude";
371
+ break;
372
+ case EXIF_TAG_GPS_ALTITUDE_REF:
373
+ return "@gps_altitude_ref";
374
+ break;
375
+ case EXIF_TAG_GPS_ALTITUDE:
376
+ return "@gps_altitude";
377
+ break;
378
+ case EXIF_TAG_GPS_TIME_STAMP:
379
+ return "@gps_time_stamp";
380
+ break;
381
+ case EXIF_TAG_GPS_SATELLITES:
382
+ return "@gps_satellites";
383
+ break;
384
+ case EXIF_TAG_GPS_STATUS:
385
+ return "@gps_status";
386
+ break;
387
+ case EXIF_TAG_GPS_MEASURE_MODE:
388
+ return "@gps_measure_mode";
389
+ break;
390
+ case EXIF_TAG_GPS_DOP:
391
+ return "@gps_dop";
392
+ break;
393
+ case EXIF_TAG_GPS_SPEED_REF:
394
+ return "@gps_speed_ref";
395
+ break;
396
+ case EXIF_TAG_GPS_SPEED:
397
+ return "@gps_speed";
398
+ break;
399
+ case EXIF_TAG_GPS_TRACK_REF:
400
+ return "@gps_track_ref";
401
+ break;
402
+ case EXIF_TAG_GPS_TRACK:
403
+ return "@gps_track";
404
+ break;
405
+ case EXIF_TAG_GPS_IMG_DIRECTION_REF:
406
+ return "@gps_img_direction_ref";
407
+ break;
408
+ case EXIF_TAG_GPS_IMG_DIRECTION:
409
+ return "@gps_img_direction";
410
+ break;
411
+ case EXIF_TAG_GPS_MAP_DATUM:
412
+ return "@gps_map_datum";
413
+ break;
414
+ case EXIF_TAG_GPS_DEST_LATITUDE_REF:
415
+ return "@gps_dest_latitude_ref";
416
+ break;
417
+ case EXIF_TAG_GPS_DEST_LATITUDE:
418
+ return "@gps_dest_latitude";
419
+ break;
420
+ case EXIF_TAG_GPS_DEST_LONGITUDE_REF:
421
+ return "@gps_dest_longitude_ref";
422
+ break;
423
+ case EXIF_TAG_GPS_DEST_LONGITUDE:
424
+ return "@gps_dest_longitude";
425
+ break;
426
+ case EXIF_TAG_GPS_DEST_BEARING_REF:
427
+ return "@gps_dest_bearing_ref";
428
+ break;
429
+ case EXIF_TAG_GPS_DEST_BEARING:
430
+ return "@gps_dest_bearing";
431
+ break;
432
+ case EXIF_TAG_GPS_DEST_DISTANCE_REF:
433
+ return "@gps_dest_distance_ref";
434
+ break;
435
+ case EXIF_TAG_GPS_DEST_DISTANCE:
436
+ return "@gps_dest_distance";
437
+ break;
438
+ case EXIF_TAG_GPS_PROCESSING_METHOD:
439
+ return "@gps_processing_method";
440
+ break;
441
+ case EXIF_TAG_GPS_AREA_INFORMATION:
442
+ return "@gps_area_information";
443
+ break;
444
+ case EXIF_TAG_GPS_DATE_STAMP:
445
+ return "@gps_date_stamp";
446
+ break;
447
+ case EXIF_TAG_GPS_DIFFERENTIAL:
448
+ return "@gps_differential";
449
+ break;
450
+ }
451
+ return 0;
452
+ }
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'mkmf'
4
+ $CFLAGS << ' -std=c99 '
5
+ have_library('exif')
6
+ have_header('libexif/exif-data.h')
7
+ create_makefile('exif/exif')
data/lib/exif.rb ADDED
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'exif/version'
4
+ require 'exif/exif'
5
+
6
+ module Exif
7
+
8
+ class Data
9
+
10
+ def latitude
11
+ hemi = self.gps_latitude_ref == "N" ? 1 : -1
12
+ lat_f = (self.gps_latitude[0].to_f+self.gps_latitude[1].to_f/60.0+self.gps_latitude[2].to_f/3600.0)*hemi
13
+ return lat_f
14
+ end
15
+
16
+ def longitude
17
+ hemi = self.gps_longitude_ref == "E" ? 1 : -1
18
+ lng_f = (self.gps_longitude[0].to_f+self.gps_longitude[1].to_f/60.0+self.gps_longitude[2].to_f/3600.0)*hemi
19
+ return lng_f
20
+ end
21
+
22
+ def altitude
23
+ return gps_altitude.to_f
24
+ end
25
+
26
+ end
27
+
28
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Exif
4
+ VERSION = '2.0.1'
5
+ end
metadata ADDED
@@ -0,0 +1,108 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: exif-aerial
3
+ version: !ruby/object:Gem::Version
4
+ version: 2.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Jian Weihang
8
+ - Nathan Sullivan
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2017-10-03 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: bundler
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - "~>"
19
+ - !ruby/object:Gem::Version
20
+ version: 1.15.4
21
+ type: :development
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - "~>"
26
+ - !ruby/object:Gem::Version
27
+ version: 1.15.4
28
+ - !ruby/object:Gem::Dependency
29
+ name: rake
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - "~>"
33
+ - !ruby/object:Gem::Version
34
+ version: 12.0.0
35
+ type: :development
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - "~>"
40
+ - !ruby/object:Gem::Version
41
+ version: 12.0.0
42
+ - !ruby/object:Gem::Dependency
43
+ name: rake-compiler
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - "~>"
47
+ - !ruby/object:Gem::Version
48
+ version: 1.0.4
49
+ type: :development
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - "~>"
54
+ - !ruby/object:Gem::Version
55
+ version: 1.0.4
56
+ - !ruby/object:Gem::Dependency
57
+ name: minitest
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - "~>"
61
+ - !ruby/object:Gem::Version
62
+ version: 5.10.3
63
+ type: :development
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - "~>"
68
+ - !ruby/object:Gem::Version
69
+ version: 5.10.3
70
+ description: Adds latitude, longitude, altitude accessors.
71
+ email: nathan@aerialapplications.com
72
+ executables: []
73
+ extensions:
74
+ - ext/exif/extconf.rb
75
+ extra_rdoc_files: []
76
+ files:
77
+ - ext/exif/data.c
78
+ - ext/exif/data.h
79
+ - ext/exif/exif.c
80
+ - ext/exif/exif_entry_to_ivar.c
81
+ - ext/exif/extconf.rb
82
+ - lib/exif.rb
83
+ - lib/exif/version.rb
84
+ homepage: https://github.com/tonytonyjan/exif
85
+ licenses:
86
+ - MIT
87
+ metadata: {}
88
+ post_install_message:
89
+ rdoc_options: []
90
+ require_paths:
91
+ - lib
92
+ required_ruby_version: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ required_rubygems_version: !ruby/object:Gem::Requirement
98
+ requirements:
99
+ - - ">="
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ requirements: []
103
+ rubyforge_project:
104
+ rubygems_version: 2.5.2
105
+ signing_key:
106
+ specification_version: 4
107
+ summary: Ruby EXIF reader written in C extension.
108
+ test_files: []