exif 0.9.0 → 0.10.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +4 -4
- data/benchmark/benchmark.rb +23 -0
- data/ext/exif/data.c +469 -20
- data/ext/exif/data.h +3 -0
- data/lib/exif.rb +0 -1
- data/lib/exif/version.rb +1 -1
- data/spec/exif_spec.rb +6 -4
- metadata +2 -2
- data/lib/exif/underscore.rb +0 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5e2d459e26e4c1bc0cc6c02e6c1e87c8a7168796
|
4
|
+
data.tar.gz: e430895590e8ceaa7595f19c38aa0b062780c527
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5e5b91c5f772dbdc7c8bef203b2101b8f57122c081a30ef841da082de6ba42cd8c942698024678136930ae895a95f59931b28ea4dc7e988d2f4445ae5d38bf48
|
7
|
+
data.tar.gz: 9dd8285f7a418fed4bf545be7039feb702bd246aa524754090a88196a573adbd491c9a005736c3eaff8458338bdeaabb182d6e02cf83756eed229f2daf1d4395
|
data/README.md
CHANGED
@@ -10,8 +10,8 @@ Ruby wrapper for libexif
|
|
10
10
|
|
11
11
|
```ruby
|
12
12
|
data = Exif::Data.new('sample.jpg')
|
13
|
-
data
|
14
|
-
data
|
13
|
+
data.image_width # => 4000
|
14
|
+
data.gps_latitude # => '24, 10.6817, 0'
|
15
15
|
|
16
16
|
# get all entries in an IFD
|
17
17
|
data[0] # => {image_width: 4000, image_length: 2670, ...}
|
@@ -19,6 +19,7 @@ data[1] # => {x_resolution: "72"}, y_resolution: "72", ...}
|
|
19
19
|
data[:exif] # => exposure_time: "1/125 sec.", f_number: "f/8.0"}
|
20
20
|
data[:gps] # => {gps_version_id: "2.2.0.0", gps_latitude_ref: "N", ...}
|
21
21
|
data[:interoperability] # => {...}
|
22
|
+
data.to_h # => {0 => {...}, 1 => {...}, :exif => {...}}
|
22
23
|
```
|
23
24
|
|
24
25
|
## Tag Rreference
|
@@ -174,5 +175,4 @@ data[:interoperability] # => {...}
|
|
174
175
|
|
175
176
|
# TODO
|
176
177
|
|
177
|
-
1.
|
178
|
-
2. Support reading from String.
|
178
|
+
1. Support reading from String.
|
@@ -0,0 +1,23 @@
|
|
1
|
+
$: << File.expand_path('../../lib', __FILE__)
|
2
|
+
require 'benchmark'
|
3
|
+
require 'exif'
|
4
|
+
require 'exifr'
|
5
|
+
|
6
|
+
N = 500
|
7
|
+
FILE_PATH = File.expand_path('../../spec/sample.jpg', __FILE__)
|
8
|
+
exifr = EXIFR::JPEG.new(FILE_PATH)
|
9
|
+
exif = Exif::Data.new(FILE_PATH)
|
10
|
+
Benchmark.bmbm do |x|
|
11
|
+
x.report '[exifr] init' do
|
12
|
+
N.times{ EXIFR::JPEG.new(FILE_PATH).width }
|
13
|
+
end
|
14
|
+
x.report '[exif] init' do
|
15
|
+
N.times{ Exif::Data.new(FILE_PATH).image_width }
|
16
|
+
end
|
17
|
+
x.report '[exifr] get width' do
|
18
|
+
N.times{ exifr.width }
|
19
|
+
end
|
20
|
+
x.report '[exif] get width' do
|
21
|
+
N.times{ exif.image_width }
|
22
|
+
end
|
23
|
+
end
|
data/ext/exif/data.c
CHANGED
@@ -7,11 +7,15 @@ static VALUE IFD2SYM[5];
|
|
7
7
|
|
8
8
|
void init_data(){
|
9
9
|
rb_cData = rb_define_class_under(rb_mExif, "Data", rb_cObject);
|
10
|
-
IFD2SYM[
|
11
|
-
IFD2SYM[
|
12
|
-
IFD2SYM[
|
13
|
-
IFD2SYM[
|
14
|
-
IFD2SYM[
|
10
|
+
IFD2SYM[EXIF_IFD_0] = INT2NUM(0);
|
11
|
+
IFD2SYM[EXIF_IFD_1] = INT2NUM(1);
|
12
|
+
IFD2SYM[EXIF_IFD_EXIF] = ID2SYM(rb_intern("exif"));
|
13
|
+
IFD2SYM[EXIF_IFD_GPS] = ID2SYM(rb_intern("gps"));
|
14
|
+
IFD2SYM[EXIF_IFD_INTEROPERABILITY] = ID2SYM(rb_intern("interoperability"));
|
15
|
+
int length = sizeof(attrs) / sizeof(char*);
|
16
|
+
for(int i = 0; i < length; ++i) rb_define_attr(rb_cData, attrs[i], 1, 0);
|
17
|
+
rb_define_attr(rb_cData, "contents", 1, 0);
|
18
|
+
rb_define_alias(rb_cData, "to_h", "contents");
|
15
19
|
rb_define_singleton_method(rb_cData, "new", rb_new, 1);
|
16
20
|
rb_define_method(rb_cData, "dump", rb_dump, 0);
|
17
21
|
rb_define_method(rb_cData, "[]", rb_value, 1);
|
@@ -22,10 +26,8 @@ static VALUE rb_new(VALUE self, VALUE file_path){
|
|
22
26
|
ExifData *ed = exif_data_new_from_file(StringValueCStr(file_path));
|
23
27
|
if(!ed) rb_raise(rb_eRuntimeError, "File not readable or no EXIF data in file.");
|
24
28
|
VALUE rb_data = Data_Wrap_Struct(self, NULL, exif_data_free, ed);
|
25
|
-
|
26
|
-
|
27
|
-
exif_data_foreach_content(ed, each_content, &rb_h);
|
28
|
-
rb_iv_set(rb_data, "@contents", rb_h);
|
29
|
+
rb_iv_set(rb_data, "@contents", rb_hash_new());
|
30
|
+
exif_data_foreach_content(ed, each_content, &rb_data);
|
29
31
|
return rb_data;
|
30
32
|
}
|
31
33
|
|
@@ -41,21 +43,23 @@ static VALUE rb_value(VALUE self, VALUE key){
|
|
41
43
|
return rb_hash_aref(rb_contents, key);
|
42
44
|
}
|
43
45
|
|
44
|
-
static void each_content(ExifContent *ec, void *
|
45
|
-
VALUE *
|
46
|
+
static void each_content(ExifContent *ec, void *self_ptr){
|
47
|
+
VALUE *self = (VALUE*)self_ptr;
|
48
|
+
VALUE rb_contents = rb_iv_get(*self, "@contents");
|
49
|
+
Check_Type(rb_contents, T_HASH);
|
46
50
|
ExifIfd ifd = exif_content_get_ifd(ec);
|
47
51
|
VALUE ifd_name = IFD2SYM[ifd]; //rb_str_new_cstr(exif_ifd_get_name(ifd));
|
48
52
|
if(ifd == EXIF_IFD_COUNT) rb_raise(rb_eRuntimeError, "Con't get IFD.");
|
49
|
-
else rb_hash_aset(
|
50
|
-
exif_content_foreach_entry(ec, each_entry,
|
53
|
+
else rb_hash_aset(rb_contents, ifd_name, rb_hash_new());
|
54
|
+
exif_content_foreach_entry(ec, each_entry, self);
|
51
55
|
}
|
52
56
|
|
53
|
-
static void each_entry(ExifEntry *ee, void *
|
54
|
-
VALUE *
|
57
|
+
static void each_entry(ExifEntry *ee, void *self_ptr){
|
58
|
+
VALUE *self = (VALUE*)self_ptr;
|
59
|
+
VALUE rb_contents = rb_iv_get(*self, "@contents");
|
55
60
|
ExifIfd ifd = exif_entry_get_ifd(ee);
|
56
|
-
|
57
|
-
|
58
|
-
tag_name = ID2SYM(rb_intern_str(tag_name));
|
61
|
+
char *attr_name = attr_string(ifd, ee->tag);
|
62
|
+
VALUE tag_name = ID2SYM(rb_intern(attr_name + 1));
|
59
63
|
char buf[500];
|
60
64
|
exif_entry_get_value(ee, buf, sizeof(buf));
|
61
65
|
VALUE value;
|
@@ -91,6 +95,451 @@ static void each_entry(ExifEntry *ee, void *rb_h_ptr){
|
|
91
95
|
default:
|
92
96
|
value = rb_str_new_cstr(buf);
|
93
97
|
}
|
94
|
-
rb_hash_aset(rb_hash_aref(
|
95
|
-
|
98
|
+
rb_hash_aset(rb_hash_aref(rb_contents, IFD2SYM[ifd]), tag_name, value);
|
99
|
+
rb_hash_aset(rb_contents, tag_name, value);
|
100
|
+
rb_iv_set(*self, attr_name, value);
|
101
|
+
}
|
102
|
+
|
103
|
+
static char* attr_string(ExifIfd ifd, ExifTag tag){
|
104
|
+
switch((int)tag){
|
105
|
+
case EXIF_TAG_INTEROPERABILITY_INDEX: /* EXIF_TAG_GPS_LATITUDE_REF */
|
106
|
+
return ifd == EXIF_IFD_GPS ? "@gps_latitude_ref" : "@interoperability_index";
|
107
|
+
break;
|
108
|
+
case EXIF_TAG_INTEROPERABILITY_VERSION: /* EXIF_TAG_GPS_LATITUDE */
|
109
|
+
return ifd == EXIF_IFD_GPS ? "@gps_latitude" : "@interoperability_version";
|
110
|
+
break;
|
111
|
+
case EXIF_TAG_NEW_SUBFILE_TYPE:
|
112
|
+
return "@new_subfile_type";
|
113
|
+
break;
|
114
|
+
case EXIF_TAG_IMAGE_WIDTH:
|
115
|
+
return "@image_width";
|
116
|
+
break;
|
117
|
+
case EXIF_TAG_IMAGE_LENGTH:
|
118
|
+
return "@image_length";
|
119
|
+
break;
|
120
|
+
case EXIF_TAG_BITS_PER_SAMPLE:
|
121
|
+
return "@bits_per_sample";
|
122
|
+
break;
|
123
|
+
case EXIF_TAG_COMPRESSION:
|
124
|
+
return "@compression";
|
125
|
+
break;
|
126
|
+
case EXIF_TAG_PHOTOMETRIC_INTERPRETATION:
|
127
|
+
return "@photometric_interpretation";
|
128
|
+
break;
|
129
|
+
case EXIF_TAG_FILL_ORDER:
|
130
|
+
return "@fill_order";
|
131
|
+
break;
|
132
|
+
case EXIF_TAG_DOCUMENT_NAME:
|
133
|
+
return "@document_name";
|
134
|
+
break;
|
135
|
+
case EXIF_TAG_IMAGE_DESCRIPTION:
|
136
|
+
return "@image_description";
|
137
|
+
break;
|
138
|
+
case EXIF_TAG_MAKE:
|
139
|
+
return "@make";
|
140
|
+
break;
|
141
|
+
case EXIF_TAG_MODEL:
|
142
|
+
return "@model";
|
143
|
+
break;
|
144
|
+
case EXIF_TAG_STRIP_OFFSETS:
|
145
|
+
return "@strip_offsets";
|
146
|
+
break;
|
147
|
+
case EXIF_TAG_ORIENTATION:
|
148
|
+
return "@orientation";
|
149
|
+
break;
|
150
|
+
case EXIF_TAG_SAMPLES_PER_PIXEL:
|
151
|
+
return "@samples_per_pixel";
|
152
|
+
break;
|
153
|
+
case EXIF_TAG_ROWS_PER_STRIP:
|
154
|
+
return "@rows_per_strip";
|
155
|
+
break;
|
156
|
+
case EXIF_TAG_STRIP_BYTE_COUNTS:
|
157
|
+
return "@strip_byte_counts";
|
158
|
+
break;
|
159
|
+
case EXIF_TAG_X_RESOLUTION:
|
160
|
+
return "@x_resolution";
|
161
|
+
break;
|
162
|
+
case EXIF_TAG_Y_RESOLUTION:
|
163
|
+
return "@y_resolution";
|
164
|
+
break;
|
165
|
+
case EXIF_TAG_PLANAR_CONFIGURATION:
|
166
|
+
return "@planar_configuration";
|
167
|
+
break;
|
168
|
+
case EXIF_TAG_RESOLUTION_UNIT:
|
169
|
+
return "@resolution_unit";
|
170
|
+
break;
|
171
|
+
case EXIF_TAG_TRANSFER_FUNCTION:
|
172
|
+
return "@transfer_function";
|
173
|
+
break;
|
174
|
+
case EXIF_TAG_SOFTWARE:
|
175
|
+
return "@software";
|
176
|
+
break;
|
177
|
+
case EXIF_TAG_DATE_TIME:
|
178
|
+
return "@date_time";
|
179
|
+
break;
|
180
|
+
case EXIF_TAG_ARTIST:
|
181
|
+
return "@artist";
|
182
|
+
break;
|
183
|
+
case EXIF_TAG_WHITE_POINT:
|
184
|
+
return "@white_point";
|
185
|
+
break;
|
186
|
+
case EXIF_TAG_PRIMARY_CHROMATICITIES:
|
187
|
+
return "@primary_chromaticities";
|
188
|
+
break;
|
189
|
+
case EXIF_TAG_SUB_IFDS:
|
190
|
+
return "@sub_ifds";
|
191
|
+
break;
|
192
|
+
case EXIF_TAG_TRANSFER_RANGE:
|
193
|
+
return "@transfer_range";
|
194
|
+
break;
|
195
|
+
case EXIF_TAG_JPEG_PROC:
|
196
|
+
return "@jpeg_proc";
|
197
|
+
break;
|
198
|
+
case EXIF_TAG_JPEG_INTERCHANGE_FORMAT:
|
199
|
+
return "@jpeg_interchange_format";
|
200
|
+
break;
|
201
|
+
case EXIF_TAG_JPEG_INTERCHANGE_FORMAT_LENGTH:
|
202
|
+
return "@jpeg_interchange_format_length";
|
203
|
+
break;
|
204
|
+
case EXIF_TAG_YCBCR_COEFFICIENTS:
|
205
|
+
return "@ycbcr_coefficients";
|
206
|
+
break;
|
207
|
+
case EXIF_TAG_YCBCR_SUB_SAMPLING:
|
208
|
+
return "@ycbcr_sub_sampling";
|
209
|
+
break;
|
210
|
+
case EXIF_TAG_YCBCR_POSITIONING:
|
211
|
+
return "@ycbcr_positioning";
|
212
|
+
break;
|
213
|
+
case EXIF_TAG_REFERENCE_BLACK_WHITE:
|
214
|
+
return "@reference_black_white";
|
215
|
+
break;
|
216
|
+
case EXIF_TAG_XML_PACKET:
|
217
|
+
return "@xml_packet";
|
218
|
+
break;
|
219
|
+
case EXIF_TAG_RELATED_IMAGE_FILE_FORMAT:
|
220
|
+
return "@related_image_file_format";
|
221
|
+
break;
|
222
|
+
case EXIF_TAG_RELATED_IMAGE_WIDTH:
|
223
|
+
return "@related_image_width";
|
224
|
+
break;
|
225
|
+
case EXIF_TAG_RELATED_IMAGE_LENGTH:
|
226
|
+
return "@related_image_length";
|
227
|
+
break;
|
228
|
+
case EXIF_TAG_CFA_REPEAT_PATTERN_DIM:
|
229
|
+
return "@cfa_repeat_pattern_dim";
|
230
|
+
break;
|
231
|
+
case EXIF_TAG_CFA_PATTERN:
|
232
|
+
return "@cfa_pattern";
|
233
|
+
break;
|
234
|
+
case EXIF_TAG_BATTERY_LEVEL:
|
235
|
+
return "@battery_level";
|
236
|
+
break;
|
237
|
+
case EXIF_TAG_COPYRIGHT:
|
238
|
+
return "@copyright";
|
239
|
+
break;
|
240
|
+
case EXIF_TAG_EXPOSURE_TIME:
|
241
|
+
return "@exposure_time";
|
242
|
+
break;
|
243
|
+
case EXIF_TAG_FNUMBER:
|
244
|
+
return "@fnumber";
|
245
|
+
break;
|
246
|
+
case EXIF_TAG_IPTC_NAA:
|
247
|
+
return "@iptc_naa";
|
248
|
+
break;
|
249
|
+
case EXIF_TAG_IMAGE_RESOURCES:
|
250
|
+
return "@image_resources";
|
251
|
+
break;
|
252
|
+
case EXIF_TAG_EXIF_IFD_POINTER:
|
253
|
+
return "@exif_ifd_pointer";
|
254
|
+
break;
|
255
|
+
case EXIF_TAG_INTER_COLOR_PROFILE:
|
256
|
+
return "@inter_color_profile";
|
257
|
+
break;
|
258
|
+
case EXIF_TAG_EXPOSURE_PROGRAM:
|
259
|
+
return "@exposure_program";
|
260
|
+
break;
|
261
|
+
case EXIF_TAG_SPECTRAL_SENSITIVITY:
|
262
|
+
return "@spectral_sensitivity";
|
263
|
+
break;
|
264
|
+
case EXIF_TAG_GPS_INFO_IFD_POINTER:
|
265
|
+
return "@gps_info_ifd_pointer";
|
266
|
+
break;
|
267
|
+
case EXIF_TAG_ISO_SPEED_RATINGS:
|
268
|
+
return "@iso_speed_ratings";
|
269
|
+
break;
|
270
|
+
case EXIF_TAG_OECF:
|
271
|
+
return "@oecf";
|
272
|
+
break;
|
273
|
+
case EXIF_TAG_TIME_ZONE_OFFSET:
|
274
|
+
return "@time_zone_offset";
|
275
|
+
break;
|
276
|
+
case EXIF_TAG_EXIF_VERSION:
|
277
|
+
return "@exif_version";
|
278
|
+
break;
|
279
|
+
case EXIF_TAG_DATE_TIME_ORIGINAL:
|
280
|
+
return "@date_time_original";
|
281
|
+
break;
|
282
|
+
case EXIF_TAG_DATE_TIME_DIGITIZED:
|
283
|
+
return "@date_time_digitized";
|
284
|
+
break;
|
285
|
+
case EXIF_TAG_COMPONENTS_CONFIGURATION:
|
286
|
+
return "@components_configuration";
|
287
|
+
break;
|
288
|
+
case EXIF_TAG_COMPRESSED_BITS_PER_PIXEL:
|
289
|
+
return "@compressed_bits_per_pixel";
|
290
|
+
break;
|
291
|
+
case EXIF_TAG_SHUTTER_SPEED_VALUE:
|
292
|
+
return "@shutter_speed_value";
|
293
|
+
break;
|
294
|
+
case EXIF_TAG_APERTURE_VALUE:
|
295
|
+
return "@aperture_value";
|
296
|
+
break;
|
297
|
+
case EXIF_TAG_BRIGHTNESS_VALUE:
|
298
|
+
return "@brightness_value";
|
299
|
+
break;
|
300
|
+
case EXIF_TAG_EXPOSURE_BIAS_VALUE:
|
301
|
+
return "@exposure_bias_value";
|
302
|
+
break;
|
303
|
+
case EXIF_TAG_MAX_APERTURE_VALUE:
|
304
|
+
return "@max_aperture_value";
|
305
|
+
break;
|
306
|
+
case EXIF_TAG_SUBJECT_DISTANCE:
|
307
|
+
return "@subject_distance";
|
308
|
+
break;
|
309
|
+
case EXIF_TAG_METERING_MODE:
|
310
|
+
return "@metering_mode";
|
311
|
+
break;
|
312
|
+
case EXIF_TAG_LIGHT_SOURCE:
|
313
|
+
return "@light_source";
|
314
|
+
break;
|
315
|
+
case EXIF_TAG_FLASH:
|
316
|
+
return "@flash";
|
317
|
+
break;
|
318
|
+
case EXIF_TAG_FOCAL_LENGTH:
|
319
|
+
return "@focal_length";
|
320
|
+
break;
|
321
|
+
case EXIF_TAG_SUBJECT_AREA:
|
322
|
+
return "@subject_area";
|
323
|
+
break;
|
324
|
+
case EXIF_TAG_TIFF_EP_STANDARD_ID:
|
325
|
+
return "@tiff_ep_standard_id";
|
326
|
+
break;
|
327
|
+
case EXIF_TAG_MAKER_NOTE:
|
328
|
+
return "@maker_note";
|
329
|
+
break;
|
330
|
+
case EXIF_TAG_USER_COMMENT:
|
331
|
+
return "@user_comment";
|
332
|
+
break;
|
333
|
+
case EXIF_TAG_SUB_SEC_TIME:
|
334
|
+
return "@sub_sec_time";
|
335
|
+
break;
|
336
|
+
case EXIF_TAG_SUB_SEC_TIME_ORIGINAL:
|
337
|
+
return "@sub_sec_time_original";
|
338
|
+
break;
|
339
|
+
case EXIF_TAG_SUB_SEC_TIME_DIGITIZED:
|
340
|
+
return "@sub_sec_time_digitized";
|
341
|
+
break;
|
342
|
+
case EXIF_TAG_XP_TITLE:
|
343
|
+
return "@xp_title";
|
344
|
+
break;
|
345
|
+
case EXIF_TAG_XP_COMMENT:
|
346
|
+
return "@xp_comment";
|
347
|
+
break;
|
348
|
+
case EXIF_TAG_XP_AUTHOR:
|
349
|
+
return "@xp_author";
|
350
|
+
break;
|
351
|
+
case EXIF_TAG_XP_KEYWORDS:
|
352
|
+
return "@xp_keywords";
|
353
|
+
break;
|
354
|
+
case EXIF_TAG_XP_SUBJECT:
|
355
|
+
return "@xp_subject";
|
356
|
+
break;
|
357
|
+
case EXIF_TAG_FLASH_PIX_VERSION:
|
358
|
+
return "@flash_pix_version";
|
359
|
+
break;
|
360
|
+
case EXIF_TAG_COLOR_SPACE:
|
361
|
+
return "@color_space";
|
362
|
+
break;
|
363
|
+
case EXIF_TAG_PIXEL_X_DIMENSION:
|
364
|
+
return "@pixel_x_dimension";
|
365
|
+
break;
|
366
|
+
case EXIF_TAG_PIXEL_Y_DIMENSION:
|
367
|
+
return "@pixel_y_dimension";
|
368
|
+
break;
|
369
|
+
case EXIF_TAG_RELATED_SOUND_FILE:
|
370
|
+
return "@related_sound_file";
|
371
|
+
break;
|
372
|
+
case EXIF_TAG_INTEROPERABILITY_IFD_POINTER:
|
373
|
+
return "@interoperability_ifd_pointer";
|
374
|
+
break;
|
375
|
+
case EXIF_TAG_FLASH_ENERGY:
|
376
|
+
return "@flash_energy";
|
377
|
+
break;
|
378
|
+
case EXIF_TAG_SPATIAL_FREQUENCY_RESPONSE:
|
379
|
+
return "@spatial_frequency_response";
|
380
|
+
break;
|
381
|
+
case EXIF_TAG_FOCAL_PLANE_X_RESOLUTION:
|
382
|
+
return "@focal_plane_x_resolution";
|
383
|
+
break;
|
384
|
+
case EXIF_TAG_FOCAL_PLANE_Y_RESOLUTION:
|
385
|
+
return "@focal_plane_y_resolution";
|
386
|
+
break;
|
387
|
+
case EXIF_TAG_FOCAL_PLANE_RESOLUTION_UNIT:
|
388
|
+
return "@focal_plane_resolution_unit";
|
389
|
+
break;
|
390
|
+
case EXIF_TAG_SUBJECT_LOCATION:
|
391
|
+
return "@subject_location";
|
392
|
+
break;
|
393
|
+
case EXIF_TAG_EXPOSURE_INDEX:
|
394
|
+
return "@exposure_index";
|
395
|
+
break;
|
396
|
+
case EXIF_TAG_SENSING_METHOD:
|
397
|
+
return "@sensing_method";
|
398
|
+
break;
|
399
|
+
case EXIF_TAG_FILE_SOURCE:
|
400
|
+
return "@file_source";
|
401
|
+
break;
|
402
|
+
case EXIF_TAG_SCENE_TYPE:
|
403
|
+
return "@scene_type";
|
404
|
+
break;
|
405
|
+
case EXIF_TAG_NEW_CFA_PATTERN:
|
406
|
+
return "@new_cfa_pattern";
|
407
|
+
break;
|
408
|
+
case EXIF_TAG_CUSTOM_RENDERED:
|
409
|
+
return "@custom_rendered";
|
410
|
+
break;
|
411
|
+
case EXIF_TAG_EXPOSURE_MODE:
|
412
|
+
return "@exposure_mode";
|
413
|
+
break;
|
414
|
+
case EXIF_TAG_WHITE_BALANCE:
|
415
|
+
return "@white_balance";
|
416
|
+
break;
|
417
|
+
case EXIF_TAG_DIGITAL_ZOOM_RATIO:
|
418
|
+
return "@digital_zoom_ratio";
|
419
|
+
break;
|
420
|
+
case EXIF_TAG_FOCAL_LENGTH_IN_35MM_FILM:
|
421
|
+
return "@focal_length_in_35mm_film";
|
422
|
+
break;
|
423
|
+
case EXIF_TAG_SCENE_CAPTURE_TYPE:
|
424
|
+
return "@scene_capture_type";
|
425
|
+
break;
|
426
|
+
case EXIF_TAG_GAIN_CONTROL:
|
427
|
+
return "@gain_control";
|
428
|
+
break;
|
429
|
+
case EXIF_TAG_CONTRAST:
|
430
|
+
return "@contrast";
|
431
|
+
break;
|
432
|
+
case EXIF_TAG_SATURATION:
|
433
|
+
return "@saturation";
|
434
|
+
break;
|
435
|
+
case EXIF_TAG_SHARPNESS:
|
436
|
+
return "@sharpness";
|
437
|
+
break;
|
438
|
+
case EXIF_TAG_DEVICE_SETTING_DESCRIPTION:
|
439
|
+
return "@device_setting_description";
|
440
|
+
break;
|
441
|
+
case EXIF_TAG_SUBJECT_DISTANCE_RANGE:
|
442
|
+
return "@subject_distance_range";
|
443
|
+
break;
|
444
|
+
case EXIF_TAG_IMAGE_UNIQUE_ID:
|
445
|
+
return "@image_unique_id";
|
446
|
+
break;
|
447
|
+
case EXIF_TAG_GAMMA:
|
448
|
+
return "@gamma";
|
449
|
+
break;
|
450
|
+
case EXIF_TAG_PRINT_IMAGE_MATCHING:
|
451
|
+
return "@print_image_matching";
|
452
|
+
break;
|
453
|
+
case EXIF_TAG_PADDING:
|
454
|
+
return "@padding";
|
455
|
+
break;
|
456
|
+
case EXIF_TAG_GPS_VERSION_ID:
|
457
|
+
return "@gps_version_id";
|
458
|
+
break;
|
459
|
+
case EXIF_TAG_GPS_LONGITUDE_REF:
|
460
|
+
return "@gps_longitude_ref";
|
461
|
+
break;
|
462
|
+
case EXIF_TAG_GPS_LONGITUDE:
|
463
|
+
return "@gps_longitude";
|
464
|
+
break;
|
465
|
+
case EXIF_TAG_GPS_ALTITUDE_REF:
|
466
|
+
return "@gps_altitude_ref";
|
467
|
+
break;
|
468
|
+
case EXIF_TAG_GPS_ALTITUDE:
|
469
|
+
return "@gps_altitude";
|
470
|
+
break;
|
471
|
+
case EXIF_TAG_GPS_TIME_STAMP:
|
472
|
+
return "@gps_time_stamp";
|
473
|
+
break;
|
474
|
+
case EXIF_TAG_GPS_SATELLITES:
|
475
|
+
return "@gps_satellites";
|
476
|
+
break;
|
477
|
+
case EXIF_TAG_GPS_STATUS:
|
478
|
+
return "@gps_status";
|
479
|
+
break;
|
480
|
+
case EXIF_TAG_GPS_MEASURE_MODE:
|
481
|
+
return "@gps_measure_mode";
|
482
|
+
break;
|
483
|
+
case EXIF_TAG_GPS_DOP:
|
484
|
+
return "@gps_dop";
|
485
|
+
break;
|
486
|
+
case EXIF_TAG_GPS_SPEED_REF:
|
487
|
+
return "@gps_speed_ref";
|
488
|
+
break;
|
489
|
+
case EXIF_TAG_GPS_SPEED:
|
490
|
+
return "@gps_speed";
|
491
|
+
break;
|
492
|
+
case EXIF_TAG_GPS_TRACK_REF:
|
493
|
+
return "@gps_track_ref";
|
494
|
+
break;
|
495
|
+
case EXIF_TAG_GPS_TRACK:
|
496
|
+
return "@gps_track";
|
497
|
+
break;
|
498
|
+
case EXIF_TAG_GPS_IMG_DIRECTION_REF:
|
499
|
+
return "@gps_img_direction_ref";
|
500
|
+
break;
|
501
|
+
case EXIF_TAG_GPS_IMG_DIRECTION:
|
502
|
+
return "@gps_img_direction";
|
503
|
+
break;
|
504
|
+
case EXIF_TAG_GPS_MAP_DATUM:
|
505
|
+
return "@gps_map_datum";
|
506
|
+
break;
|
507
|
+
case EXIF_TAG_GPS_DEST_LATITUDE_REF:
|
508
|
+
return "@gps_dest_latitude_ref";
|
509
|
+
break;
|
510
|
+
case EXIF_TAG_GPS_DEST_LATITUDE:
|
511
|
+
return "@gps_dest_latitude";
|
512
|
+
break;
|
513
|
+
case EXIF_TAG_GPS_DEST_LONGITUDE_REF:
|
514
|
+
return "@gps_dest_longitude_ref";
|
515
|
+
break;
|
516
|
+
case EXIF_TAG_GPS_DEST_LONGITUDE:
|
517
|
+
return "@gps_dest_longitude";
|
518
|
+
break;
|
519
|
+
case EXIF_TAG_GPS_DEST_BEARING_REF:
|
520
|
+
return "@gps_dest_bearing_ref";
|
521
|
+
break;
|
522
|
+
case EXIF_TAG_GPS_DEST_BEARING:
|
523
|
+
return "@gps_dest_bearing";
|
524
|
+
break;
|
525
|
+
case EXIF_TAG_GPS_DEST_DISTANCE_REF:
|
526
|
+
return "@gps_dest_distance_ref";
|
527
|
+
break;
|
528
|
+
case EXIF_TAG_GPS_DEST_DISTANCE:
|
529
|
+
return "@gps_dest_distance";
|
530
|
+
break;
|
531
|
+
case EXIF_TAG_GPS_PROCESSING_METHOD:
|
532
|
+
return "@gps_processing_method";
|
533
|
+
break;
|
534
|
+
case EXIF_TAG_GPS_AREA_INFORMATION:
|
535
|
+
return "@gps_area_information";
|
536
|
+
break;
|
537
|
+
case EXIF_TAG_GPS_DATE_STAMP:
|
538
|
+
return "@gps_date_stamp";
|
539
|
+
break;
|
540
|
+
case EXIF_TAG_GPS_DIFFERENTIAL:
|
541
|
+
return "@gps_differential";
|
542
|
+
break;
|
543
|
+
}
|
544
|
+
return NULL;
|
96
545
|
}
|
data/ext/exif/data.h
CHANGED
@@ -4,6 +4,8 @@
|
|
4
4
|
#include <libexif/exif-data.h>
|
5
5
|
#include "ruby.h"
|
6
6
|
|
7
|
+
static char *attrs[] = {"aperture_value", "artist", "battery_level", "bits_per_sample", "brightness_value", "cfa_pattern", "cfa_repeat_pattern_dim", "color_space", "components_configuration", "compressed_bits_per_pixel", "compression", "contrast", "copyright", "custom_rendered", "date_time", "date_time_digitized", "date_time_original", "device_setting_description", "digital_zoom_ratio", "document_name", "exif_ifd_pointer", "exif_version", "exposure_bias_value", "exposure_index", "exposure_mode", "exposure_program", "exposure_time", "file_source", "fill_order", "flash", "flash_energy", "flash_pix_version", "fnumber", "focal_length", "focal_length_in_35mm_film", "focal_plane_resolution_unit", "focal_plane_x_resolution", "focal_plane_y_resolution", "gain_control", "gamma", "gps_altitude", "gps_altitude_ref", "gps_area_information", "gps_date_stamp", "gps_dest_bearing", "gps_dest_bearing_ref", "gps_dest_distance", "gps_dest_distance_ref", "gps_dest_latitude", "gps_dest_latitude_ref", "gps_dest_longitude", "gps_dest_longitude_ref", "gps_differential", "gps_dop", "gps_img_direction", "gps_img_direction_ref", "gps_info_ifd_pointer", "gps_latitude", "gps_latitude_ref", "gps_longitude", "gps_longitude_ref", "gps_map_datum", "gps_measure_mode", "gps_processing_method", "gps_satellites", "gps_speed", "gps_speed_ref", "gps_status", "gps_time_stamp", "gps_track", "gps_track_ref", "gps_version_id", "image_description", "image_length", "image_resources", "image_unique_id", "image_width", "inter_color_profile", "interoperability_ifd_pointer", "interoperability_index", "interoperability_version", "iptc_naa", "iso_speed_ratings", "jpeg_interchange_format", "jpeg_interchange_format_length", "jpeg_proc", "light_source", "make", "maker_note", "max_aperture_value", "metering_mode", "model", "new_cfa_pattern", "new_subfile_type", "oecf", "orientation", "padding", "photometric_interpretation", "pixel_x_dimension", "pixel_y_dimension", "planar_configuration", "primary_chromaticities", "print_image_matching", "reference_black_white", "related_image_file_format", "related_image_length", "related_image_width", "related_sound_file", "resolution_unit", "rows_per_strip", "samples_per_pixel", "saturation", "scene_capture_type", "scene_type", "sensing_method", "sharpness", "shutter_speed_value", "software", "spatial_frequency_response", "spectral_sensitivity", "strip_byte_counts", "strip_offsets", "sub_ifds", "sub_sec_time", "sub_sec_time_digitized", "sub_sec_time_original", "subject_area", "subject_distance", "subject_distance_range", "subject_location", "tiff_ep_standard_id", "time_zone_offset", "transfer_function", "transfer_range", "user_comment", "white_balance", "white_point", "x_resolution", "xml_packet", "xp_author", "xp_comment", "xp_keywords", "xp_subject", "xp_title", "y_resolution", "ycbcr_coefficients", "ycbcr_positioning", "ycbcr_sub_sampling"};
|
8
|
+
|
7
9
|
void init_data();
|
8
10
|
|
9
11
|
static VALUE rb_new(VALUE self, VALUE file_path);
|
@@ -12,5 +14,6 @@ static VALUE rb_value(VALUE self, VALUE key);
|
|
12
14
|
|
13
15
|
static void each_content(ExifContent *ec, void *user_data);
|
14
16
|
static void each_entry(ExifEntry *, void *user_data);
|
17
|
+
static char* attr_string(ExifIfd ifd, ExifTag tag);
|
15
18
|
|
16
19
|
#endif /* DATA_H */
|
data/lib/exif.rb
CHANGED
data/lib/exif/version.rb
CHANGED
data/spec/exif_spec.rb
CHANGED
@@ -10,13 +10,15 @@ describe Exif do
|
|
10
10
|
# end
|
11
11
|
|
12
12
|
it 'works' do
|
13
|
-
expect(@data.
|
14
|
-
expect(@data.
|
13
|
+
expect(@data.to_h[0][:image_width]).to eq 4000
|
14
|
+
expect(@data.to_h[:image_width]).to eq 4000
|
15
15
|
expect(@data[0][:image_width]).to eq 4000
|
16
16
|
expect(@data[:image_width]).to eq 4000
|
17
|
-
expect(@data.
|
18
|
-
expect(@data.
|
17
|
+
expect(@data.image_width).to eq 4000
|
18
|
+
expect(@data.to_h[:gps][:gps_latitude]).to eq '24, 10.6817, 0'
|
19
|
+
expect(@data.to_h[:gps_latitude]).to eq '24, 10.6817, 0'
|
19
20
|
expect(@data[:gps][:gps_latitude]).to eq '24, 10.6817, 0'
|
20
21
|
expect(@data[:gps_latitude]).to eq '24, 10.6817, 0'
|
22
|
+
expect(@data.gps_latitude).to eq '24, 10.6817, 0'
|
21
23
|
end
|
22
24
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: exif
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.10.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jian Weihang
|
@@ -66,6 +66,7 @@ files:
|
|
66
66
|
- LICENSE.txt
|
67
67
|
- README.md
|
68
68
|
- Rakefile
|
69
|
+
- benchmark/benchmark.rb
|
69
70
|
- exif.gemspec
|
70
71
|
- ext/exif/data.c
|
71
72
|
- ext/exif/data.h
|
@@ -73,7 +74,6 @@ files:
|
|
73
74
|
- ext/exif/exif.h
|
74
75
|
- ext/exif/extconf.rb
|
75
76
|
- lib/exif.rb
|
76
|
-
- lib/exif/underscore.rb
|
77
77
|
- lib/exif/version.rb
|
78
78
|
- spec/exif_spec.rb
|
79
79
|
- spec/sample.jpg
|
data/lib/exif/underscore.rb
DELETED
@@ -1,12 +0,0 @@
|
|
1
|
-
module Exif
|
2
|
-
module_function
|
3
|
-
def underscore!(word)
|
4
|
-
word.to_s.gsub!('::', '/')
|
5
|
-
word.gsub!(/(?:([A-Za-z\d])|^)((?=a)b)(?=\b|[^a-z])/) { "#{$1}#{$1 && '_'}#{$2.downcase}" }
|
6
|
-
word.gsub!(/([A-Z\d]+)([A-Z][a-z])/,'\1_\2')
|
7
|
-
word.gsub!(/([a-z\d])([A-Z])/,'\1_\2')
|
8
|
-
word.tr!("-", "_")
|
9
|
-
word.downcase!
|
10
|
-
word
|
11
|
-
end
|
12
|
-
end
|