I''ve based my code on the Agile example for uploading files, pages 362-365. I''ve successfully loaded the Picture object to the database, but I come unstuck when trying to replicate this for a thumbnail version of the original image: thumbnail = Thumbnail.new thumbnail.name = ''thumbnail_'' + @picture.name.to_s thumbnail.content_type = @picture.content_type thumbnail.data = @picture.data thumbnail.make_thumbnail thumbnail.save I get the following error on the make_thumbnail method: ArgumentError (can''t decode image): /app/models/thumbnail.rb:11:in `read_inline'' /app/models/thumbnail.rb:11:in `make_thumbnail'' Here''s the Thumbnail model: require ''RMagick'' include Magick def make_thumbnail img = Image.read_inline(self.data) ... end What do I have to do to thumbnail.data to get RMagick to read it? Lindsay -- Posted via http://www.ruby-forum.com/.
You should go the easy way by : - using mini_magick instead rmagick (less memory foot print) - storing your pictures on disk instead on db In that case, handling file upload is quite simple. Look here : http://www.ruby-forum.com/topic/59545#new -- Posted via http://www.ruby-forum.com/.
Christophe Gimenez wrote:> You should go the easy way by : > - using mini_magick instead rmagick (less memory foot print) > - storing your pictures on disk instead on db > > In that case, handling file upload is quite simple. > > Look here : http://www.ruby-forum.com/topic/59545#newI would prefer to store the images in the database - but I''ll definitely look into mini_magick. Thanks. -- Posted via http://www.ruby-forum.com/.
Lindsay Boyd wrote:> What do I have to do to thumbnail.data to get RMagick to read it?According to my reading of the RMagick docs, read_inline takes a Base64-encoded string. Is your @picture.data encoded, or raw? --Al Evans -- Posted via http://www.ruby-forum.com/.