Attachment_fu thumbnail not created

I followed the instructions on Mike C.'s weblog and everything
works perfectly except the thumbnail column in my DB is alwas NULL.
I’m using S3 as my storage system. Anyone else having this issue with
thumbnails?

has_attachment :content_type => :image,
:storage => :s3,
:max_size => 500.kilobytes,
:resize_to => ‘150x150>’,
:thumbnails => { :thumb => ‘40x40>’ },
:processor => ‘Rmagick’

validates_as_attachment

I first started out with trying to use ImageScience. I followed the
directions correctly on their website and within my app when I try to
upload an image it shuts down mongrel/server with this error:

/Users/Bob/work/app/trunk/vendor/plugins/attachment_fu/lib/
technoweenie/attachment_fu/processors/image_science_processor.rb:14:
[BUG] Bus Error
ruby 1.8.4 (2005-12-24) [i686-darwin8.8.1]

Abort trap

Fair enough, I’ll just try minimagick and see if that works. When I
run: gem install mini_magick I get this error:
ERROR: While executing gem … (Errno::EACCES)
Permission denied - /usr/local/lib/ruby/gems/1.8/cache/
mini_magick-1.2.0.gem

So it looks like Rmagick is the only one that is working but
attachment_fu is not saving thumbnails. Ideally I would like to use
ImageScience but I cannot spend all day working on this image upload
problem. Anyone know what I’m doing wrong?

Anyone know why the thumbnails are not being created while everything
else is working fine?

Hello,

On 9 Apr 2007, at 16:53, jko170 wrote:

Anyone know why the thumbnails are not being created while everything
else is working fine?

I doubt this is the answer, but I thought I’d link it just in case it
helps:

http://groups.google.com/group/rubyonrails-talk/browse_thread/thread/
3c86abb8daa12cc6/079b85c99b22be2f

Regards,
Andy S.

try installing mini_magick again but put a sudo in front:

sudo gem install mini_magick

are you on a mac ?

I assume you are trying to install it locally and that you have the
appropriate permissions.

Thanks for the replies. I installed mini magick correctly and
thumbnails are still not generated. I doesn’t matter what image
processor I use so I’m assuming that’s not the problem.

jko170 wrote:

Anyone know why the thumbnails are not being created while everything
else is working fine?

I ran into this a few weeks ago using a Flash upload widget, and it
turned out that the uploader wasn’t sending the proper MIME type –
everything was application/octet-stream, so attachment_fu wasn’t
recognizing the file as an image.

I just rewrote the uploaded_data method of attachment_fu to check
against a table mapping file extensions to MIME types when it found a
file type of application/octet-stream. The hack seems to work for my
purposes.

–Al Evans

Here is all my code incase someone can spot something:

create_table “photos” do |t|
t.column :user_id, :integer, :null => false
t.column :content_type, :string
t.column :filename, :string
t.column :thumbnail, :string
t.column :size, :integer
t.column :width, :integer
t.column :height, :integer
end

class Photo < ActiveRecord::Base
belongs_to :user

has_attachment :content_type => :image,
:storage => :s3,
:max_size => 500.kilobytes,
:resize_to => ‘150x150>’,
:thumbnails => { :thumb => [50, 50], :geometry =>
‘x50’ },
:processor => ‘MiniMagick’

validates_as_attachment
end

def create
@user = User.new(params[:user])
@photo = Photo.new(params[:photo])
@user.photo = @photo

if @user.save && @photo.save
  flash[:notice] = 'User was successfully created.'
  redirect_to user_url(@user)
else
  render :action => "new"
end

end

Hi,

You need to have a ‘parent_id’ column in your photos table. This one
had me scratching my head for a few hours too until I stumbled across
this requirement of the plugin.

See the tutorial: http://clarkware.com/cgi/blosxom/2007/02/24

He doesn’t mention that parent_id is required however.

Guy

That fixed it. Thanks Guy!

One more quick question: Do you know how to make the thumbnail and
images resize to an exact size? I guess that would require cropping?

hi just wondering if you solved this proble. i am having the same issue

mr_robot wrote:

hi just wondering if you solved this proble. i am having the same issue

'kay; same problem (thumbnails not being generated);
happened just by moving from a model to another (from
app/models/asset.rb to app/models/item.rb).
columns are just fine; but still getting the same problem.

I just don’t know what’s the problem, is there any model caching or
something like that in there ? weird…

this is a great thread and helped me get my hands around debugging this
thing.

some more tips –

1 here’s another thing to look for with respect to parent_id: if
you’re using uuid (string) instead of id (integer) make sure your
parent_id is also a string and not an integer, otherwise you won’t get
thumbnails

2 if you’re a windows user, ruby is faster than windows so for your
create and update actions (assuming REST) make sure you stick in a
sleep(2) to allow windows to catch up to your rails app when you post:

def create
sleep(2)

def update
sleep(2)

aa bb wrote:

mr_robot wrote:

hi just wondering if you solved this proble. i am having the same issue

'kay; same problem (thumbnails not being generated);
happened just by moving from a model to another (from
app/models/asset.rb to app/models/item.rb).
columns are just fine; but still getting the same problem.

I just don’t know what’s the problem, is there any model caching or
something like that in there ? weird…

'aight… the fuc*$$€¨!!- column parent_id has to be NULL… and not at
default 0