You can get the dimension of the img using
img.columns, img.rows
I ended up doing something like this to prevent blurring of the cropped image:
ruby
defcropif model.crop_x.present?
#resize_to_limit(300, 3000)
manipulate! do |img|
converted_h = 300.0*img.rows/img.columns
x = (model.crop_x.to_i/300.0*img.columns).to_i
y = (model.crop_y.to_i/converted_h*img.rows).to_i
w = (model.crop_w.to_i/300.0*img.columns).to_i
h = (model.crop_h.to_i/converted_h*img.rows).to_i
#img.crop("#{w}x#{h}+#{x}+#{y}")
img.crop!(x, y, w, h)
img
endendend
You can get the dimension of the img using
img.columns, img.rows
I ended up doing something like this to prevent blurring of the cropped image:
**Noticed this was from 2 years ago...
have you solved this issue?