attachment_fu issues

Relying largely on Mike Clark's guidance:

I've had limited success with attachment_fu. I'm able to upload
andsubsequently redisplay images through the browser. But, a few
things aren't working right:

1) Image size is sometimes 0 and sometimes actual size (more often 0).
Can't find a pattern, testing with jpg, png, gif with Firefox and IE.
I've had to set the :size option to allow 0, otherwise validation
prevents images from uploading (again, most of the time but not

2) Images don't resize even though option is set in model.

3) Thumbnails aren't generated even though option is set in model.
Only the original image at it's original size with it's original name
is stored.

Below is my model. I'm pretty new to rails so it's entirely possible
I've done something idiotic. This is happening on Windows XP w/
InstantRails (haven't tried it in my hosted environment yet).

class Mugshot < ActiveRecord::Base

  has_attachment :content_type => :image,
                 :storage => :file_system,
     :size => 0.kilobyte..2.megabytes,
                 :resize_to => [50, 50],
     :thumbnails => { :thumb => [50, 50], :geometry => 'x50' },
                 :processor => 'Rmagick'


There are a number of possibilities.

  1. and 3) are related to 1), so it has to do with the images you’re uploading. Attachment_fu will determine if it’s an image by checking the MIME type. This can lead to images not being recognized as images if the browser doesn’t upload them with the correct MIME type or if your images are corrupt.

To give you an example: when using a solution like SWFUpload to upload images, all files will be streamed as application/octet-stream, attachment_fu won’t recognize them as being images. In this case, you need to “preprocess” the upload by mapping the extension of the file to a mime type before passing it on to attachment_fu for thumbnailing.

Best regards

Peter De Berdt

Thanks for your reply Peter. I was able to get 1) solved using the
sleep fix. Eric Northam's change to attachment_fu also fixed the
problem for me (both fixes described in this post):

However, I still haven't been able to get thumbnails or resizing
working on my Windows development box.

I deployed to my OCS Solutions shared host and am not having any of
the problems. I'm starting to wonder if rails development and windows
don't mix. Maybe I should bite the bullet and load linux or get a Mac.

Oops, the post was from me, inadvertantly using an alternate gmail
account of mine.

Thanks again for your reply Peter.