exif 1.0.1 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -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 */
@@ -1,9 +1,15 @@
1
- #include "exif.h"
1
+ #include "ruby.h"
2
2
  #include "data.h"
3
3
 
4
- VALUE rb_mExif;
4
+ VALUE rb_mExif, rb_eError, rb_eNotReadble, rb_eIFDNotFound, rb_eUnknownDataType;
5
5
 
6
6
  void Init_exif(void){
7
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 = rb_define_class_under(rb_mExif, "UnknownDataType", rb_eError);
13
+
8
14
  init_data();
9
15
  }
@@ -0,0 +1,451 @@
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" : "@interoperability_index";
13
+ break;
14
+ case EXIF_TAG_INTEROPERABILITY_VERSION: /* EXIF_TAG_GPS_LATITUDE */
15
+ return ifd == EXIF_IFD_GPS ? "@gps_latitude" : "@interoperability_version";
16
+ break;
17
+ case EXIF_TAG_NEW_SUBFILE_TYPE:
18
+ return "@new_subfile_type";
19
+ break;
20
+ case EXIF_TAG_IMAGE_WIDTH:
21
+ return "@image_width";
22
+ break;
23
+ case EXIF_TAG_IMAGE_LENGTH:
24
+ return "@image_length";
25
+ break;
26
+ case EXIF_TAG_BITS_PER_SAMPLE:
27
+ return "@bits_per_sample";
28
+ break;
29
+ case EXIF_TAG_COMPRESSION:
30
+ return "@compression";
31
+ break;
32
+ case EXIF_TAG_PHOTOMETRIC_INTERPRETATION:
33
+ return "@photometric_interpretation";
34
+ break;
35
+ case EXIF_TAG_FILL_ORDER:
36
+ return "@fill_order";
37
+ break;
38
+ case EXIF_TAG_DOCUMENT_NAME:
39
+ return "@document_name";
40
+ break;
41
+ case EXIF_TAG_IMAGE_DESCRIPTION:
42
+ return "@image_description";
43
+ break;
44
+ case EXIF_TAG_MAKE:
45
+ return "@make";
46
+ break;
47
+ case EXIF_TAG_MODEL:
48
+ return "@model";
49
+ break;
50
+ case EXIF_TAG_STRIP_OFFSETS:
51
+ return "@strip_offsets";
52
+ break;
53
+ case EXIF_TAG_ORIENTATION:
54
+ return "@orientation";
55
+ break;
56
+ case EXIF_TAG_SAMPLES_PER_PIXEL:
57
+ return "@samples_per_pixel";
58
+ break;
59
+ case EXIF_TAG_ROWS_PER_STRIP:
60
+ return "@rows_per_strip";
61
+ break;
62
+ case EXIF_TAG_STRIP_BYTE_COUNTS:
63
+ return "@strip_byte_counts";
64
+ break;
65
+ case EXIF_TAG_X_RESOLUTION:
66
+ return "@x_resolution";
67
+ break;
68
+ case EXIF_TAG_Y_RESOLUTION:
69
+ return "@y_resolution";
70
+ break;
71
+ case EXIF_TAG_PLANAR_CONFIGURATION:
72
+ return "@planar_configuration";
73
+ break;
74
+ case EXIF_TAG_RESOLUTION_UNIT:
75
+ return "@resolution_unit";
76
+ break;
77
+ case EXIF_TAG_TRANSFER_FUNCTION:
78
+ return "@transfer_function";
79
+ break;
80
+ case EXIF_TAG_SOFTWARE:
81
+ return "@software";
82
+ break;
83
+ case EXIF_TAG_DATE_TIME:
84
+ return "@date_time";
85
+ break;
86
+ case EXIF_TAG_ARTIST:
87
+ return "@artist";
88
+ break;
89
+ case EXIF_TAG_WHITE_POINT:
90
+ return "@white_point";
91
+ break;
92
+ case EXIF_TAG_PRIMARY_CHROMATICITIES:
93
+ return "@primary_chromaticities";
94
+ break;
95
+ case EXIF_TAG_SUB_IFDS:
96
+ return "@sub_ifds";
97
+ break;
98
+ case EXIF_TAG_TRANSFER_RANGE:
99
+ return "@transfer_range";
100
+ break;
101
+ case EXIF_TAG_JPEG_PROC:
102
+ return "@jpeg_proc";
103
+ break;
104
+ case EXIF_TAG_JPEG_INTERCHANGE_FORMAT:
105
+ return "@jpeg_interchange_format";
106
+ break;
107
+ case EXIF_TAG_JPEG_INTERCHANGE_FORMAT_LENGTH:
108
+ return "@jpeg_interchange_format_length";
109
+ break;
110
+ case EXIF_TAG_YCBCR_COEFFICIENTS:
111
+ return "@ycbcr_coefficients";
112
+ break;
113
+ case EXIF_TAG_YCBCR_SUB_SAMPLING:
114
+ return "@ycbcr_sub_sampling";
115
+ break;
116
+ case EXIF_TAG_YCBCR_POSITIONING:
117
+ return "@ycbcr_positioning";
118
+ break;
119
+ case EXIF_TAG_REFERENCE_BLACK_WHITE:
120
+ return "@reference_black_white";
121
+ break;
122
+ case EXIF_TAG_XML_PACKET:
123
+ return "@xml_packet";
124
+ break;
125
+ case EXIF_TAG_RELATED_IMAGE_FILE_FORMAT:
126
+ return "@related_image_file_format";
127
+ break;
128
+ case EXIF_TAG_RELATED_IMAGE_WIDTH:
129
+ return "@related_image_width";
130
+ break;
131
+ case EXIF_TAG_RELATED_IMAGE_LENGTH:
132
+ return "@related_image_length";
133
+ break;
134
+ case EXIF_TAG_CFA_REPEAT_PATTERN_DIM:
135
+ return "@cfa_repeat_pattern_dim";
136
+ break;
137
+ case EXIF_TAG_CFA_PATTERN:
138
+ return "@cfa_pattern";
139
+ break;
140
+ case EXIF_TAG_BATTERY_LEVEL:
141
+ return "@battery_level";
142
+ break;
143
+ case EXIF_TAG_COPYRIGHT:
144
+ return "@copyright";
145
+ break;
146
+ case EXIF_TAG_EXPOSURE_TIME:
147
+ return "@exposure_time";
148
+ break;
149
+ case EXIF_TAG_FNUMBER:
150
+ return "@fnumber";
151
+ break;
152
+ case EXIF_TAG_IPTC_NAA:
153
+ return "@iptc_naa";
154
+ break;
155
+ case EXIF_TAG_IMAGE_RESOURCES:
156
+ return "@image_resources";
157
+ break;
158
+ case EXIF_TAG_EXIF_IFD_POINTER:
159
+ return "@exif_ifd_pointer";
160
+ break;
161
+ case EXIF_TAG_INTER_COLOR_PROFILE:
162
+ return "@inter_color_profile";
163
+ break;
164
+ case EXIF_TAG_EXPOSURE_PROGRAM:
165
+ return "@exposure_program";
166
+ break;
167
+ case EXIF_TAG_SPECTRAL_SENSITIVITY:
168
+ return "@spectral_sensitivity";
169
+ break;
170
+ case EXIF_TAG_GPS_INFO_IFD_POINTER:
171
+ return "@gps_info_ifd_pointer";
172
+ break;
173
+ case EXIF_TAG_ISO_SPEED_RATINGS:
174
+ return "@iso_speed_ratings";
175
+ break;
176
+ case EXIF_TAG_OECF:
177
+ return "@oecf";
178
+ break;
179
+ case EXIF_TAG_TIME_ZONE_OFFSET:
180
+ return "@time_zone_offset";
181
+ break;
182
+ case EXIF_TAG_EXIF_VERSION:
183
+ return "@exif_version";
184
+ break;
185
+ case EXIF_TAG_DATE_TIME_ORIGINAL:
186
+ return "@date_time_original";
187
+ break;
188
+ case EXIF_TAG_DATE_TIME_DIGITIZED:
189
+ return "@date_time_digitized";
190
+ break;
191
+ case EXIF_TAG_COMPONENTS_CONFIGURATION:
192
+ return "@components_configuration";
193
+ break;
194
+ case EXIF_TAG_COMPRESSED_BITS_PER_PIXEL:
195
+ return "@compressed_bits_per_pixel";
196
+ break;
197
+ case EXIF_TAG_SHUTTER_SPEED_VALUE:
198
+ return "@shutter_speed_value";
199
+ break;
200
+ case EXIF_TAG_APERTURE_VALUE:
201
+ return "@aperture_value";
202
+ break;
203
+ case EXIF_TAG_BRIGHTNESS_VALUE:
204
+ return "@brightness_value";
205
+ break;
206
+ case EXIF_TAG_EXPOSURE_BIAS_VALUE:
207
+ return "@exposure_bias_value";
208
+ break;
209
+ case EXIF_TAG_MAX_APERTURE_VALUE:
210
+ return "@max_aperture_value";
211
+ break;
212
+ case EXIF_TAG_SUBJECT_DISTANCE:
213
+ return "@subject_distance";
214
+ break;
215
+ case EXIF_TAG_METERING_MODE:
216
+ return "@metering_mode";
217
+ break;
218
+ case EXIF_TAG_LIGHT_SOURCE:
219
+ return "@light_source";
220
+ break;
221
+ case EXIF_TAG_FLASH:
222
+ return "@flash";
223
+ break;
224
+ case EXIF_TAG_FOCAL_LENGTH:
225
+ return "@focal_length";
226
+ break;
227
+ case EXIF_TAG_SUBJECT_AREA:
228
+ return "@subject_area";
229
+ break;
230
+ case EXIF_TAG_TIFF_EP_STANDARD_ID:
231
+ return "@tiff_ep_standard_id";
232
+ break;
233
+ case EXIF_TAG_MAKER_NOTE:
234
+ return "@maker_note";
235
+ break;
236
+ case EXIF_TAG_USER_COMMENT:
237
+ return "@user_comment";
238
+ break;
239
+ case EXIF_TAG_SUB_SEC_TIME:
240
+ return "@sub_sec_time";
241
+ break;
242
+ case EXIF_TAG_SUB_SEC_TIME_ORIGINAL:
243
+ return "@sub_sec_time_original";
244
+ break;
245
+ case EXIF_TAG_SUB_SEC_TIME_DIGITIZED:
246
+ return "@sub_sec_time_digitized";
247
+ break;
248
+ case EXIF_TAG_XP_TITLE:
249
+ return "@xp_title";
250
+ break;
251
+ case EXIF_TAG_XP_COMMENT:
252
+ return "@xp_comment";
253
+ break;
254
+ case EXIF_TAG_XP_AUTHOR:
255
+ return "@xp_author";
256
+ break;
257
+ case EXIF_TAG_XP_KEYWORDS:
258
+ return "@xp_keywords";
259
+ break;
260
+ case EXIF_TAG_XP_SUBJECT:
261
+ return "@xp_subject";
262
+ break;
263
+ case EXIF_TAG_FLASH_PIX_VERSION:
264
+ return "@flash_pix_version";
265
+ break;
266
+ case EXIF_TAG_COLOR_SPACE:
267
+ return "@color_space";
268
+ break;
269
+ case EXIF_TAG_PIXEL_X_DIMENSION:
270
+ return "@pixel_x_dimension";
271
+ break;
272
+ case EXIF_TAG_PIXEL_Y_DIMENSION:
273
+ return "@pixel_y_dimension";
274
+ break;
275
+ case EXIF_TAG_RELATED_SOUND_FILE:
276
+ return "@related_sound_file";
277
+ break;
278
+ case EXIF_TAG_INTEROPERABILITY_IFD_POINTER:
279
+ return "@interoperability_ifd_pointer";
280
+ break;
281
+ case EXIF_TAG_FLASH_ENERGY:
282
+ return "@flash_energy";
283
+ break;
284
+ case EXIF_TAG_SPATIAL_FREQUENCY_RESPONSE:
285
+ return "@spatial_frequency_response";
286
+ break;
287
+ case EXIF_TAG_FOCAL_PLANE_X_RESOLUTION:
288
+ return "@focal_plane_x_resolution";
289
+ break;
290
+ case EXIF_TAG_FOCAL_PLANE_Y_RESOLUTION:
291
+ return "@focal_plane_y_resolution";
292
+ break;
293
+ case EXIF_TAG_FOCAL_PLANE_RESOLUTION_UNIT:
294
+ return "@focal_plane_resolution_unit";
295
+ break;
296
+ case EXIF_TAG_SUBJECT_LOCATION:
297
+ return "@subject_location";
298
+ break;
299
+ case EXIF_TAG_EXPOSURE_INDEX:
300
+ return "@exposure_index";
301
+ break;
302
+ case EXIF_TAG_SENSING_METHOD:
303
+ return "@sensing_method";
304
+ break;
305
+ case EXIF_TAG_FILE_SOURCE:
306
+ return "@file_source";
307
+ break;
308
+ case EXIF_TAG_SCENE_TYPE:
309
+ return "@scene_type";
310
+ break;
311
+ case EXIF_TAG_NEW_CFA_PATTERN:
312
+ return "@new_cfa_pattern";
313
+ break;
314
+ case EXIF_TAG_CUSTOM_RENDERED:
315
+ return "@custom_rendered";
316
+ break;
317
+ case EXIF_TAG_EXPOSURE_MODE:
318
+ return "@exposure_mode";
319
+ break;
320
+ case EXIF_TAG_WHITE_BALANCE:
321
+ return "@white_balance";
322
+ break;
323
+ case EXIF_TAG_DIGITAL_ZOOM_RATIO:
324
+ return "@digital_zoom_ratio";
325
+ break;
326
+ case EXIF_TAG_FOCAL_LENGTH_IN_35MM_FILM:
327
+ return "@focal_length_in_35mm_film";
328
+ break;
329
+ case EXIF_TAG_SCENE_CAPTURE_TYPE:
330
+ return "@scene_capture_type";
331
+ break;
332
+ case EXIF_TAG_GAIN_CONTROL:
333
+ return "@gain_control";
334
+ break;
335
+ case EXIF_TAG_CONTRAST:
336
+ return "@contrast";
337
+ break;
338
+ case EXIF_TAG_SATURATION:
339
+ return "@saturation";
340
+ break;
341
+ case EXIF_TAG_SHARPNESS:
342
+ return "@sharpness";
343
+ break;
344
+ case EXIF_TAG_DEVICE_SETTING_DESCRIPTION:
345
+ return "@device_setting_description";
346
+ break;
347
+ case EXIF_TAG_SUBJECT_DISTANCE_RANGE:
348
+ return "@subject_distance_range";
349
+ break;
350
+ case EXIF_TAG_IMAGE_UNIQUE_ID:
351
+ return "@image_unique_id";
352
+ break;
353
+ case EXIF_TAG_GAMMA:
354
+ return "@gamma";
355
+ break;
356
+ case EXIF_TAG_PRINT_IMAGE_MATCHING:
357
+ return "@print_image_matching";
358
+ break;
359
+ case EXIF_TAG_PADDING:
360
+ return "@padding";
361
+ break;
362
+ case EXIF_TAG_GPS_VERSION_ID:
363
+ return "@gps_version_id";
364
+ break;
365
+ case EXIF_TAG_GPS_LONGITUDE_REF:
366
+ return "@gps_longitude_ref";
367
+ break;
368
+ case EXIF_TAG_GPS_LONGITUDE:
369
+ return "@gps_longitude";
370
+ break;
371
+ case EXIF_TAG_GPS_ALTITUDE_REF:
372
+ return "@gps_altitude_ref";
373
+ break;
374
+ case EXIF_TAG_GPS_ALTITUDE:
375
+ return "@gps_altitude";
376
+ break;
377
+ case EXIF_TAG_GPS_TIME_STAMP:
378
+ return "@gps_time_stamp";
379
+ break;
380
+ case EXIF_TAG_GPS_SATELLITES:
381
+ return "@gps_satellites";
382
+ break;
383
+ case EXIF_TAG_GPS_STATUS:
384
+ return "@gps_status";
385
+ break;
386
+ case EXIF_TAG_GPS_MEASURE_MODE:
387
+ return "@gps_measure_mode";
388
+ break;
389
+ case EXIF_TAG_GPS_DOP:
390
+ return "@gps_dop";
391
+ break;
392
+ case EXIF_TAG_GPS_SPEED_REF:
393
+ return "@gps_speed_ref";
394
+ break;
395
+ case EXIF_TAG_GPS_SPEED:
396
+ return "@gps_speed";
397
+ break;
398
+ case EXIF_TAG_GPS_TRACK_REF:
399
+ return "@gps_track_ref";
400
+ break;
401
+ case EXIF_TAG_GPS_TRACK:
402
+ return "@gps_track";
403
+ break;
404
+ case EXIF_TAG_GPS_IMG_DIRECTION_REF:
405
+ return "@gps_img_direction_ref";
406
+ break;
407
+ case EXIF_TAG_GPS_IMG_DIRECTION:
408
+ return "@gps_img_direction";
409
+ break;
410
+ case EXIF_TAG_GPS_MAP_DATUM:
411
+ return "@gps_map_datum";
412
+ break;
413
+ case EXIF_TAG_GPS_DEST_LATITUDE_REF:
414
+ return "@gps_dest_latitude_ref";
415
+ break;
416
+ case EXIF_TAG_GPS_DEST_LATITUDE:
417
+ return "@gps_dest_latitude";
418
+ break;
419
+ case EXIF_TAG_GPS_DEST_LONGITUDE_REF:
420
+ return "@gps_dest_longitude_ref";
421
+ break;
422
+ case EXIF_TAG_GPS_DEST_LONGITUDE:
423
+ return "@gps_dest_longitude";
424
+ break;
425
+ case EXIF_TAG_GPS_DEST_BEARING_REF:
426
+ return "@gps_dest_bearing_ref";
427
+ break;
428
+ case EXIF_TAG_GPS_DEST_BEARING:
429
+ return "@gps_dest_bearing";
430
+ break;
431
+ case EXIF_TAG_GPS_DEST_DISTANCE_REF:
432
+ return "@gps_dest_distance_ref";
433
+ break;
434
+ case EXIF_TAG_GPS_DEST_DISTANCE:
435
+ return "@gps_dest_distance";
436
+ break;
437
+ case EXIF_TAG_GPS_PROCESSING_METHOD:
438
+ return "@gps_processing_method";
439
+ break;
440
+ case EXIF_TAG_GPS_AREA_INFORMATION:
441
+ return "@gps_area_information";
442
+ break;
443
+ case EXIF_TAG_GPS_DATE_STAMP:
444
+ return "@gps_date_stamp";
445
+ break;
446
+ case EXIF_TAG_GPS_DIFFERENTIAL:
447
+ return "@gps_differential";
448
+ break;
449
+ }
450
+ return 0;
451
+ }