From: Alexandro Kez Date: 2009-12-08T03:56:33+09:00 Subject: Re: Reading Images Fleck, thanks for this really good answer, but could you tell then what other data format may I use to avoid such parsings? I don't want to use anything extra. Dunno about RMagick, but I've seen some rubyrames example, where it's also done easy, but I wanna make it with ass few external libs as possible, that's the idea - I wanna see if ruby "da solo" is enough to coupe with such problems. Fleck Jean-Julien wrote: > The image.txt file looks like > > # ImageMagick pixel enumeration: 712,490,255,RGB > 0,0: (226,188,115) #E2BC73 rgb(226,188,115) > 1,0: (227,189,116) #E3BD74 rgb(227,189,116) > 2,0: (226,188,115) #E2BC73 rgb(226,188,115) > ... > 709,489: (224,207,125) #E0CF7D rgb(224,207,125) > 710,489: (211,203,120) #D3CB78 rgb(211,203,120) > 711,489: (134,129, 45) #86812D rgb(134,129,45) > > and its really easy to get the size (712x490) and the pixels colors > reading the file directly throught > > File.open(txt) do |f| > f.readlines.each do |line| > # action on each line using regexp to get the colors > end > end > > Cheers, -- Posted via http://www.ruby-forum.com/.