47ppm Module
47.1Overview
The ppm
module provides measures to read/write image data in PPM format. To utilize it, import the ppm
module using import
function.
Below is an example to read a PPM file:
import(ppm)
img = image('foo.ppm')
47.2Exntension to Function's Capability
This module extends the capability of function image()
and instance method image#write()
so that they can read/write PPM files.
When function image()
is provided with a stream that satisfies the following conditions, it would recognize the stream as a PPM file.
- The identifier of the stream ends with a suffix "
.ppm
" or ".pbm
". - The stream data begins with a byte sequence "
P2
", "P3
" or "P6
".
When instance method image#write()
is provided with a stream that satisfies the following condition, it would write image data in PPM format.
- The identifier of the stream ends with a suffix "
.ppm
" or ".pbm
".
47.3Extension to image Class
This module extends the image
class with methods described here.
image#read@ppm(stream:stream:r):reduce
Reads a PPM/PGM image from a stream.
image#write@ppm(stream:stream:w):reduce:[gray]
Writes a PPM/PGM image to a stream.