Basic image process suggestion?

I need

  1. upload image (JPG/GIF/BMP/etc) to pre-designated path
  2. auto resize the image and generate thumb image based on the
    pre-defined width or length, keep ratio
  3. best performance

Thanks for any recommendation.

Surfman J. wrote:

I need

  1. upload image (JPG/GIF/BMP/etc) to pre-designated path
  2. auto resize the image and generate thumb image based on the
    pre-defined width or length, keep ratio
  3. best performance

Thanks for any recommendation.

Investigate the acts_as_attachment plugin which has RMagick integration.

Take a look at RMagic. Good for what your looking for.

Another recommendation would be the file_column plug-in (http://
wiki.rubyonrails.org/rails/pages/HowToUseFileColumn). It is lighter
(though not necessarily better) than acts_as_attachement and also uses
RMagick for image manipulation.

Do NOT use RMagick for image manipulation. Using RMagick in a rails
process will cause the memory usage of each process to skyrocket. You
will run into a lot of trouble later on (from personal experience).

Delegate image manipulation to a seperate process. The easiest thing
to do in this case is simply run convert (imagemagick’s command line
tool) on the image to generate a thumbnail.

-carl

On 2/22/07, Jeff [email protected] wrote:

Another recommendation would be the file_column plug-in (http://
wiki.rubyonrails.org/rails/pages/HowToUseFileColumn). It is lighter
(though not necessarily better) than acts_as_attachement and also uses
RMagick for image manipulation.


EPA Rating: 3000 Lines of Code / Gallon (of coffee)

Which rules out the memory problem and proves the use of actually
reading
documentation. :slight_smile:

The RMagick documentation is clear on this - you must invoke the
Garbage collector manually after RMagick processing, as Ruby doesn’t
track the RMagick memory used.

file_column does this, but if you do your own RMagick code, you must
call GC.start once your processing is complete.

Tim H. wrote:

Tom F. wrote:

The RMagick documentation is clear on this - you must invoke the
Garbage collector manually after RMagick processing, as Ruby doesn’t
track the RMagick memory used.

file_column does this, but if you do your own RMagick code, you must
call GC.start once your processing is complete.

Thanks for saying this, Tom. I’m glad to see that this information is
getting out. It makes me sad when people say that RMagick “leaks” memory
when judicious use of GC.start would’ve solved their problem. If they
had emailed me I would’ve tried to help.

Tim speaks the truth on both counts. RMagick doesn’t leak memory if you
remember to call GC.start after each image-processing operation. AND
he’s a very helpful person.

I’ve got an all-RMagick application at

It’s been running for almost a year, on a shared host, and has no memory
issues.

–Al Evans

Tom F. wrote:

The RMagick documentation is clear on this - you must invoke the
Garbage collector manually after RMagick processing, as Ruby doesn’t
track the RMagick memory used.

file_column does this, but if you do your own RMagick code, you must
call GC.start once your processing is complete.

Thanks for saying this, Tom. I’m glad to see that this information is
getting out. It makes me sad when people say that RMagick “leaks” memory
when judicious use of GC.start would’ve solved their problem. If they
had emailed me I would’ve tried to help.

Not that I’m saying that it’s impossible for RMagick to have a memory
leak. That would just be asking for trouble! I am saying that anybody
who thinks that RMagick has a memory leak should email me at rmagick AT
rubyforge DOT org to complain, or open a bug track on RubyForge. If I
know about a problem and can reproduce it, then I can fix it. I’d even
thank you for reporting the problem!

P.S. The RMagick documentation that Tom is referring to is a thread in
the RMagick Hints and Tips Forum on RubyForge:
http://rubyforge.org/forum/forum.php?thread_id=1374&forum_id=1618. If
you have a suggestion about a better way for me to promulgate this
information please let me know. Thanks!