uploadcolumn 0.3.0 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/VERSION +1 -1
- data/lib/upload_column/manipulators/rmagick.rb +19 -14
- metadata +3 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.3.
|
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.
|
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
|
-
-
|
9
|
-
version: 0.3.
|
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
|
+
date: 2010-03-20 00:00:00 +00:00
|
20
20
|
default_executable:
|
21
21
|
dependencies: []
|
22
22
|
|