# Flex image - processed images generation

**URL:** <https://www.ruby-forum.com/t/flex-image-processed-images-generation/177953>\
**Category:** Rails\
**Created:** [October 27, 2009, 9:11am UTC](https://www.ruby-forum.com/t/flex-image-processed-images-generation/177953 "2009-10-27T09:11:45Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ct9a](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/ad7895/32.png) [@ct9a](https://www.ruby-forum.com/u/ct9a)\
**Post date:** [October 27, 2009, 9:11am UTC](https://www.ruby-forum.com/t/flex-image-processed-images-generation/177953/1 "2009-10-27T09:11:45Z")

</div>

hi, guys,

I have been researching on an image uploader plugin to use for my  
application.

I have my eyes of fleximage at the moment.

One of the links I read was [GitHub - AlexJWayne/fleximage: Rails plugin for uploading images as resources, with support for resizing, text stamping, and other special effects.](http://github.com/Squeegy/fleximage).

Pretty neat I must say.

I just have some questions:

1. Seems to be that thumbnails generation and rendering of images (ie  
uploaded images get applied with watermarks) happen dynamically (ie.  
the watermarked thumbnails are generated when a request is made).  
Sorry, looked at the source code for Resize and it seems to be the  
case.  
Can anyone confirm that this is the case?

2. Has anyone used FlexImage in their production environment and can  
comment if dynamically generating images would take up the server’s  
available resources (ie. memory footprint)?

3. Has anyone got another plugin to recommend that would satisfy the  
following criteria?

- can resize thumbnails to different sizes (ie, small, medium,  
large)?
- can apply watermarks to uploaded images?
- images can be stored in either database or file system ( allows  
future expansion or swap from one storage method to another)

thank you

---

<div class="post-metadata">

**Author:** ![ct9a](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/ad7895/32.png) [@ct9a](https://www.ruby-forum.com/u/ct9a)\
**Post date:** [October 27, 2009, 4:46pm UTC](https://www.ruby-forum.com/t/flex-image-processed-images-generation/177953/2 "2009-10-27T16:46:40Z")

</div>

> 1. Seems to be that thumbnails generation and rendering of images (ie  
> uploaded images get applied with watermarks) happen dynamically (ie.  
> the watermarked thumbnails are generated when a request is made).  
> Sorry, looked at the source code for Resize and it seems to be the  
> case.  
> Can anyone confirm that this is the case?

This is true. But you can cache the result to disk using Rails  
caches\_page… Long ago I had this in one of my controllers:

class HomeController \< ApplicationController

caches\_page :photo, :thumb

flex\_image :action =\> ‘photo’,  
:class =\> Photo,  
:quality =\> 95,  
:shadow =\> {  
:color =\> ‘#000’,  
:background =\> ‘#fff’,  
:blur =\> 4,  
:offset =\> ‘2x2’,  
:opacity =\> 0.75  
},  
:overlay =\> {  
:file =\> ‘public/images/watermark.png’,  
:alignment =\> :bottom\_right,  
:offset =\> 0  
}

```
# there was a thumb one too, but have removed it to save room.

```

end

If you go to the url below the thumbnails are generated (and cached)  
using the above code and if you click on the image you’ll see the  
larger version with watermark.

[http://overthefencecards.com/our\_products/package/13-mosaics-collection-6-cards](http://overthefencecards.com/our_products/package/13-mosaics-collection-6-cards)

> 1. Has anyone used FlexImage in their production environment and can  
> comment if dynamically generating images would take up the server’s  
> available resources (ie. memory footprint)?

They will take up RAM when being generated. If you cache them they  
will take up disk space, but after that are like any other image.

> 1. Has anyone got another plugin to recommend that would satisfy the  
> following criteria?
> 
> - can resize thumbnails to different sizes (ie, small, medium,  
> large)?
> - can apply watermarks to uploaded images?
> - images can be stored in either database or file system ( allows  
> future expansion or swap from one storage method to another)

paperclip can do this I think. I know it can resize and if you google  
I’m sure someone has instructions on how to set it up to watermark the  
images (it uses ImageMagick underneath which can watermark so should  
be doable). Images can be stored in the filesystem or on S3. Not  
sure about in a database (just never paid attention to that part).

---

<div class="post-metadata">

**Author:** ![ct9a](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/ad7895/32.png) [@ct9a](https://www.ruby-forum.com/u/ct9a)\
**Post date:** [November 5, 2009, 5:30am UTC](https://www.ruby-forum.com/t/flex-image-processed-images-generation/177953/3 "2009-11-05T05:30:42Z")

</div>

guys, I am using paperclip and have been prettyhappy with it.

One thing though is that if I were to specify my image dimensions for  
landscape images (ie. 600x400, 800x600, 1024x768 and so forth),  
uploading pictures which are portrait (ie. 400x600, 600x800, 768x1024  
and so forth) would cause cropping and streching (undesired).

When using ImageMagicK with perl (via PerlMagick), I used to detect if  
width\>height, then it is a landscape and I will resize by means of  
width x height. Otherwise, being portrait, I would resize by means of  
height x weight.

I might have a closer look at this tonight but any ideas of how to  
overcome this problem in Rails?

thanks 🙂

gordon
