On 8/3/05, Tim Hunter <cyclists / nc.rr.com> wrote:
> Joe Van Dyk wrote:
> 
> > The following Rails/Ruby code gives me this error: "Zero-length blob
> > not permitted".
> >
> > @magick_image = Magick::Image.from_blob(@file.read).first
> >
> > Where @file is a StringIO object or a File object, depending on the
> > size of the uploaded file.
> >
> > @file.read.size returns the expected file size (in bytes).
> >
> > Any ideas?
> 
> Well, it works for me. Here's my attempt to reproduce the problem.
> 
> require 'RMagick'
> require 'stringio'
> 
> file = File.open('Flower_Hat.jpg')
> img = Magick::Image.from_blob(file.read).first
> p img
> 
> blob = IO.read('Flower_Hat.jpg')
> sio = StringIO.new(blob)
> img = Magick::Image.from_blob(sio.read).first
> p img
> 
> 
> The output is:
> tim: ~> ruby  test.rb
>  JPEG 200x250 DirectClass 8-bit 9kb
>  JPEG 200x250 DirectClass 8-bit 9kb

Yeah, I tried to do that test last night and it worked fine.

So I have no idea why the code is failing inside my Image model.