I need a way to upload an image and display it without using any of the plugins that use rmagic. I have used the plugins (file_column, fleximage) which both use rmagic and gave me problems (never got fleximage to work) Thanks in advance - K --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
I got FlexImage to work! Yahoo. I am still looking for a way to upload images without rmagic though. Any suggestions? On Feb 9, 3:05 pm, "Kim" <Kim.Gri...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I need a way to upload an image and display it without using any of > the plugins that use rmagic. I have used the plugins (file_column, > fleximage) which both use rmagic and gave me problems (never got > fleximage to work) > > Thanks in advance - K--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Kim wrote:> I need a way to upload an image and display it without using any of > the plugins that use rmagic. I have used the plugins (file_column, > fleximage) which both use rmagic and gave me problems (never got > fleximage to work) > > Thanks in advance - KTo simply write an uploaded file to the disk on the server is pretty easy. # view <% form_tag({:action => ''upload''}, :multipart => true) do %> <%= file_field_tag ''file'' %> <%= submit_tag ''Upload!'' %> <% end %> # controller def upload file = params[:file].original_filename path = "#{RAILS_ROOT}/public/uploads/#{file}" File.open path, ''wb'' do |f| f.write(params[:file].read) end flash[:notice] = "#{file} uploaded successfuly to #{path}" redirect_to :action => ''index'' end If you want to manipulate the images in any way you must use RMagick. As far as I know it''s the only way to resize images in ruby. Although, if you don;t want to use RMagick, you can use ImageMagick via command line. I haven''t done this exactly, but ImageMagick gives you a command line program called "convert". def resize_image(file, size) `convert #{file} --resize #{size}" #maybe end Now I don''t know the exact format of the arguments to convert but something like that may work. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
You can resizes images using `/usr/local/bin/convert #{whatever}`. That''s how I do it. On 2/9/07, Alex Wayne <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > Kim wrote: > > I need a way to upload an image and display it without using any of > > the plugins that use rmagic. I have used the plugins (file_column, > > fleximage) which both use rmagic and gave me problems (never got > > fleximage to work) > > > > Thanks in advance - K > > To simply write an uploaded file to the disk on the server is pretty > easy. > > # view > <% form_tag({:action => ''upload''}, :multipart => true) do %> > <%= file_field_tag ''file'' %> > <%= submit_tag ''Upload!'' %> > <% end %> > > # controller > def upload > file = params[:file].original_filename > path = "#{RAILS_ROOT}/public/uploads/#{file}" > File.open path, ''wb'' do |f| > f.write(params[:file].read) > end > > flash[:notice] = "#{file} uploaded successfuly to #{path}" > redirect_to :action => ''index'' > end > > If you want to manipulate the images in any way you must use RMagick. > As far as I know it''s the only way to resize images in ruby. > > Although, if you don;t want to use RMagick, you can use ImageMagick via > command line. I haven''t done this exactly, but ImageMagick gives you a > command line program called "convert". > > def resize_image(file, size) > `convert #{file} --resize #{size}" #maybe > end > > Now I don''t know the exact format of the arguments to convert but > something like that may work. > > -- > Posted via http://www.ruby-forum.com/. > > > >-- EPA Rating: 3000 Lines of Code / Gallon (of coffee) --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
How about if I want to load an image to a DB? On 2/9/07, Alex Wayne <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > > Kim wrote: > > I need a way to upload an image and display it without using any of > > the plugins that use rmagic. I have used the plugins (file_column, > > fleximage) which both use rmagic and gave me problems (never got > > fleximage to work) > > > > Thanks in advance - K > > To simply write an uploaded file to the disk on the server is pretty > easy. > > # view > <% form_tag({:action => ''upload''}, :multipart => true) do %> > <%= file_field_tag ''file'' %> > <%= submit_tag ''Upload!'' %> > <% end %> > > # controller > def upload > file = params[:file].original_filename > path = "#{RAILS_ROOT}/public/uploads/#{file}" > File.open path, ''wb'' do |f| > f.write(params[:file].read) > end > > flash[:notice] = "#{file} uploaded successfuly to #{path}" > redirect_to :action => ''index'' > end > > If you want to manipulate the images in any way you must use RMagick. > As far as I know it''s the only way to resize images in ruby. > > Although, if you don;t want to use RMagick, you can use ImageMagick via > command line. I haven''t done this exactly, but ImageMagick gives you a > command line program called "convert". > > def resize_image(file, size) > `convert #{file} --resize #{size}" #maybe > end > > Now I don''t know the exact format of the arguments to convert but > something like that may work. > > -- > Posted via http://www.ruby-forum.com/. > > > >-- Kim Griggs kim.griggs-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org "We are all stakeholders in the Karma economy." --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Are you using ImageMagic? Can you explain: `/usr/local/bin/convert #{whatever}`. Thanks, -K On 2/9/07, Carl Lerche <carl.lerche-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > You can resizes images using `/usr/local/bin/convert #{whatever}`. > > That''s how I do it. > > On 2/9/07, Alex Wayne <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote: > > > > Kim wrote: > > > I need a way to upload an image and display it without using any of > > > the plugins that use rmagic. I have used the plugins (file_column, > > > fleximage) which both use rmagic and gave me problems (never got > > > fleximage to work) > > > > > > Thanks in advance - K > > > > To simply write an uploaded file to the disk on the server is pretty > > easy. > > > > # view > > <% form_tag({:action => ''upload''}, :multipart => true) do %> > > <%= file_field_tag ''file'' %> > > <%= submit_tag ''Upload!'' %> > > <% end %> > > > > # controller > > def upload > > file = params[:file].original_filename > > path = "#{RAILS_ROOT}/public/uploads/#{file}" > > File.open path, ''wb'' do |f| > > f.write(params[:file].read) > > end > > > > flash[:notice] = "#{file} uploaded successfuly to #{path}" > > redirect_to :action => ''index'' > > end > > > > If you want to manipulate the images in any way you must use RMagick. > > As far as I know it''s the only way to resize images in ruby. > > > > Although, if you don;t want to use RMagick, you can use ImageMagick via > > command line. I haven''t done this exactly, but ImageMagick gives you a > > command line program called "convert". > > > > def resize_image(file, size) > > `convert #{file} --resize #{size}" #maybe > > end > > > > Now I don''t know the exact format of the arguments to convert but > > something like that may work. > > > > -- > > Posted via http://www.ruby-forum.com/. > > > > > > > > > > -- > EPA Rating: 3000 Lines of Code / Gallon (of coffee) > > > >-- Kim Griggs kim.griggs-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org "We are all stakeholders in the Karma economy." --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Yeah, that''s using imagemagick, however it''s not loading the image into the main mongrel process and making memory usage shoot through the roof. It''s using the command line tool (convert). Basically, write the image to be processed to a file somewhere and run convert on it. As for loading an image to a DB, I really would advise against doing that. Having all that binary data in the database would slow it down a lot. There are a lot of alternatives and unless your site grows massive, you won''t need anything more than just writing the files in a directory somewhere. On 2/10/07, Kim Griggs <kim.griggs-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Are you using ImageMagic? Can you explain: `/usr/local/bin/convert > #{whatever}`. > > Thanks, -K > > > On 2/9/07, Carl Lerche <carl.lerche-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > You can resizes images using `/usr/local/bin/convert #{whatever}`. > > > > That''s how I do it. > > > > On 2/9/07, Alex Wayne <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org > > wrote: > > > > > > Kim wrote: > > > > I need a way to upload an image and display it without using any of > > > > the plugins that use rmagic. I have used the plugins (file_column, > > > > fleximage) which both use rmagic and gave me problems (never got > > > > fleximage to work) > > > > > > > > Thanks in advance - K > > > > > > To simply write an uploaded file to the disk on the server is pretty > > > easy. > > > > > > # view > > > <% form_tag({:action => ''upload''}, :multipart => true) do %> > > > <%= file_field_tag ''file'' %> > > > <%= submit_tag ''Upload!'' %> > > > <% end %> > > > > > > # controller > > > def upload > > > file = params[:file].original_filename > > > path = "#{RAILS_ROOT}/public/uploads/#{file}" > > > File.open path, ''wb'' do |f| > > > f.write(params[:file].read) > > > end > > > > > > flash[:notice] = "#{file} uploaded successfuly to #{path}" > > > redirect_to :action => ''index'' > > > end > > > > > > If you want to manipulate the images in any way you must use RMagick. > > > As far as I know it''s the only way to resize images in ruby. > > > > > > Although, if you don;t want to use RMagick, you can use ImageMagick via > > > command line. I haven''t done this exactly, but ImageMagick gives you a > > > command line program called "convert". > > > > > > def resize_image(file, size) > > > `convert #{file} --resize #{size}" #maybe > > > end > > > > > > Now I don''t know the exact format of the arguments to convert but > > > something like that may work. > > > > > > -- > > > Posted via http://www.ruby-forum.com/. > > > > > > > > > > > > > > > > -- > > EPA Rating: 3000 Lines of Code / Gallon (of coffee) > > > > > > > > -- > Kim Griggs > kim.griggs-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org > > "We are all stakeholders in the Karma economy." > > >-- EPA Rating: 3000 Lines of Code / Gallon (of coffee) --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Carl Lerche wrote:> As for loading an image to a DB, I really would advise against doing > that. Having all that binary data in the database would slow it down a > lot. There are a lot of alternatives and unless your site grows > massive, you won''t need anything more than just writing the files in a > directory somewhere.With proper caching and optimizations, it doesn;t affect performance much, and it makes backing it all up much easier. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---