Forum: Ruby on Rails File_column and rmagick options

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
9dbe5b9021bf8477a3b7e747b44bde48?d=identicon&s=25 Sean O'Hara (Guest)
on 2006-02-03 04:44
(Received via mailing list)
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
9dbe5b9021bf8477a3b7e747b44bde48?d=identicon&s=25 Sean O'Hara (Guest)
on 2006-02-12 00:47
(Received via mailing list)
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
0747214fd9c3537493494b1612a686de?d=identicon&s=25 Alien8 Recordings (Guest)
on 2006-02-12 03:43
(Received via mailing list)
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
> Rails@lists.rubyonrails.org
> http://lists.rubyonrails.org/mailman/listinfo/rails
>
>

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

http://www.alien8recordings.com
64f8084c418ad62c29a1673427ad5042?d=identicon&s=25 Dave Krupinski (Guest)
on 2006-11-28 00:28
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
>> Rails@lists.rubyonrails.org
>> http://lists.rubyonrails.org/mailman/listinfo/rails
>>
>>
>
> ______________
> ALIEN8 RECORDINGS
> P.O. BOX 666, STATION R
> MONTREAL, QC
> CANADA, H2S 3L1
>
> http://www.alien8recordings.com
This topic is locked and can not be replied to.