# Resizing images and creating thumbnails

**URL:** <https://www.ruby-forum.com/t/resizing-images-and-creating-thumbnails/77045>\
**Category:** Rails\
**Created:** [March 5, 2006, 9:27pm UTC](https://www.ruby-forum.com/t/resizing-images-and-creating-thumbnails/77045 "2006-03-05T21:27:31Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![g0nzo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/3bc359/32.png) [@g0nzo](https://www.ruby-forum.com/u/g0nzo)\
**Post date:** [March 5, 2006, 9:27pm UTC](https://www.ruby-forum.com/t/resizing-images-and-creating-thumbnails/77045/1 "2006-03-05T21:27:31Z")

</div>

Hi,

1. How to resize an image uploaded by a web form before saving it to the  
disk? (i need all uploaded images to have similar size)

2. How to create thumbnails? Is it enough if i specify small size of the  
image in html or would the image look horrible? Can i do it somehow in  
‘realtime’ using javascript? Or is it best to create thumbnail as a  
separate file?

3. How to get file (image) extension?

---

<div class="post-metadata">

**Author:** ![g0nzo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/3bc359/32.png) [@g0nzo](https://www.ruby-forum.com/u/g0nzo)\
**Post date:** [March 5, 2006, 10:01pm UTC](https://www.ruby-forum.com/t/resizing-images-and-creating-thumbnails/77045/2 "2006-03-05T22:01:57Z")

</div>

On 3/5/06, g0nzo [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Hi,
> 
> 1. How to resize an image uploaded by a web form before saving it to the  
> disk? (i need all uploaded images to have similar size)

rmagick

1. How to create thumbnails? Is it enough if i specify small size of the

> image in html or would the image look horrible? Can i do it somehow in  
> ‘realtime’ using javascript? Or is it best to create thumbnail as a  
> separate file?

It’s better to create the thumbnail.  
Check the file\_column plugin.

---

<div class="post-metadata">

**Author:** ![g0nzo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/3bc359/32.png) [@g0nzo](https://www.ruby-forum.com/u/g0nzo)\
**Post date:** [March 5, 2006, 10:53pm UTC](https://www.ruby-forum.com/t/resizing-images-and-creating-thumbnails/77045/3 "2006-03-05T22:53:09Z")

</div>

Thanks!

I took a (very) quick look on file\_column plugin and got few questions:  
Does it keep the file or just the filename in the database?  
Can i change the name of uploaded file before saving it?

BTW. Generally, is it better to save the file to the database or just  
store there its name and the file itself on the disk?

---

<div class="post-metadata">

**Author:** ![g0nzo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/3bc359/32.png) [@g0nzo](https://www.ruby-forum.com/u/g0nzo)\
**Post date:** [March 5, 2006, 11:03pm UTC](https://www.ruby-forum.com/t/resizing-images-and-creating-thumbnails/77045/4 "2006-03-05T23:03:41Z")

</div>

I’ve just found that “Files are stored in the filesystem and the  
filename in the database.” 🙂

So can i change their name before saving them?

---

<div class="post-metadata">

**Author:** ![g0nzo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/3bc359/32.png) [@g0nzo](https://www.ruby-forum.com/u/g0nzo)\
**Post date:** [March 6, 2006, 12:36am UTC](https://www.ruby-forum.com/t/resizing-images-and-creating-thumbnails/77045/5 "2006-03-06T00:36:12Z")

</div>

On 3/5/06, g0nzo [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Thanks!
> 
> I took a (very) quick look on file\_column plugin and got few questions:  
> Does it keep the file or just the filename in the database?

the filename.

Can i change the name of uploaded file before saving it?

Look at file\_column documentation and source code, since i don’t  
remember if  
you can change the filename.

BTW. Generally, is it better to save the file to the database or just

> store there its name and the file itself on the disk?

It seems that file systems are good at storing files ;-).  
Your web server can serve static content as images/files in general  
faster  
if they are stored on the disk.

–
