From: Joe Van Dyk Date: 2005-08-04T04:00:32+09:00 Subject: Re: [Rails] RMagick problem On 8/3/05, Sebastian Kanthak wrote: > Joe Van Dyk wrote: > > >On 8/3/05, Sebastian Kanthak wrote: > > > > > >> if file.is_a?(StringIO) > >> img = Magick::Image::from_blob(file.string).first > >> else > >> img = Magick::Image::read(file.local_path).first > >> end > >> > >> > > > >Also, File objects support #read, so why do you have that distinction in there? > > > > > mainly, because I'm not so sure if it is a good idea to read a (possibly > pretty big) image into main memory. I'm not sure what RMagick does, but > it could be optimized to only read the header information and process > the image in a "streaming" mode. > > For a StringIO object it doesn't really matter, as these are only > created if the upload is reasonably small, so I can use from_blob > safely, here. Ah, good idea. I still have no idea why it's giving me "Zero-length blob not permitted" for this line: @magick_image = Magick::Image.from_blob(@file.read).first What's weird is that if I leave out the .first method call, I don't get that error. But if I print out the size of @file.read.size, and then call the Image.from_blob line, then I get the Zero-length blob error. It's driving me crazy. :(