On 8/3/05, Sebastian Kanthak <sebastian.kanthak / muehlheim.de> wrote:
> Joe Van Dyk wrote:
> 
> >On 8/3/05, Sebastian Kanthak <sebastian.kanthak / muehlheim.de> 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.  :(