File_column crashing WEBrick when using :magick options

I’m trying to use file_column in an app I’m writing. Simple file uploads
are working fine.

However, when I try and use the :magick options to make resized
versions, WEBrick dies.

This is the Media model:

class Media < ActiveRecord::Base
file_column :media_item,
:magick => {
:versions => {
:thumb => {:size => “50x50”},
:medium => {:size => “640x480”}
}
}
end

This is the output from WEBrick when it dies:

script/server: No such file or directory - file -bi
“./script/…/config/…/publi
c/media/media_item/tmp/1136422120.515000.5436/004.jpg”
Output file write error — out of disk space?

There is no issue with disk space and the odd thing is it looks to have
gotten half way through when it dies as this is the contents of the
dirs:

E:\rails\app_name\public\media
-–media_item
-–tmp
-–1136422120.515000.5436
| 004.jpg
|
-–thumb
004.jpg

The file itself seems to be fine. The resized thumb is at 0 bytes, so
this is where it looks to have died when trying to write that.

RMagick itself seems to work fine on its own. I wrote a small app to
test it and all went ok, so it would seem to be something file_column
related as opposed to simply RMagick itself not working.

Anyone any ideas as to how to solve this issue?

Running on Windows XP box if that makes any diff and using edge rails.

Thanks in advance.


R.Livsey

How come you always seem to find the answer 5 mins after hitting send!?

An earlier thread (file_column on windows?) contains all the info
required to fix the issue.

Sorry for the noise.


R.Livsey

Seems I spoke too soon when I said it was all ok.
The comments in the earlier thread fix the issue with the ‘-file -bi’
error, but WEBrick still dies with the following:

“Output file write error — out of disk space?”

Now I’m nowhere near short of disk space and it seems to upload the
original file ok, as far as I can see it just dies when writing the
resized version to disk.

Any ideas would be greatly appreciated.

Thanks in advance.


R.Livsey

Richard L. wrote:

Any ideas would be greatly appreciated.

Thanks in advance.

Well I’ve fixed it now, but I’m not sure how!

I changed this line in magick_file_column (about 85) from:

File.open(dest_path, “wb”, options[:permissions]) {|f| img.write f }

to

File.open(dest_path, “wb”, options[:permissions]) {|f|
f.write(img.to_blob) }

And it stops dying now.

Not a clue why… but I’m leaving it and backing away slowly!


R.Livsey

Hi Richard,

thanks for investigating this mysterious windows crash. As I’m only
running unix (and the problem doesn’t appear there), I’m hoping you
can help me a bit more…

On 1/5/06, Richard L. [email protected] wrote:

Well I’ve fixed it now, but I’m not sure how!

I changed this line in magick_file_column (about 85) from:

File.open(dest_path, “wb”, options[:permissions]) {|f| img.write f }

to

File.open(dest_path, “wb”, options[:permissions]) {|f|
f.write(img.to_blob) }

the reason I do not want to commit this is that it requires extra main
memory as to_blob returns the complete file as one large chunk. The
whole thing looks like a RMagick bug to me, but let’s investigate.

Can you try to following on a (windows) ruby console?

  • Load an image with RMagick
  • Write it in the same way, file_column does, e.g.
    File.open(“/some/file.jpg”, “wb”, 0644) { |f| img.write f }
    Does this crash?
  • What if you leave out the 0644 parameter?

Sebastian

Richard L. wrote:

I changed this line in magick_file_column (about 85) from:

File.open(dest_path, “wb”, options[:permissions]) {|f| img.write f }

This helped me too. I am using webrick on windows xp and :magick resize
options game me this error:

script/server: No such file or directory - file -bi
“./script/…/config/…/public/entry/kuva/tmp/113
6553849.406000.696/Water_lilies.jpg”
./script/…/config/…/vendor/plugins/file_column/lib/magick_file_column.rb:85:
[BUG] Segmentation fault
ruby 1.8.2 (2004-12-25) [i386-mswin32]

This application has requested the Runtime to terminate it in an unusual
way.
Please contact the application’s support team for more information.