From: Gavin Sinclair Date: 2003-12-28T07:34:04+09:00 Subject: Re: forum & binary cgi On Sunday, December 28, 2003, 9:11:49 AM, Jaap wrote: > I too am new to Ruby, but i love it! Two questions though: > 1. I read and printed a png image from disk and printed it to the > browser but it doesnt't work: > print "Content-type: image/png\n\n" > file = File.new(imagePath, 'r') > content = '' > file.each_line {|line| content += line } > file.close > print content > Could this have anything to do with binary mode? How could i get this to > work? Try this: print "Content-type: image/png\n\n" File.open(image_path, 'rb') do |file| content = file.read end # file is auto-closed here print content Explicitly closing a file is *so* last-century ;) You can use 'content = File.read(image_path)' but I'm not sure if that's read as text or binary. > 2. What is the forum/community site where most Ruby experts hang out? > Like Perl has perlmonks.org No real forum to speak of. That's what ruby-talk is for. Check out the Ruby Documentation Bundle (ruby-doc.org/downloads) for some meaty documentation and a newbie's guide to the Ruby community. Summary: ruby-talk, IRC, rubygarden.org, Wiki, RAA, RubyForge. Cheers, Gavin