# File\_column and Thumbnails

**URL:** <https://www.ruby-forum.com/t/file-column-and-thumbnails/58609>\
**Category:** Rails\
**Created:** [April 24, 2006, 12:32am UTC](https://www.ruby-forum.com/t/file-column-and-thumbnails/58609 "2006-04-24T00:32:51Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![HHHHHH](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/50afbb/32.png) [@HHHHHH](https://www.ruby-forum.com/u/HHHHHH)\
**Post date:** [April 24, 2006, 12:32am UTC](https://www.ruby-forum.com/t/file-column-and-thumbnails/58609/1 "2006-04-24T00:32:51Z")

</div>

I see that the SVN version of the excellent file\_column plug-in can  
create  
thumbnails using the url\_for\_image\_column helper.

This uses Rmagick to create the thumbnail… Quick question…

Let’s say the file is a TIFF image - can the helper create a JPG version  
of  
the thumbnail for display in the browser?

Curious if the plug-in can handle that transform with some creative use  
of  
the options. Any ideas before I hack up the plug-in code myself?

---

<div class="post-metadata">

**Author:** ![HHHHHH](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/50afbb/32.png) [@HHHHHH](https://www.ruby-forum.com/u/HHHHHH)\
**Post date:** [April 24, 2006, 8:07am UTC](https://www.ruby-forum.com/t/file-column-and-thumbnails/58609/2 "2006-04-24T08:07:56Z")

</div>

I believe it can using Rmagick. If you read the rdoc documentation for  
file\_column you can interact with Magick directly. I don’t have it in  
front of me right now so I can’t be more help :(.

A good, integrated and well-documented image manipulation library  
is one of a few things I miss from my PHP days.

Nicholas P. Mueller

---

<div class="post-metadata">

**Author:** ![HHHHHH](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/50afbb/32.png) [@HHHHHH](https://www.ruby-forum.com/u/HHHHHH)\
**Post date:** [April 24, 2006, 1:52pm UTC](https://www.ruby-forum.com/t/file-column-and-thumbnails/58609/3 "2006-04-24T13:52:30Z")

</div>

HH wrote:

> I see that the SVN version of the excellent file\_column plug-in can  
> create  
> thumbnails using the url\_for\_image\_column helper.
> 
> This uses Rmagick to create the thumbnail… Quick question…
> 
> Let’s say the file is a TIFF image - can the helper create a JPG version  
> of  
> the thumbnail for display in the browser?
> 
> Curious if the plug-in can handle that transform with some creative use  
> of  
> the options. Any ideas before I hack up the plug-in code myself?

Yes, you can do that. Actually, you shouldn’t have to do much hacking –  
RMagick (or rather, ImageMagick/GraphicsMagick behind it) can determine  
what kind of image you feed it.

Here’s the code I use to convert an uploaded photo to a thumbnail that’s  
96 pixels in its longest dimension:

def write\_photo\_file(photo\_data)  
img = Image.from\_blob(photo\_data)  
img.first.strip!.change\_geometry(“96x96”) { |cols, rows, img|  
img.resize!(cols, rows)  
}  
img.write(User.photo\_file\_name\_for(self.id)) { self.quality = 50 }  
end

Not much to it…

–Al Evans
