@@ -7,7 +7,7 @@ def self.included(base)
7
7
base . send :extend , ClassMethods
8
8
base . alias_method_chain :process_attachment , :processing
9
9
end
10
-
10
+
11
11
module ClassMethods
12
12
# Yields a block containing an MiniMagick Image for the given binary data.
13
13
def with_image ( file , &block )
@@ -23,7 +23,7 @@ def with_image(file, &block)
23
23
!binary_data . nil?
24
24
end
25
25
end
26
-
26
+
27
27
protected
28
28
def process_attachment_with_processing
29
29
return unless process_attachment_without_processing
@@ -34,7 +34,7 @@ def process_attachment_with_processing
34
34
callback_with_args :after_resize , img
35
35
end if image?
36
36
end
37
-
37
+
38
38
# Performs the actual resizing operation for a thumbnail
39
39
def resize_image ( img , size )
40
40
size = size . first if size . is_a? ( Array ) && size . length == 1
@@ -46,9 +46,9 @@ def resize_image(img, size)
46
46
if format == 'GIF'
47
47
img . format ( 'PNG' )
48
48
end
49
-
50
- if size . is_a? ( Fixnum ) || ( size . is_a? ( Array ) && size . first . is_a? ( Fixnum ) )
51
- if size . is_a? ( Fixnum )
49
+
50
+ if size . is_a? ( Integer ) || ( size . is_a? ( Array ) && size . first . is_a? ( Integer ) )
51
+ if size . is_a? ( Integer )
52
52
size = [ size , size ]
53
53
commands . resize ( size . join ( 'x' ) )
54
54
else
@@ -64,16 +64,16 @@ def resize_image(img, size)
64
64
# crop thumbnail, the smart way
65
65
elsif size . is_a? ( String ) and size =~ /c$/
66
66
size = size . gsub ( /c/ , '' )
67
-
67
+
68
68
# calculate sizes and aspect ratio
69
69
thumb_width , thumb_height = size . split ( "x" )
70
70
thumb_width = thumb_width . to_f
71
71
thumb_height = thumb_height . to_f
72
-
72
+
73
73
thumb_aspect = thumb_width . to_f / thumb_height . to_f
74
74
image_width , image_height = img [ :width ] . to_f , img [ :height ] . to_f
75
75
image_aspect = image_width / image_height
76
-
76
+
77
77
# only crop if image is not smaller in both dimensions
78
78
unless image_width < thumb_width and image_height < thumb_height
79
79
command = calculate_offset ( image_width , image_height , image_aspect , thumb_width , thumb_height , thumb_aspect )
@@ -83,7 +83,7 @@ def resize_image(img, size)
83
83
end
84
84
85
85
# don not resize if image is not as height or width then thumbnail
86
- if image_width < thumb_width or image_height < thumb_height
86
+ if image_width < thumb_width or image_height < thumb_height
87
87
commands . background ( '#ffffff' )
88
88
commands . gravity ( 'center' )
89
89
commands . extent ( size )
@@ -120,7 +120,7 @@ def calculate_offset(image_width,image_height,image_aspect,thumb_width,thumb_hei
120
120
command = "#{ thumb_width } x#{ image_height } +#{ offset } +0"
121
121
122
122
# normal thumbnail generation
123
- # calculate height and offset y, width is fixed
123
+ # calculate height and offset y, width is fixed
124
124
elsif ( image_aspect <= thumb_aspect or image_width < thumb_width ) and image_height > thumb_height
125
125
height = image_width / thumb_aspect
126
126
offset = ( image_height / 2 ) - ( height / 2 )
@@ -139,4 +139,4 @@ def calculate_offset(image_width,image_height,image_aspect,thumb_width,thumb_hei
139
139
end
140
140
end
141
141
end
142
- end
142
+ end
0 commit comments