1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
after_attachment_saved do |photo|
image=MiniMagick::Image.from_file(photo.full_filename)
height=image["height"]
width=image["width"]
if height<100 or width<100
image.resize "100x100!"
else
image.combine_options do |c|
c.resize height>100 ? "100x" : "x100"
c.gravity "Center"
c.crop("100x100+0+0")
end
end
image.write(photo.full_filename)
end
|