9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
# File 'lib/ii.rb', line 9
def self.resize(filename, new_filename, resize_ratio)
img = Magick::Image.read(filename).first
width = img.columns
height = img.rows
dest_height = height*resize_ratio
dest_width = width*resize_ratio
dest_height = dest_height < 1 ? 1 : dest_height
dest_width = dest_width < 1 ? 1:dest_width
new_img = img.resize(dest_width, dest_height, Magick::LanczosFilter, 0.8)
new_img2 = img.
new_img.write(new_filename) {self.quality = 70 }
img.destroy!
new_img.destroy!
end
|