imanip 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +6 -0
- data/lib/imanip/imanip_magick.rb +6 -7
- data/lib/imanip/version.rb +1 -1
- data/test/test_imanip_magick.rb +19 -0
- metadata +2 -2
data/History.txt
CHANGED
data/lib/imanip/imanip_magick.rb
CHANGED
@@ -49,6 +49,10 @@ module Imanip
|
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
52
|
+
def ratio
|
53
|
+
width.to_f / height.to_f
|
54
|
+
end
|
55
|
+
|
52
56
|
def crop(to_file, options = {})
|
53
57
|
@options = options
|
54
58
|
parse_size_options!
|
@@ -70,13 +74,8 @@ module Imanip
|
|
70
74
|
crop_width = @geometry[:width]
|
71
75
|
crop_height = @geometry[:height]
|
72
76
|
if !(crop_height.nil? || crop_width.nil?)
|
73
|
-
|
74
|
-
|
75
|
-
crop_resize_string << "-resize #{to_geometry_string(:width => crop_width)}"
|
76
|
-
else
|
77
|
-
crop_resize_string << "-resize #{to_geometry_string(:height => crop_height)}"
|
78
|
-
end
|
79
|
-
elsif portrait?
|
77
|
+
crop_ratio = crop_width.to_f / crop_height.to_f
|
78
|
+
if crop_ratio > ratio
|
80
79
|
crop_resize_string << "-resize #{to_geometry_string(:width => crop_width)}"
|
81
80
|
else
|
82
81
|
crop_resize_string << "-resize #{to_geometry_string(:height => crop_height)}"
|
data/lib/imanip/version.rb
CHANGED
data/test/test_imanip_magick.rb
CHANGED
@@ -47,6 +47,10 @@ class ImanipMagickTest < Test::Unit::TestCase
|
|
47
47
|
assert !@portrait_image.landscape?
|
48
48
|
end
|
49
49
|
|
50
|
+
def test_ratio_should_return_width_over_height
|
51
|
+
assert_equal(@landscape_image.width.to_f / @landscape_image.height.to_f, @landscape_image.ratio)
|
52
|
+
end
|
53
|
+
|
50
54
|
def test_resize_should_save_to_new_file
|
51
55
|
assert !File.readable?(new_image_path)
|
52
56
|
assert @portrait_image.resize(new_image_path, :width => 50)
|
@@ -73,6 +77,21 @@ class ImanipMagickTest < Test::Unit::TestCase
|
|
73
77
|
assert @portrait_image.crop_resize(new_image_path, :dimensions => dimensions)
|
74
78
|
@new_image = new_imanip_image(new_image_path)
|
75
79
|
assert_equal dimensions, @new_image.dimensions
|
80
|
+
|
81
|
+
dimensions = [200,153]
|
82
|
+
assert @landscape_image.crop_resize(new_image_path, :dimensions => dimensions)
|
83
|
+
@new_image = new_imanip_image(new_image_path)
|
84
|
+
assert_equal dimensions, @new_image.dimensions
|
85
|
+
|
86
|
+
dimensions = [100,125]
|
87
|
+
assert @portrait_image.crop_resize(new_image_path, :dimensions => dimensions)
|
88
|
+
@new_image = new_imanip_image(new_image_path)
|
89
|
+
assert_equal dimensions, @new_image.dimensions
|
90
|
+
|
91
|
+
dimensions = [100,125]
|
92
|
+
assert @landscape_image.crop_resize(new_image_path, :dimensions => dimensions)
|
93
|
+
@new_image = new_imanip_image(new_image_path)
|
94
|
+
assert_equal dimensions, @new_image.dimensions
|
76
95
|
end
|
77
96
|
|
78
97
|
def test_crop_resize_should_crop_and_resize_image_to_exact_dimensions_with_square_dimensions
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: imanip
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aaron Quint
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-
|
12
|
+
date: 2008-10-16 00:00:00 -04:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|