Hi. I''m trying to display a .tif image file on my web page. The image is on another physical drive on the server and because .tif images don''t display very well i decided to use Rmagick... I would like to load the image from the server; convert it to a .png; display it on the web page. If possible i don''t want to create a physical .png file on the server. The closest i''ve got is: read the file in, convert it to .png and write it to the server (which as i mentioned i dont want to do), and use <%= image_tag("file:///c:/temp/photo3.png") %> in the view. It works, but just seems very clunky. Any ideas welcome... Cheers. --~--~---------~--~----~------------~-------~--~----~ 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 20 Feb 2008, at 16:33, MagicLava wrote:> > Hi. I''m trying to display a .tif image file on my web page. > > The image is on another physical drive on the server and because .tif > images don''t display very well i decided to use Rmagick... > > I would like to load the image from the server; convert it to a .png; > display it on the web page. > > If possible i don''t want to create a physical .png file on the server. > > The closest i''ve got is: > read the file in, > convert it to .png and write it to the server (which as i mentioned i > dont want to do), > and use <%= image_tag("file:///c:/temp/photo3.png") %> in the view.Assuming that rmagick can give you the binary data for the png file, you should be able to just use send_data Fred --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Your clunky feeling is correct, your solution is a bit of fragile. At first, you should not convert image each time when somebody accessing it. In fact you _should_ write it down and then use saved copy in your views. RMagick consume memory, lots of it, if abused, so don''t abuse it, please. Then, this <%= image_tag("file:///c:/temp/photo3.png") %> seems kind of wrong. Not sure if it ever worked, but, even if it was, I''m pretty sure there will be the point it will stop doing so. You have to use path, related to web root, not absolute path on your local drive. And last, but not least - do not use send_file. Use http://john.guen.in/rdoc/x_send_file/ instead. On 20 фев, 18:33, MagicLava <magicl...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi. I''m trying to display a .tif image file on my web page. > > The image is on another physical drive on the server and because .tif > images don''t display very well i decided to use Rmagick... > > I would like to load the image from the server; convert it to a .png; > display it on the web page. > > If possible i don''t want to create a physical .png file on the server. > > The closest i''ve got is: > read the file in, > convert it to .png and write it to the server (which as i mentioned i > dont want to do), > and use <%= image_tag("file:///c:/temp/photo3.png") %> in the view. > > It works, but just seems very clunky. Any ideas welcome... > > Cheers.--~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---