Using the data storage type defined on this page for raster images, read an image from a PPM file (binary P6 prefered).
(Read the definition of PPM file on Wikipedia.)

Task: Use write ppm file solution and grayscale image solution with this one in order to convert a color image to grayscale one.

sub readPPM(f$)
	local ff, x, y, t$, dcol$, wid, hei
 
	if f$ = "" print "No PPM file name indicate." : return false
 
	ff = open (f$, "rb")
	if not ff print "File ", f$, " not found."  : return false
 
	input #ff t$, wid, hei, dcol$
 
	if t$ = "P6" then
		open window wid, hei
 
		for x = 0 to hei - 1
		 	for y = 0 to wid - 1
		 		color peek(#ff), peek(#ff), peek(#ff)
		 		dot y, x
		 	next y
		next x
 
		close #ff
	else
		print "File is NOT PPM P6 type." : return false
	end if
 
	return true
end sub