# File\_column and rmagick options

**URL:** <https://www.ruby-forum.com/t/file-column-and-rmagick-options/100515>\
**Category:** Rails\
**Created:** [February 3, 2006, 4:44am UTC](https://www.ruby-forum.com/t/file-column-and-rmagick-options/100515 "2006-02-03T04:44:31Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sean\_OSHara](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/dbc845/32.png) [@Sean\_OSHara](https://www.ruby-forum.com/u/Sean_OSHara)\
**Post date:** [February 3, 2006, 4:44am UTC](https://www.ruby-forum.com/t/file-column-and-rmagick-options/100515/1 "2006-02-03T04:44:31Z")

</div>

Hi,

Currently I’m using the file\_column plugin to upload images and save  
multiple copies of each at 3 different resoltions:  
file\_column :name, :magick =\> {  
:versions =\> { “thumb96” =\> “96x150\>”, “medium250” =\>  
“250x400\>”, “large480” =\> “480X640\>” }  
}

I am wondering if there’s any way I can declare other rmagick options  
at the same time, specifically the -quality attribute, since the  
jpegs it outputs by default of very poor quality (serious compression  
artifacts). I tried the following:

file\_column :name, :magick =\> {  
:quality =\> ‘90’,  
:versions =\> { “thumb96” =\> “96x150\>”, “medium250” =\>  
“250x400\>”, “large480” =\> “480X640\>” }  
}  
but it doesn’t seem to have any effect. Is it possible to send other  
rmagick parameters to file\_column if you are already using  
the :versions option? If not, any ideas on how I could work around this?

Thanks,  
Sean

---

<div class="post-metadata">

**Author:** ![Sean\_OSHara](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/dbc845/32.png) [@Sean\_OSHara](https://www.ruby-forum.com/u/Sean_OSHara)\
**Post date:** [February 12, 2006, 12:47am UTC](https://www.ruby-forum.com/t/file-column-and-rmagick-options/100515/2 "2006-02-12T00:47:57Z")

</div>

Hi All,

Regarding the problem I was having below, after going through some of  
the file\_column source, it seems that only specific rmagick options  
get processed, namely those that are hardcoded into the plugin by the  
developer: :crop, :size and :versions. I was a little surprised  
because the documentation seemed to imply that general rmagick  
options could be passed via the options hash. Of course I am a newbie  
to Ruby so I could just be reading the code wrong.

So, I want to modify the file\_column source to ensure that when  
images are resized they are saved with a higher quality jpeg  
compression than is the default. In rmagick\_file\_column.rb, in the  
resize\_image method definition, I change the following:

```
     if img_options[:size]
       img = img.change_geometry(img_options[:size]) do |c, r, i|
         i.resize(c, r)
       end

```

to:

```
     if img_options[:size]
       img = img.change_geometry(img_options[:size]) do |c, r, i|
         self.radial_blur = 15
         i.resize(c, r)
       end

```

I’ve just used radial\_blur as a stand in rmagick method for now  
because the results will be more readily apparent through visual  
inspection than changing jpeg compression quality.

The change I made doesn’t seem to have any effect. Any ideas?

Thanks,  
Sean

---

<div class="post-metadata">

**Author:** ![Sean\_OSHara](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/dbc845/32.png) [@Sean\_OSHara](https://www.ruby-forum.com/u/Sean_OSHara)\
**Post date:** [February 12, 2006, 3:43am UTC](https://www.ruby-forum.com/t/file-column-and-rmagick-options/100515/3 "2006-02-12T03:43:44Z")

</div>

Hi All,

Sorry for the noise on this lonely thread. I actually found an answer  
to my problem. The quality setting has to be passed to the .write  
method, which is called just after the resize method definition. I  
changed it to this:

```
   ensure
     img.write(dest_path) { self.quality = 100 }
     File.chmod options[:permissions], dest_path
   end

```

The images look much better now.

Take care,  
Sean

On 11-Feb-06, at 6:47 PM, Sean O’Hara wrote:

> So, I want to modify the file\_column source to ensure that when
> 
> The change I made doesn’t seem to have any effect. Any ideas?
> 
> > save multiple copies of each at 3 different resoltions:  
> > file\_column :name, :magick =\> {  
> > Sean
> 
> * * *
> 
> Rails mailing list  
> removed\_email\_address@domain.invalid  
> [http://lists.rubyonrails.org/mailman/listinfo/rails](http://lists.rubyonrails.org/mailman/listinfo/rails)

* * *

ALIEN8 RECORDINGS  
P.O. BOX 666, STATION R  
MONTREAL, QC  
CANADA, H2S 3L1

[http://www.alien8recordings.com](http://www.alien8recordings.com)

---

<div class="post-metadata">

**Author:** ![Sean\_OSHara](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/dbc845/32.png) [@Sean\_OSHara](https://www.ruby-forum.com/u/Sean_OSHara)\
**Post date:** [November 28, 2006, 12:28am UTC](https://www.ruby-forum.com/t/file-column-and-rmagick-options/100515/4 "2006-11-28T00:28:44Z")

</div>

Not sure if the post is anywhere active, but the tag does have support  
for quality (and probably most other things) through the ‘attributes’  
parameters.

so you want to do something like

file\_column :name, :magick =\> { :versions =\> { “thumb96” =\> “96x150\>”  
}, :attributes =\> { :size =\> 100 } }

Alien8 Recordings wrote:

> Hi All,
> 
> Sorry for the noise on this lonely thread. I actually found an answer  
> to my problem. The quality setting has to be passed to the .write  
> method, which is called just after the resize method definition. I  
> changed it to this:
> 
> ```
> ensure
> img.write(dest_path) { self.quality = 100 }
> File.chmod options[:permissions], dest_path
> end
> 
> ```
> 
> The images look much better now.
> 
> Take care,  
> Sean
> 
> On 11-Feb-06, at 6:47 PM, Sean O’Hara wrote:
> 
> > So, I want to modify the file\_column source to ensure that when
> > 
> > The change I made doesn’t seem to have any effect. Any ideas?
> > 
> > > save multiple copies of each at 3 different resoltions:  
> > > file\_column :name, :magick =\> {  
> > > Sean
> > 
> > * * *
> > 
> > Rails mailing list  
> > removed\_email\_address@domain.invalid  
> > [http://lists.rubyonrails.org/mailman/listinfo/rails](http://lists.rubyonrails.org/mailman/listinfo/rails)
> 
> * * *
> 
> ALIEN8 RECORDINGS  
> P.O. BOX 666, STATION R  
> MONTREAL, QC  
> CANADA, H2S 3L1
> 
> [http://www.alien8recordings.com](http://www.alien8recordings.com)
