Skip to content

Commit

Permalink
feat: make fd0's priority higher than fd1 when same tag being used by…
Browse files Browse the repository at this point in the history
… both

BREAKING CHANGE: All top-level APIs will seek ifd0 tags first instead of ifd1, to retrieve tags from ifd1, use `Exif::Data#[]`, for example:

    ```ruby
    # to retrieve image width of ifd0
    data.image_width
    data[:ifd0][:image_width]
    # to retrieve image width of ifd1
    data[:ifd1][:image_width]
    ```
  • Loading branch information
tonytonyjan committed Sep 12, 2017
1 parent 9fbf4d7 commit 1db5274
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 3 additions & 1 deletion ext/exif/data.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,9 @@ static void each_entry(ExifEntry *entry, void *self_ptr){
ID2SYM(rb_intern(ivar_name + 1)),
value
);
rb_iv_set(*(VALUE*)self_ptr, ivar_name, value);
if(TYPE(rb_ivar_defined(*(VALUE*)self_ptr, rb_intern(ivar_name))) == T_FALSE){
rb_iv_set(*(VALUE*)self_ptr, ivar_name, value);
}
}

static VALUE exif_entry_to_rb_value(ExifEntry *entry){
Expand Down
4 changes: 2 additions & 2 deletions test/test_exif.rb
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,8 @@ def test_ascii
end

def test_rational
# assert_equal Rational(72, 1), data.x_resolution
# assert_equal Rational(72, 1), data.y_resolution
assert_equal Rational(300, 1), data.x_resolution
assert_equal Rational(300, 1), data.y_resolution
assert_equal Rational(1, 125), data.exposure_time
assert_equal Rational(8, 1), data.fnumber
assert_equal Rational(870723, 125000), data.shutter_speed_value
Expand Down

0 comments on commit 1db5274

Please sign in to comment.