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.

//24-bpp P6 PPM solution:
image:=File("lena.ppm","rb").read();
start:=image.find("\n255\n")+5;   // Get sizeof PPM header
 
foreach n in ([start..image.len()-1,3]){  //  Transform color triplets
   r,g,b:=image[n,3];  // Read colors stored in RGB order
   l:=(0.2126*r + 0.7152*g + 0.0722*b).toInt(); // Derive luminance
   image[n,3]=T(l,l,l);
}
 
File("lenaGrey.ppm","wb").write(image);