Relying largely on Mike Clark''s guidance: http://clarkware.com/cgi/blosxom/2007/02/24 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 always). 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'' validates_as_attachment end --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On 10 Aug 2007, at 00:04, P.F.Pluto wrote:> 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 > always). > > 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.There are a number of possibilities. 2) 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 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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): http://groups.google.com/group/rubyonrails-talk/browse_thread/thread/2150d2ebe267545a/dc13f21b1a4a87fc?lnk=gst&q=attachment_fu+sleep&rnum=1#dc13f21b1a4a87fc 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. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Oops, the post was from me, inadvertantly using an alternate gmail account of mine. Thanks again for your reply Peter. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---