Skip to content

Commit

Permalink
- Fixed thumbnail float imprecision errors. (jdelStrother)
Browse files Browse the repository at this point in the history
[git-p4: depot-paths = "//src/image_science/dev/": change = 7421]
  • Loading branch information
zenspider committed May 7, 2012
1 parent 2321a9d commit 5141a26
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/image_science.rb
Expand Up @@ -60,7 +60,7 @@ def thumbnail(size) # :yields: image
w, h = width, height
scale = size.to_f / (w > h ? w : h)

self.resize((w * scale).to_i, (h * scale).to_i) do |image|
self.resize((w * scale).round, (h * scale).round) do |image|
yield image
end
end
Expand Down
17 changes: 17 additions & 0 deletions test/test_image_science.rb
Expand Up @@ -157,4 +157,21 @@ def test_resize_negative

refute File.exists?(@tmppath)
end

def test_thumbnail
ImageScience.with_image @path do |img|
img.thumbnail(29) do |thumb|
assert thumb.save(@tmppath)
end
end

assert File.exists?(@tmppath)

ImageScience.with_image @tmppath do |img|
assert_kind_of ImageScience, img
assert_equal 29, img.height
assert_equal 29, img.width
end
end

end

0 comments on commit 5141a26

Please sign in to comment.