a few words about web development

How to save images as PNM, PGM or PBM

Converting images to Netpbm formats
If you need to convert images to PNM, PGM or PBM with PHP this small library is for you.

The library has 3 functions:
function imagepnm($im, $fname)
function imagepgm($im, $fname)
function imagepbm($im, $fname)
and you can use them in the same fashion as built-in PHP functions imagepng(), imagegif() and imagejpeg().

Example: converting PNG to PNM

$im = imagecreatefrompng('input.png');
imagepnm($im, 'output.pnm');

Example: converting GIF to PBM

$im = imagecreatefromgif('input.gif');
imagepbm($im, 'output.pbm');

Example: converting JPEG to PNM

$im = imagecreatefromjpeg('input.jpg');
imagepgm($im, 'output.pgm');

License: MIT