# Basic image process suggestion?

**URL:** <https://www.ruby-forum.com/t/basic-image-process-suggestion/86473>\
**Category:** Rails\
**Created:** [February 22, 2007, 4:02pm UTC](https://www.ruby-forum.com/t/basic-image-process-suggestion/86473 "2007-02-22T16:02:38Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![surfman](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/49beb7/32.png) [@surfman](https://www.ruby-forum.com/u/surfman)\
**Post date:** [February 22, 2007, 4:02pm UTC](https://www.ruby-forum.com/t/basic-image-process-suggestion/86473/1 "2007-02-22T16:02:38Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![surfman](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/49beb7/32.png) [@surfman](https://www.ruby-forum.com/u/surfman)\
**Post date:** [February 22, 2007, 4:54pm UTC](https://www.ruby-forum.com/t/basic-image-process-suggestion/86473/2 "2007-02-22T16:54:03Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![surfman](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/49beb7/32.png) [@surfman](https://www.ruby-forum.com/u/surfman)\
**Post date:** [February 22, 2007, 4:09pm UTC](https://www.ruby-forum.com/t/basic-image-process-suggestion/86473/3 "2007-02-22T16:09:47Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![surfman](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/49beb7/32.png) [@surfman](https://www.ruby-forum.com/u/surfman)\
**Post date:** [February 22, 2007, 7:43pm UTC](https://www.ruby-forum.com/t/basic-image-process-suggestion/86473/4 "2007-02-22T19:43:34Z")

</div>

Another recommendation would be the file\_column plug-in (http://  
[wiki.rubyonrails.org/rails/pages/HowToUseFileColumn](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.

---

<div class="post-metadata">

**Author:** ![surfman](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/49beb7/32.png) [@surfman](https://www.ruby-forum.com/u/surfman)\
**Post date:** [February 22, 2007, 8:35pm UTC](https://www.ruby-forum.com/t/basic-image-process-suggestion/86473/5 "2007-02-22T20:35:39Z")

</div>

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 [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Another recommendation would be the file\_column plug-in (http://  
> [wiki.rubyonrails.org/rails/pages/HowToUseFileColumn](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)

---

<div class="post-metadata">

**Author:** ![surfman](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/49beb7/32.png) [@surfman](https://www.ruby-forum.com/u/surfman)\
**Post date:** [February 23, 2007, 2:04pm UTC](https://www.ruby-forum.com/t/basic-image-process-suggestion/86473/6 "2007-02-23T14:04:36Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![surfman](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/49beb7/32.png) [@surfman](https://www.ruby-forum.com/u/surfman)\
**Post date:** [February 23, 2007, 2:50am UTC](https://www.ruby-forum.com/t/basic-image-process-suggestion/86473/7 "2007-02-23T02:50:19Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![surfman](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/49beb7/32.png) [@surfman](https://www.ruby-forum.com/u/surfman)\
**Post date:** [February 24, 2007, 2:44pm UTC](https://www.ruby-forum.com/t/basic-image-process-suggestion/86473/8 "2007-02-24T14:44:59Z")

</div>

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

> **[psitsnot.alevans.com is almost here!](http://psitsnot.alevans.com)**
>
> The owner of this domain has not yet uploaded their website.

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

–Al Evans

---

<div class="post-metadata">

**Author:** ![surfman](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/49beb7/32.png) [@surfman](https://www.ruby-forum.com/u/surfman)\
**Post date:** [February 24, 2007, 1:02am UTC](https://www.ruby-forum.com/t/basic-image-process-suggestion/86473/9 "2007-02-24T01:02:32Z")

</div>

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](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!
