uploadcolumn 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.0
1
+ 0.3.1
@@ -1,16 +1,16 @@
1
1
  module UploadColumn
2
-
2
+
3
3
  UploadError = Class.new(StandardError) unless defined?(UploadError)
4
4
  ManipulationError = Class.new(UploadError) unless defined?(ManipulationError)
5
-
5
+
6
6
  module Manipulators
7
-
7
+
8
8
  module RMagick
9
-
9
+
10
10
  def load_manipulator_dependencies #:nodoc:
11
11
  require 'RMagick'
12
12
  end
13
-
13
+
14
14
  def process!(instruction = nil, &block)
15
15
  if instruction.is_a?(Proc)
16
16
  manipulate!(&instruction)
@@ -21,7 +21,7 @@ module UploadColumn
21
21
  end
22
22
  manipulate!(&block) if block
23
23
  end
24
-
24
+
25
25
  # Convert the image to format
26
26
  def convert!(format)
27
27
  manipulate! do |img|
@@ -29,14 +29,18 @@ module UploadColumn
29
29
  img
30
30
  end
31
31
  end
32
-
32
+
33
33
  # Resize the image so that it will not exceed the dimensions passed
34
34
  # via geometry, geometry should be a string, formatted like '200x100' where
35
35
  # the first number is the height and the second is the width
36
36
  def resize!( geometry )
37
37
  manipulate! do |img|
38
38
  img.change_geometry( geometry ) do |c, r, i|
39
- i.resize(c,r)
39
+ if i.rows > c || i.columns > r
40
+ i.resize(c,r)
41
+ else
42
+ i
43
+ end
40
44
  end
41
45
  end
42
46
  end
@@ -50,10 +54,10 @@ module UploadColumn
50
54
  img.crop_resized(h.to_i,w.to_i)
51
55
  end
52
56
  end
53
-
57
+
54
58
  def manipulate!
55
59
  image = ::Magick::Image.read(self.path)
56
-
60
+
57
61
  if image.size > 1
58
62
  list = ::Magick::ImageList.new
59
63
  image.each do |frame|
@@ -67,9 +71,10 @@ module UploadColumn
67
71
  # this is a more meaningful error message, which we could catch later
68
72
  raise ManipulationError.new("Failed to manipulate with rmagick, maybe it is not an image? Original Error: #{e}")
69
73
  end
70
-
74
+
71
75
  end
72
-
76
+
73
77
  end
74
-
75
- end
78
+
79
+ end
80
+
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 3
8
- - 0
9
- version: 0.3.0
8
+ - 1
9
+ version: 0.3.1
10
10
  platform: ruby
11
11
  authors:
12
12
  - Dave Hrycyszyn
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2010-03-19 00:00:00 +00:00
19
+ date: 2010-03-20 00:00:00 +00:00
20
20
  default_executable:
21
21
  dependencies: []
22
22