Michael Neumann wrote:


>   [img_data].pack("m") should do it.


Thanks. The below works, and uses code from RDoc's web/images/conv.rb :

require 'generated/svg/svg_writer'

name = ARGV.shift || raise("Missing name")
image_data = File.open(name, "rb") {|f| f.read}
base64_image = [image_data].pack("m*").split("\n")

doc = Svg_doc.new
root_el = doc.root
root_el.attributes["xmlns:xlink"]="http://www.w3.org/1999/xlink"
image = Image.new
image.width=100
image.height=100
image.xlink_href='data:image/jpeg;base64,'+base64_image.to_s
root_el.push image
open('generated/svg/base64.svg','w') {|f|f.write doc}

Tobi


-- 
http://www.pinkjuice.com/