Best way to upload an image and make a thumbnail

I'd do a system call to image magic's convert program to make the
thumbnail... about the best performance your going to get

def thumbnail(temp, target)
    "/usr/local/bin/convert #{escape(temp)} -resize 48x48!

DHH touches on this in "Outsourcing the performance-intensive
functions" on this blog page:

Not really following you on what your asking about with the how to
upload part of the question? and not sure what javascript has to do
with it? It should just be a file-upload field as far as the browser
goes. For saving on the server I do something like this in one of my

  def save_file(file_name, file)
    fh =, 'w')

  def image=(img)
    return if img.blank?
    save_file("/whatever/name/for_my_file.jpg", img)

good luck!