This is simple trumpet blowing but there is a gem I wrote called
thumbnailer (as in 'gem install thumbnailer') that resizes images into
boxes with out without transparency, it can also scale images down to
a maximum width or height.
The project is here http://rubyforge.org/projects/thumbnailer/
and the docs can be seen here http://thumbnailer.rubyforge.org/doc/index.html
At some point I intend to announce that I have written it but there is
so much to be worked on. Requires gd2 and exifr.