hi all, i wanna generate thumbnail from image i found RMagick and found this code but i can''t run it, so please anyone help me in this issue. my code def index img = Magick::Image.read(''/images/img2.jpg'').first width, height = 100, 100 thumb = img.resize(width, height) thumb.write(''/images/mythumbnail.jpg'') end but it throws this exception unable to open image `/images/img2.jpg'': No such file or directory thanks -- Mohamed Saeed software engineer --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
hi all, i wanna generate thumbnail from image i found RMagick and found this code but i can''t run it, so please anyone help me in this issue. my code def index img = Magick::Image.read (''/images/img2.jpg'').first width, height = 100, 100 thumb = img.resize(width, height) thumb.write(''/images/mythumbnail.jpg'') end but it throws this exception unable to open image `/images/img2.jpg'': No such file or directory thanks -- 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 -~----------~----~----~----~------~----~------~--~---
Image.read() is relative not to your web root, but to your host operating system''s root. Try something like: def index fname = RAILS_ROOT + ''/images/img2.jpg'' img = Magick::Image.read(fname) img = img.first ... end On 10/17/07, Mohamed Saeed <medofci-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > def index > img = Magick::Image.read (''/images/img2.jpg'').first > width, height = 100, 100 > thumb = img.resize(width, height) > thumb.write(''/images/mythumbnail.jpg'') > 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 Oct 17, 2007, at 11:26 AM, Mohamed Saeed wrote:> hi all, > > i wanna generate thumbnail from image > > i found RMagick and found this code but i can''t run it, so please > anyone > help me in this issue. > > my code > > def index > img = Magick::Image.read (''/images/img2.jpg'').first > width, height = 100, 100 > thumb = img.resize(width, height) > thumb.write(''/images/mythumbnail.jpg'') > end > > > but it throws this exception > > unable to open image `/images/img2.jpg'': No such file or directory > > > thanks > -- > Posted via http://www.ruby-forum.com/.You probably need to File.expand_path(''public'' + ''/images/img2.jpg'', RAILS_ROOT) to get a real file name on your system. I presume that the ''/images/ img2.jpg'' will be replaced with some variable that is meant to be an absolute "web" path, but you need a "file system" path. -Rob Rob Biedenharn http://agileconsultingllc.com Rob-xa9cJyRlE0mWcWVYNo9pwxS2lgjeYSpx@public.gmane.org --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---