From: clc Date: 2006-04-08T02:59:05+09:00 Subject: Load and Embed an Image Using Ruby? Hello, I'm trying to load an 8x8 GIF file and embed it directly into some HTML but the image pixels are out of order and the dimensions are not correct. I assume the problem is with the byte order during the read. Can any of you suggest a better way to do this? ######################################### require 'base64' gif_path = 'C:\work\gifTest\gifTest.gif' html_path = 'C:\work\gifTest\gifTest.html' f = File.open( gif_path, "rb" ) data = f.read f.close encoded = Base64.encode64( data ) f = File.open( html_path, 'w' ) # links work perfectly f.puts( "" ) f.puts( "" ) # something appears, but out-of-order and wrong dimension f.puts( "" ) # these produce the "missing image" placeholder f.puts( "" ) f.puts( "" ) f.puts( "" ) f.close #########################################