Hi,
how can I base64 encode an image so I can inline it in SVG like
<image width="400" height="300"
xlink:href="data:image/jpeg;base64,/9j/4AAQSkZJRgABAQEAYABgAAD/2wBDAAs...
?
This is from RDoc's web/images/conv.rb; would it to what I want? Will it
work for PNGs and JPEGs as well?:
----------8<----------
# Convert a binary .gif file into a String so we can write it out
# from inside a Ruby program
name = ARGV.shift || raise("Missing name")
content = File.open(name, "rb") {|f| f.read}
content = [content].pack("m*").split("\n")
name.gsub!(/\./, '_').upcase!
puts "#{name} = ("
puts(content.collect {|line| "\t" + line.dump} .join(" +\n") +
").unpack('m*')[0]")
----------8<----------
Tobi
--
http://www.pinkjuice.com/