File_column Cropping -> image offset information


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)