Forum: Ruby on Rails file_column Cropping -> image offset information

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Martijn van Leeuwen (Guest)
on 2006-03-08 13:36
(Received via mailing list)

I had a problem cropping images with file_column. These are my settings:

file_column :image, :magick => {
        :versions => {
            :thumb => "80x80>",
            :medium => "150x150>",
            :square => {
                :crop => "1:1",
                :size => "50x50!"
        :geometry => "400x300>"

With a square thumbnail i had the following problem; the offset
information of the images wasn't reset. The i found this in the rmagick

The |crop| method retains the offset information in the cropped image.
This may cause the image to appear to be surrounded by blank or black
space when viewed with an external viewer. This only occurs when the
image is saved in a format (such as GIF) that saves offset information.
To reset the offset data, add |true| as the last argument to |crop|. For

cropped = img.crop(x, y, width, height, true)

You can add |true| as the last argument with any of the three argument
list formats described above.


so adding ',true' in the file magick_file_column.rb at line 76 solved my

img = img.crop(::Magick::CenterGravity, [img.columns, w].min,
                         [img.rows, h].min,true)
This topic is locked and can not be replied to.