RMagick and Image Manipulation

If the image is really large, performing RMagick operations on it could take time. I was under the impression that this was blocking, but maybe I’m wrong, but anyways, try moving your thumbnail manipulations before the original image:

#thumb
thumb = (RAILS_ROOT + "/public/client_images/#

{client}/" +
Image.thumbnail_name_for(photo.filename))
image = Magick::ImageList.new(thumb)

  image   = image.rotate(-90)
  image.write(thumb)

before:

image = Magick::ImageList.new(“public/client_images/#
{client}/”

  • photo.filename)
    image = image.rotate(-90)
    image.write(“public/client_images/#{client}/” + photo.filename)

Also, an implementation consideration: you could consider queueing up the effects applied (in a session variable array, [‘rotate:90’, ‘scale:2’] etc. perhaps) and only applying the effects to the original image when the user hits “save”. Do the operations only on the thumb meanwhile since only that’s getting displayed.

If the thumb is small, Firefox supports data urls, data:
http://www.andrewwooldridge.com/blog/2005/11/firefox-canvas-supports-data-urls.html

You can pass this inline in the index file, tho this is definitely clunky.

Vish