Processing Images in Rails - It’s driving me nuts.
So I’m trying to convert a bunch of photos grabbed from a data feed, but It’s just not working in Rails for some reason.
I first tried RMagick, then ImageScience, then using back-ticks to run the command line ImageMagick convert. All of them end up generating corrupt images.
I run the command line from the command prompt and it works fine. I run it from the console, and it still runs fine. It just won’t run from my model.
The command line is:
sudo -u www /usr/local/bin/convert -geometry “1024×768>” -strip -quality 90 o-1.jpg l-1.jpg
I have removed the path for my blog. o-1.jpg is the original photo, l-1.jpg is the large size preview.
The errors I get are:
convert: Premature end of JPEG file o-2.jpg’.
convert: Corrupt JPEG data: premature end of data segment `o-2.jpg’.
It makes a jpg with the bottom half chopped off and all gray.
I’m thinking that Ruby or Rails is running out of memory while processing the image… maybe.. I don’t know.




have you checked typos yet, I bet its a typo. “I always screw up those mundane details like that.”
Nope, not a typo.
Works at the command line:
> /usr/local/bin/convert -geometry “1024×768>” -strip -quality 90 o-1.jpg l-1.jpg
Doesn’t work in my Ruby model
`/usr/local/bin/convert -geometry “1024×768>” -strip -quality 90 o-1.jpg l-1.jpg`
But I found that it will work in other models. So I’m processing the file in one model and the photos in another model. The only problem is that it’s two different processes.
odd