Rmagick

I’m developing a Ruby on Rails app, and I’ve used the RMagick’s crop_resized method, but it turns out that it’s not supported by the server’s environment. There’s no ‘crop!’ either.

I’ve tried following this
http://wiki.dreamhost.com/index.php/RMagick

but rmagick gave me an error when building “native extensions”. Has anyone solved this problem? (cropping images) or at least some workaround?

Nevermind, I’ve managed to mock something up with “resize” and “crop” (crop!, and resize! are not supported)

def crop_resized(img, ncols, nrows) img2 = img.copy if ncols != img2.columns || nrows != img2.rows scale = [ncols/img2.columns.to_f, nrows/img2.rows.to_f].max img2 = img2.resize(scale*img2.columns+0.5, scale*img2.rows+0.5) end img2 = img2.crop(Magick::CenterGravity, ncols, nrows) if ncols != img2.columns || nrows != img2.rows img2 end it’s far from gracefull, but it does the trick for me. (this actually comes from the source of the latest rmagick version with some modifications :slight_smile: )