RMagic via Rails: "Corrupt JPEG data"

I’m having some trouble with opening files with ImageMagick, by way of
RMagick, from within Rails. When trying to open an existing image, I get
this error:
"Corrupt JPEG data: premature end of data segment: "

My code is pretty straightforward:
pic = Magick::Image.read(filename)

I can view the image in question through the browser, so I don’t think
it’s corrupt. I can run a stand alone Ruby script from the command line,
and that does work, so I’m guessing the library is installed correctly.
However, if I try to trigger this external script from within Rails with
backticks (like ruby resize.rb), it craps out by the “require
‘RMagick’” line.

I needed the functionality yesterday, so I have Rails triggering a perl
script, but that’s a pretty shitty way of dealing with it. I’d love to
get it right. Any ideas?


This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs