attachment_fu Resizing Mysteriously Stopped Working

Hello,

Recently attachment_fu stopped resizing images for me. I'm puzzled
because before today it was resizing them and I don't know what's
changed. Here's my code:

class Product < ActiveRecord::Base
    has_attachment :content_type => :image,
                   :storage => :file_system,
                   :max_size => 18.megabytes,
                   :resize_to => '300x',
                   :thumbnails => { :thumb => '61x110!' }
    validates_as_attachment
end

I expected a 420x595 image to be resized to 300xWhatever and a 61x110
thumbnail to be created. The image and thumbnail product records
were both created in the database but the images were left at the
original size.

Strangely the width and height fields in the database are no longer
being set. For new uploads they are null whereas previously they had
been set to the measurements of the resized images.

I think I've traced the problem to this method (but I could equally
well be barking up the wrong tree):

attachment_fu/processors/rmagick_processor.rb:

            module ClassMethods
            # Yields a block containing an RMagick Image for the given
binary data.
            def with_image(file, &block)
              begin
                binary_data = file.is_a?(Magick::Image) ? file :
Magick::Image.read(file).first unless !Object.const_defined?(:Magick)
                puts "binary_data.nil? : #{binary_data.nil?}"
                puts "file.nil?: #{file.nil?}"
                puts "const_defined? : #{Object.const_defined?(:Magick)}"
              rescue
                # Log the failure to load the image. This should
match ::Magick::ImageMagickError
                # but that would cause acts_as_attachment to require
rmagick.
                logger.debug("Exception working with image: #{$!}")
                binary_data = nil
              end
              block.call binary_data if block && binary_data
            ensure
              !binary_data.nil?
            end
          end

My puts statements give this output:

   binary_data.nil? : true
   file.nil?: false
   const_defined? : false

So it looks like the undefined constant prevents binary_data from
being assigned. But I don't know what to do about this.

I'd appreciate any help.

Thanks and regards,
Andy Stewart

Recently attachment_fu stopped resizing images for me. I'm puzzled
because before today it was resizing them and I don't know what's
changed. Here's my code:

Just for the record, I found the cause of the problem.

Originally I installed attachment_fu and created all my Product instances. Every image was resized perfectly.

Then I tried to interact with these Products in the console but RMagick kept blowing up with this error:

   >> Product.find 1
   /usr/local/lib/ruby/gems/1.8/gems/rmagick-1.14.1/lib/RMagick.bundle: [BUG] Bus Error
   ruby 1.8.4 (2005-12-24) [powerpc-darwin8.4.0]

   Abort trap

To get round this, I added a one-line file called RMagick.rb to my lib/ directory. This was recommended by Rick Olson somewhere on the Mephisto site.

   lib/RMagick.rb:

     raise LoadError

Hooray! Now the console works:

>> Product.find 1
=> #<Product:0x2663628 @attributes={"content_type"=>"image/jpeg", "name"=>...blah...}

Unfortunately this prevents attachment_fu from resizing images uploaded via a form. So to create new products via the form I have to move the lib/RMagick.rb hack away first.

Hope this helps somebody else.

Regards,
Andy Stewart