I''m working on generating FedEx labels for quick & easy shipping. FedEx returns the label as a base64-encoded string. Assuming that ''match'' is the base64 string containing the label data, here is what I have to display the image: send_data image, :filename => ''fedex_shipping_label.png'', :type => ''image/png'', :disposition => ''inline'' That works fine, but I''d like to be able to set some html/css parameters on it so that it prints at 200dpi, 4x6 inches (the RMagick ''resample'' method wasn''t working for me). I don''t really want to save the label as a file, either. Is there a way to send a variable to the template (e.g., @image) so that it gets rendered as an image? Thank you! -Kyle --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Frederick Cheung
2008-Feb-19 10:28 UTC
Re: Displaying a base64-encoded image within an rhtml template
On 18 Feb 2008, at 20:55, Kyle wrote:> > I''m working on generating FedEx labels for quick & easy shipping. > FedEx returns the label as a base64-encoded string. Assuming that > ''match'' is the base64 string containing the label data, here is what I > have to display the image: > > send_data image, :filename => ''fedex_shipping_label.png'', :type => > ''image/png'', :disposition => ''inline'' > > That works fine, but I''d like to be able to set some html/css > parameters on it so that it prints at 200dpi, 4x6 inches (the RMagick > ''resample'' method wasn''t working for me). I don''t really want to save > the label as a file, either. Is there a way to send a variable to the > template (e.g., @image) so that it gets rendered as an image?Well you can do <img src="data:image/jpeg;base64,base_64_data_here" > So presumably, just <img src="data:image/jpeg;base64,<%= @base_64_encoded_data %>"> would do the trick Fred>> > Thank you! > > -Kyle > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Thank you! I had never seen the data type in an image element. After a couple of stupidity checks, it appears to be working very well. Thank you again. -Kyle On Feb 19, 4:28 am, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On 18 Feb 2008, at 20:55, Kyle wrote: > > > > > I''m working on generating FedEx labels for quick & easy shipping. > > FedEx returns the label as a base64-encoded string. Assuming that > > ''match'' is the base64 string containing the label data, here is what I > > have to display the image: > > > send_data image, :filename => ''fedex_shipping_label.png'', :type => > > ''image/png'', :disposition => ''inline'' > > > That works fine, but I''d like to be able to set some html/css > > parameters on it so that it prints at 200dpi, 4x6 inches (the RMagick > > ''resample'' method wasn''t working for me). I don''t really want to save > > the label as a file, either. Is there a way to send a variable to the > > template (e.g., @image) so that it gets rendered as an image? > > Well you can do > <img src="data:image/jpeg;base64,base_64_data_here" > > So presumably, just <img src="data:image/jpeg;base64,<%> @base_64_encoded_data %>"> would do the trick > > Fred > > > > > Thank you! > > > -Kyle--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Matt King
2008-Feb-19 21:56 UTC
Re: Displaying a base64-encoded image within an rhtml template
Be aware this does not work in IE 6 or 7... See this: http://dean.edwards.name/weblog/2005/06/base64-ie/ and this: http://dean.edwards.name/weblog/2005/06/base64-sexy/ On Feb 19, 1:14 pm, Kyle <kyle.r...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Thank you! I had never seen the data type in an image element. After > a couple of stupidity checks, it appears to be working very well. > > Thank you again. > > -Kyle > > On Feb 19, 4:28 am, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > wrote: > > > On 18 Feb 2008, at 20:55, Kyle wrote: > > > > I''m working on generating FedEx labels for quick & easy shipping. > > > FedEx returns the label as a base64-encoded string. Assuming that > > > ''match'' is the base64 string containing the label data, here is what I > > > have to display the image: > > > > send_data image, :filename => ''fedex_shipping_label.png'', :type => > > > ''image/png'', :disposition => ''inline'' > > > > That works fine, but I''d like to be able to set some html/css > > > parameters on it so that it prints at 200dpi, 4x6 inches (the RMagick > > > ''resample'' method wasn''t working for me). I don''t really want to save > > > the label as a file, either. Is there a way to send a variable to the > > > template (e.g., @image) so that it gets rendered as an image? > > > Well you can do > > <img src="data:image/jpeg;base64,base_64_data_here" > > > So presumably, just <img src="data:image/jpeg;base64,<%> > @base_64_encoded_data %>"> would do the trick > > > Fred > > > > Thank you! > > > > -Kyle--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---