exif 1.0.1 → 2.2.1

Sign up to get free protection for your applications and to get access to all the features.
data/ext/exif/data.h CHANGED
@@ -1,20 +1,3 @@
1
- #ifndef DATA_H
2
- #define DATA_H 1
3
-
4
- #include <libexif/exif-data.h>
5
- #include "ruby.h"
6
-
7
- static const 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"};
1
+ #pragma once
8
2
 
9
3
  void init_data();
10
-
11
- VALUE rb_new(VALUE self, VALUE file_path);
12
- VALUE rb_dump(VALUE self);
13
- VALUE rb_value(VALUE self, VALUE key);
14
-
15
- void each_content(ExifContent *ec, void *user_data);
16
- void each_entry(ExifEntry *, void *user_data);
17
- VALUE process_value(VALUE *self_ptr, ExifIfd ifd, ExifTag tag, char *buf);
18
- const char* attr_string(ExifIfd ifd, ExifTag tag);
19
-
20
- #endif /* DATA_H */
data/ext/exif/exif.c CHANGED
@@ -1,9 +1,28 @@
1
- #include "exif.h"
2
1
  #include "data.h"
2
+ #include "ruby.h"
3
3
 
4
- VALUE rb_mExif;
4
+ VALUE rb_mExif, rb_eError, rb_eNotReadable, rb_eIFDNotFound,
5
+ rb_eUnknownDataType;
5
6
 
6
- void Init_exif(void){
7
+ VALUE rb_exif_const_missing(VALUE klass, VALUE name) {
8
+ const char not_readble[] = "NotReadble";
9
+ if (strcmp(rb_id2name(SYM2ID(name)), not_readble) == 0) {
10
+ rb_warn("constant NotReadble is deprecated and will be removed in the "
11
+ "future, use NotReadable instead.");
12
+ return rb_eNotReadable;
13
+ }
14
+ return rb_call_super(1, &name);
15
+ }
16
+
17
+ void Init_exif(void) {
7
18
  rb_mExif = rb_define_module("Exif");
19
+
20
+ rb_eError = rb_define_class_under(rb_mExif, "Error", rb_eStandardError);
21
+ rb_eNotReadable = rb_define_class_under(rb_mExif, "NotReadable", rb_eError);
22
+ rb_eIFDNotFound = rb_define_class_under(rb_mExif, "IFDNotFound", rb_eError);
23
+ rb_eUnknownDataType =
24
+ rb_define_class_under(rb_mExif, "UnknownDataType", rb_eError);
25
+ rb_define_singleton_method(rb_mExif, "const_missing", rb_exif_const_missing,
26
+ 1);
8
27
  init_data();
9
28
  }
@@ -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
+ }