exifr 0.10.4 → 0.10.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (6) hide show
  1. data/CHANGELOG +4 -0
  2. data/Rakefile +1 -1
  3. data/bin/exifr +2 -2
  4. data/lib/jpeg.rb +10 -9
  5. data/lib/tiff.rb +12 -10
  6. metadata +41 -34
data/CHANGELOG CHANGED
@@ -1,3 +1,7 @@
1
+ EXIF Reader 0.10.5
2
+ * bug fix; "[#15421] duplicate orientation field behavior", first field (of any type) is leading now
3
+ * Ruby 1.9 compatible
4
+
1
5
  EXIF Reader 0.10.4
2
6
  * Thumbnail extraction; [#15317] Please add thumbnail extraction
3
7
 
data/Rakefile CHANGED
@@ -21,7 +21,7 @@ end
21
21
 
22
22
  spec = Gem::Specification.new do |s|
23
23
  s.name = 'exifr'
24
- s.version = '0.10.4'
24
+ s.version = '0.10.5'
25
25
  s.author = "R.W. van 't Veer"
26
26
  s.email = 'remco@remvee.net'
27
27
  s.homepage = 'http://exifr.rubyforge.org/'
data/bin/exifr CHANGED
@@ -41,8 +41,8 @@ if ARGV.size == 0
41
41
  else
42
42
  ARGV.each do |fname|
43
43
  case fname
44
- when /\.(jpg|jpeg)$/i: pp_jpeg fname
45
- when /\.(tif|tiff)$/i: pp_tiff fname
44
+ when /\.(jpg|jpeg)$/i; pp_jpeg fname
45
+ when /\.(tif|tiff)$/i; pp_tiff fname
46
46
  end
47
47
  puts
48
48
  end
data/lib/jpeg.rb CHANGED
@@ -50,28 +50,29 @@ module EXIFR
50
50
 
51
51
  private
52
52
  def examine(io)
53
- raise 'malformed JPEG' unless io.getc == 0xFF && io.getc == 0xD8 # SOI
54
-
55
53
  class << io
56
- def readint; (readchar << 8) + readchar; end
54
+ def readbyte; readchar; end unless method_defined?(:readbyte)
55
+ def readint; (readbyte << 8) + readbyte; end
57
56
  def readframe; read(readint - 2); end
58
- def readsof; [readint, readchar, readint, readint, readchar]; end
57
+ def readsof; [readint, readbyte, readint, readint, readbyte]; end
59
58
  def next
60
- c = readchar while c != 0xFF
61
- c = readchar while c == 0xFF
59
+ c = readbyte while c != 0xFF
60
+ c = readbyte while c == 0xFF
62
61
  c
63
62
  end
64
63
  end unless io.respond_to? :readsof
65
64
 
65
+ raise 'malformed JPEG' unless io.readbyte == 0xFF && io.readbyte == 0xD8 # SOI
66
+
66
67
  app1s = []
67
68
  while marker = io.next
68
69
  case marker
69
70
  when 0xC0..0xC3, 0xC5..0xC7, 0xC9..0xCB, 0xCD..0xCF # SOF markers
70
71
  length, @bits, @height, @width, components = io.readsof
71
72
  raise 'malformed JPEG' unless length == 8 + components * 3
72
- when 0xD9, 0xDA: break # EOI, SOS
73
- when 0xFE: (@comment ||= []) << io.readframe # COM
74
- when 0xE1: app1s << io.readframe # APP1, may contain EXIF tag
73
+ when 0xD9, 0xDA; break # EOI, SOS
74
+ when 0xFE; (@comment ||= []) << io.readframe # COM
75
+ when 0xE1; app1s << io.readframe # APP1, may contain EXIF tag
75
76
  else io.readframe # ignore frame
76
77
  end
77
78
  end
data/lib/tiff.rb CHANGED
@@ -238,7 +238,7 @@ module EXIFR
238
238
 
239
239
  time_proc = proc do |value|
240
240
  if value =~ /^(\d{4}):(\d\d):(\d\d) (\d\d):(\d\d):(\d\d)$/
241
- Time.mktime($1, $2, $3, $4, $5, $6) rescue nil
241
+ Time.mktime($1.to_i, $2.to_i, $3.to_i, $4.to_i, $5.to_i, $6.to_i) rescue nil
242
242
  else
243
243
  value
244
244
  end
@@ -258,13 +258,13 @@ module EXIFR
258
258
  # Rotate and/or flip for proper viewing.
259
259
  def transform_rmagick(img)
260
260
  case @type
261
- when :TopRight : img.flop
262
- when :BottomRight : img.rotate(180)
263
- when :BottomLeft : img.flip
264
- when :LeftTop : img.rotate(90).flop
265
- when :RightTop : img.rotate(90)
266
- when :RightBottom : img.rotate(270).flop
267
- when :LeftBottom : img.rotate(270)
261
+ when :TopRight ; img.flop
262
+ when :BottomRight ; img.rotate(180)
263
+ when :BottomLeft ; img.flip
264
+ when :LeftTop ; img.rotate(90).flop
265
+ when :RightTop ; img.rotate(90)
266
+ when :RightBottom ; img.rotate(270).flop
267
+ when :LeftBottom ; img.rotate(270)
268
268
  else
269
269
  img
270
270
  end
@@ -418,11 +418,13 @@ module EXIFR
418
418
  end
419
419
 
420
420
  def to_yaml_properties
421
- '@fields'
421
+ ['@fields']
422
422
  end
423
+
423
424
  private
424
425
  def add_field(field)
425
426
  return unless tag = TAG_MAPPING[@type][field.tag]
427
+ return if @fields[tag]
426
428
 
427
429
  if IFD_TAGS.include? tag
428
430
  @fields[tag] = IFD.new(@data, field.offset, tag)
@@ -469,7 +471,7 @@ module EXIFR
469
471
 
470
472
  if len && pack
471
473
  start = len > 4 ? @offset : (pos + 8)
472
- @value = pack[data[start..(start + len - 1)]]
474
+ @value = [pack[data[start..(start + len - 1)]]].flatten
473
475
  end
474
476
  end
475
477
  end
metadata CHANGED
@@ -1,33 +1,27 @@
1
1
  --- !ruby/object:Gem::Specification
2
- rubygems_version: 0.9.4
3
- specification_version: 1
4
2
  name: exifr
5
3
  version: !ruby/object:Gem::Version
6
- version: 0.10.4
7
- date: 2007-11-04 00:00:00 +01:00
8
- summary: EXIF Reader is a module to read EXIF from JPEG images.
9
- require_paths:
10
- - lib
11
- email: remco@remvee.net
12
- homepage: http://exifr.rubyforge.org/
13
- rubyforge_project:
14
- description:
15
- autorequire: exifr
16
- default_executable:
17
- bindir: bin
18
- has_rdoc: true
19
- required_ruby_version: !ruby/object:Gem::Version::Requirement
20
- requirements:
21
- - - ">"
22
- - !ruby/object:Gem::Version
23
- version: 0.0.0
24
- version:
4
+ version: 0.10.5
25
5
  platform: ruby
26
- signing_key:
27
- cert_chain:
28
- post_install_message:
29
6
  authors:
30
7
  - R.W. van 't Veer
8
+ autorequire: exifr
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2007-12-28 00:00:00 +01:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description:
17
+ email: remco@remvee.net
18
+ executables:
19
+ - exifr
20
+ extensions: []
21
+
22
+ extra_rdoc_files:
23
+ - README
24
+ - CHANGELOG
31
25
  files:
32
26
  - Rakefile
33
27
  - bin/exifr
@@ -55,18 +49,31 @@ files:
55
49
  - tests/data/weird_date.exif
56
50
  - README
57
51
  - CHANGELOG
58
- test_files: []
59
-
52
+ has_rdoc: true
53
+ homepage: http://exifr.rubyforge.org/
54
+ post_install_message:
60
55
  rdoc_options: []
61
56
 
62
- extra_rdoc_files:
63
- - README
64
- - CHANGELOG
65
- executables:
66
- - exifr
67
- extensions: []
68
-
57
+ require_paths:
58
+ - lib
59
+ required_ruby_version: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - ">="
62
+ - !ruby/object:Gem::Version
63
+ version: "0"
64
+ version:
65
+ required_rubygems_version: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: "0"
70
+ version:
69
71
  requirements: []
70
72
 
71
- dependencies: []
73
+ rubyforge_project:
74
+ rubygems_version: 1.0.1
75
+ signing_key:
76
+ specification_version: 2
77
+ summary: EXIF Reader is a module to read EXIF from JPEG images.
78
+ test_files: []
72
79