Been doing this forever. From C it's the easiest way to output images, using popen and piping to netpbm or imagemagick. Without error handling it goes like this:<p><pre><code> fp = popen ("pnmtojpeg > output.jpg", "w");
fprintf (fp, "P3 %d %d 255", width, height);
/* print pixels as R G B triples */
pclose (fp);</code></pre>