exifr 0.9.2 → 0.9.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (5) hide show
  1. data/CHANGELOG +5 -0
  2. data/bin/exifr +1 -1
  3. data/lib/exif.rb +143 -103
  4. data/lib/tiff_header.rb +2 -2
  5. metadata +2 -2
data/CHANGELOG CHANGED
@@ -1,3 +1,8 @@
1
+ EXIF Reader 0.9.3
2
+ * bug fix; "[#4876] Unable to extract gpsinfo"
3
+ * one-off bug in TiffHeader found and fixed
4
+ * make "InteroperabilityIndex" available
5
+
1
6
  EXIF Reader 0.9.2
2
7
  * bug fix; "[#4595] EXIFR::JPEG doesn't support multiple comments", the
3
8
  comment property of a JPEG object now contains an array instead of a string
data/bin/exifr CHANGED
@@ -18,7 +18,7 @@ def pp(fname)
18
18
 
19
19
  puts "#{fname}:"
20
20
  f = " %#{l.sort{|a,b|a[0].size <=> b[0].size}.last[0].size}s = %s\n"
21
- l.each{|k,v|puts f % [k, v]}
21
+ l.each{|k,v|puts f % [k, [v].flatten.map{|t|t.to_s}.join(', ')]}
22
22
  end
23
23
 
24
24
  if ARGV.size == 0
@@ -37,106 +37,146 @@ module EXIFR
37
37
  class EXIF < Hash
38
38
  TAGS = {} # :nodoc:
39
39
  TAGS.merge!({
40
- 0x0100 => :image_width,
41
- 0x0101 => :image_length,
42
- 0x0102 => :bits_per_sample,
43
- 0x0103 => :compression,
44
- 0x0106 => :photometric_interpretation,
45
- 0x010a => :fill_order,
46
- 0x010d => :document_name,
47
- 0x010e => :image_description,
48
- 0x010f => :make,
49
- 0x0110 => :model,
50
- 0x0111 => :strip_offsets,
51
- 0x0112 => :orientation,
52
- 0x0115 => :samples_per_pixel,
53
- 0x0116 => :rows_per_strip,
54
- 0x0117 => :strip_byte_counts,
55
- 0x011a => :xresolution,
56
- 0x011b => :yresolution,
57
- 0x011c => :planar_configuration,
58
- 0x0128 => :resolution_unit,
59
- 0x012d => :transfer_function,
60
- 0x0131 => :software,
61
- 0x0132 => :date_time,
62
- 0x013b => :artist,
63
- 0x013e => :white_point,
64
- 0x013f => :primary_chromaticities,
65
- 0x0156 => :transfer_range,
66
- 0x0200 => :jpegproc,
67
- 0x0201 => :jpeg_interchange_format,
68
- 0x0202 => :jpeg_interchange_format_length,
69
- 0x0211 => :ycb_cr_coefficients,
70
- 0x0212 => :ycb_cr_sub_sampling,
71
- 0x0213 => :ycb_cr_positioning,
72
- 0x0214 => :reference_black_white,
73
- 0x828d => :cfarepeat_pattern_dim,
74
- 0x828e => :cfapattern,
75
- 0x828f => :battery_level,
76
- 0x8298 => :copyright,
77
- 0x829a => :exposure_time,
78
- 0x829d => :fnumber,
79
- 0x83bb => :iptc_naa,
80
- 0x8769 => :exif_offset,
81
- 0x8773 => :inter_color_profile,
82
- 0x8822 => :exposure_program,
83
- 0x8824 => :spectral_sensitivity,
84
- 0x8825 => :gpsinfo,
85
- 0x8827 => :isospeed_ratings,
86
- 0x8828 => :oecf,
87
- 0x9000 => :exif_version,
88
- 0x9003 => :date_time_original,
89
- 0x9004 => :date_time_digitized,
90
- 0x9101 => :components_configuration,
91
- 0x9102 => :compressed_bits_per_pixel,
92
- 0x9201 => :shutter_speed_value,
93
- 0x9202 => :aperture_value,
94
- 0x9203 => :brightness_value,
95
- 0x9204 => :exposure_bias_value,
96
- 0x9205 => :max_aperture_value,
97
- 0x9206 => :subject_distance,
98
- 0x9207 => :metering_mode,
99
- 0x9208 => :light_source,
100
- 0x9209 => :flash,
101
- 0x920a => :focal_length,
102
- 0x9214 => :subject_area,
103
- 0x927c => :maker_note,
104
- 0x9286 => :user_comment,
105
- 0x9290 => :subsec_time,
106
- 0x9291 => :subsec_time_orginal,
107
- 0x9292 => :subsec_time_digitized,
108
- 0xa000 => :flash_pix_version,
109
- 0xa001 => :color_space,
110
- 0xa002 => :pixel_xdimension,
111
- 0xa003 => :pixel_ydimension,
112
- 0xa004 => :related_sound_file,
113
- 0xa005 => :interoperability_offset,
114
- 0xa20b => :flash_energy,
115
- 0xa20c => :spatial_frequency_response,
116
- 0xa20e => :focal_plane_xresolution,
117
- 0xa20f => :focal_plane_yresolution,
118
- 0xa210 => :focal_plane_resolution_unit,
119
- 0xa214 => :subject_location,
120
- 0xa215 => :exposure_index,
121
- 0xa217 => :sensing_method,
122
- 0xa300 => :file_source,
123
- 0xa301 => :scene_type,
124
- 0xa302 => :cfapattern,
125
- 0xa401 => :custom_rendered,
126
- 0xa402 => :exposure_mode,
127
- 0xa403 => :white_balance,
128
- 0xa404 => :digital_zoom_ratio,
129
- 0xa405 => :focal_len_in_35mm_film,
130
- 0xa406 => :scene_capture_type,
131
- 0xa407 => :gain_control,
132
- 0xa408 => :contrast,
133
- 0xa409 => :saturation,
134
- 0xa40a => :sharpness,
135
- 0xa40b => :device_setting_descr,
136
- 0xa40c => :subject_dist_range,
137
- 0xa420 => :image_unique_id
40
+ :exif => {
41
+ 0x0100 => :image_width,
42
+ 0x0101 => :image_length,
43
+ 0x0102 => :bits_per_sample,
44
+ 0x0103 => :compression,
45
+ 0x0106 => :photometric_interpretation,
46
+ 0x010a => :fill_order,
47
+ 0x010d => :document_name,
48
+ 0x010e => :image_description,
49
+ 0x010f => :make,
50
+ 0x0110 => :model,
51
+ 0x0111 => :strip_offsets,
52
+ 0x0112 => :orientation,
53
+ 0x0115 => :samples_per_pixel,
54
+ 0x0116 => :rows_per_strip,
55
+ 0x0117 => :strip_byte_counts,
56
+ 0x011a => :xresolution,
57
+ 0x011b => :yresolution,
58
+ 0x011c => :planar_configuration,
59
+ 0x0128 => :resolution_unit,
60
+ 0x012d => :transfer_function,
61
+ 0x0131 => :software,
62
+ 0x0132 => :date_time,
63
+ 0x013b => :artist,
64
+ 0x013e => :white_point,
65
+ 0x013f => :primary_chromaticities,
66
+ 0x0156 => :transfer_range,
67
+ 0x0200 => :jpegproc,
68
+ 0x0201 => :jpeg_interchange_format,
69
+ 0x0202 => :jpeg_interchange_format_length,
70
+ 0x0211 => :ycb_cr_coefficients,
71
+ 0x0212 => :ycb_cr_sub_sampling,
72
+ 0x0213 => :ycb_cr_positioning,
73
+ 0x0214 => :reference_black_white,
74
+ 0x828d => :cfarepeat_pattern_dim,
75
+ 0x828e => :cfapattern,
76
+ 0x828f => :battery_level,
77
+ 0x8298 => :copyright,
78
+ 0x829a => :exposure_time,
79
+ 0x829d => :fnumber,
80
+ 0x83bb => :iptc_naa,
81
+ 0x8769 => :exif,
82
+ 0x8773 => :inter_color_profile,
83
+ 0x8822 => :exposure_program,
84
+ 0x8824 => :spectral_sensitivity,
85
+ 0x8825 => :gps,
86
+ 0x8827 => :isospeed_ratings,
87
+ 0x8828 => :oecf,
88
+ 0x9000 => :exif_version,
89
+ 0x9003 => :date_time_original,
90
+ 0x9004 => :date_time_digitized,
91
+ 0x9101 => :components_configuration,
92
+ 0x9102 => :compressed_bits_per_pixel,
93
+ 0x9201 => :shutter_speed_value,
94
+ 0x9202 => :aperture_value,
95
+ 0x9203 => :brightness_value,
96
+ 0x9204 => :exposure_bias_value,
97
+ 0x9205 => :max_aperture_value,
98
+ 0x9206 => :subject_distance,
99
+ 0x9207 => :metering_mode,
100
+ 0x9208 => :light_source,
101
+ 0x9209 => :flash,
102
+ 0x920a => :focal_length,
103
+ 0x9214 => :subject_area,
104
+ 0x927c => :maker_note,
105
+ 0x9286 => :user_comment,
106
+ 0x9290 => :subsec_time,
107
+ 0x9291 => :subsec_time_orginal,
108
+ 0x9292 => :subsec_time_digitized,
109
+ 0xa000 => :flash_pix_version,
110
+ 0xa001 => :color_space,
111
+ 0xa002 => :pixel_xdimension,
112
+ 0xa003 => :pixel_ydimension,
113
+ 0xa004 => :related_sound_file,
114
+ 0xa005 => :interoperability,
115
+ 0xa20b => :flash_energy,
116
+ 0xa20c => :spatial_frequency_response,
117
+ 0xa20e => :focal_plane_xresolution,
118
+ 0xa20f => :focal_plane_yresolution,
119
+ 0xa210 => :focal_plane_resolution_unit,
120
+ 0xa214 => :subject_location,
121
+ 0xa215 => :exposure_index,
122
+ 0xa217 => :sensing_method,
123
+ 0xa300 => :file_source,
124
+ 0xa301 => :scene_type,
125
+ 0xa302 => :cfapattern,
126
+ 0xa401 => :custom_rendered,
127
+ 0xa402 => :exposure_mode,
128
+ 0xa403 => :white_balance,
129
+ 0xa404 => :digital_zoom_ratio,
130
+ 0xa405 => :focal_len_in_35mm_film,
131
+ 0xa406 => :scene_capture_type,
132
+ 0xa407 => :gain_control,
133
+ 0xa408 => :contrast,
134
+ 0xa409 => :saturation,
135
+ 0xa40a => :sharpness,
136
+ 0xa40b => :device_setting_descr,
137
+ 0xa40c => :subject_dist_range,
138
+ 0xa420 => :image_unique_id
139
+ },
140
+
141
+ :gps => {
142
+ 0x0000 => :gps_version_id,
143
+ 0x0001 => :gps_latitude_ref,
144
+ 0x0002 => :gps_latitude,
145
+ 0x0003 => :gps_longitude_ref,
146
+ 0x0004 => :gps_longitude,
147
+ 0x0005 => :gps_altitude_ref,
148
+ 0x0006 => :gps_altitude ,
149
+ 0x0007 => :gps_time_stamp,
150
+ 0x0008 => :gps_satellites,
151
+ 0x0009 => :gps_status,
152
+ 0x000a => :gps_measure_mode,
153
+ 0x000b => :gpsdop,
154
+ 0x000c => :gps_speed_ref,
155
+ 0x000d => :gps_speed ,
156
+ 0x000e => :gps_track_ref,
157
+ 0x000f => :gps_track,
158
+ 0x0010 => :gps_img_direction_ref,
159
+ 0x0011 => :gps_img_direction,
160
+ 0x0012 => :gps_map_datum,
161
+ 0x0013 => :gps_dest_latitude_ref,
162
+ 0x0014 => :gps_dest_latitude,
163
+ 0x0015 => :gps_dest_longitude_ref,
164
+ 0x0016 => :gps_dest_longitude,
165
+ 0x0017 => :gps_dest_bearing_ref,
166
+ 0x0018 => :gps_dest_bearing,
167
+ 0x0019 => :gps_dest_distance_ref,
168
+ 0x001a => :gps_dest_distance,
169
+ 0x001b => :gps_processing_method,
170
+ 0x001c => :gps_area_information,
171
+ 0x001d => :gps_date_stamp,
172
+ 0x001e => :gps_differential,
173
+ },
174
+
175
+ :interoperability => {
176
+ 0x0001 => :interoperability_index
177
+ }
138
178
  })
139
- EXIF_HEADERS = [0x8769, 0x8825, 0xa005] # :nodoc:
179
+ EXIF_HEADERS = [:exif, :gps, :interoperability] # :nodoc:
140
180
 
141
181
  time_proc = proc do |value|
142
182
  if value =~ /^(\d{4}):(\d\d):(\d\d) (\d\d):(\d\d):(\d\d)$/
@@ -197,13 +237,13 @@ module EXIFR
197
237
  end
198
238
 
199
239
  private
200
- def traverse(tiff)
240
+ def traverse(tiff, ifd = :exif)
201
241
  tiff.fields.each do |f|
202
- tag = TAGS[f.tag]
242
+ tag = TAGS[ifd][f.tag]
203
243
  value = f.value.map { |v| ADAPTERS[tag][v] } if f.value
204
244
  value = (value.kind_of?(Array) && value.size == 1) ? value.first : value
205
- if EXIF_HEADERS.include?(f.tag)
206
- traverse(TiffHeader.new(@data, f.offset))
245
+ if EXIF_HEADERS.include?(tag)
246
+ traverse(TiffHeader.new(@data, f.offset), tag)
207
247
  elsif tag
208
248
  self[tag] = value
209
249
  end
@@ -51,7 +51,7 @@ module EXIFR
51
51
  # TODO handle signed bytes
52
52
  len, pack = count, proc { |d| d }
53
53
  when 2 # ascii
54
- len, pack = count, proc { |d| d.sub(/\0.*$/, '').strip }
54
+ len, pack = count, proc { |d| d.strip }
55
55
  when 3, 8 # short, signed short
56
56
  # TODO handle signed
57
57
  len, pack = count * 2, proc { |d| d.unpack(data.short + '*') }
@@ -76,7 +76,7 @@ module EXIFR
76
76
 
77
77
  if len && pack
78
78
  start = len > 4 ? @offset : (pos + 8)
79
- @value = pack[data[start..(start + len)]]
79
+ @value = pack[data[start..(start + len - 1)]]
80
80
  end
81
81
  end
82
82
  end
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.8.11
3
3
  specification_version: 1
4
4
  name: exifr
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.9.2
7
- date: 2006-05-30 00:00:00 +02:00
6
+ version: 0.9.3
7
+ date: 2006-06-29 00:00:00 +02:00
8
8
  summary: EXIF Reader is a module to read EXIF from JPEG images.
9
9
  require_paths:
10
10
  - lib