1Pnm(3)                User Contributed Perl Documentation               Pnm(3)
2
3
4

NAME

6       PDL::IO::Pnm -- pnm format I/O for PDL
7

SYNOPSIS

9         use PDL::IO::Pnm;
10         $im = wpnm $pdl, $file, $format[, $raw];
11         rpnm $stack->slice(':,:,:,(0)'),"PDL.ppm";
12

DESCRIPTION

14       pnm I/O for PDL.
15

FUNCTIONS

17   pnminraw
18         Signature: (type(); byte+ [o] im(m,n); int ms => m; int ns => n;
19                               int isbin; PerlIO *fp)
20
21       Read in a raw pnm file.
22
23       read a raw pnm file. The "type" argument is only there to determine the
24       type of the operation when creating "im" or trigger the appropriate
25       type conversion (maybe we want a byte+ here so that "im" follows
26       strictly the type of "type").
27
28       pnminraw does not process bad values.  It will set the bad-value flag
29       of all output ndarrays if the flag is set for any of the input
30       ndarrays.
31
32   pnminascii
33         Signature: (type(); byte+ [o] im(m,n); int ms => m; int ns => n;
34                               int format; PerlIO *fp)
35
36       Read in an ascii pnm file.
37
38       pnminascii does not process bad values.  It will set the bad-value flag
39       of all output ndarrays if the flag is set for any of the input
40       ndarrays.
41
42   pnmout
43         Signature: (a(m); int israw; int isbin; PerlIO *fp)
44
45       Write a line of pnm data.
46
47       This function is implemented this way so that broadcasting works
48       naturally.
49
50       pnmout does not process bad values.  It will set the bad-value flag of
51       all output ndarrays if the flag is set for any of the input ndarrays.
52
53   rpnm
54       Read a pnm (portable bitmap/pixmap, pbm/ppm) file into an ndarray.
55
56         Usage:  $im = rpnm $file;
57
58       Reads a file (or open file-handle) in pnm format (ascii or raw) into a
59       pdl (magic numbers P1-P6).  Based on the input format it returns pdls
60       with arrays of size (width,height) if binary or grey value data (pbm
61       and pgm) or (3,width,height) if rgb data (ppm). This also means for a
62       palette image that the distinction between an image and its lookup
63       table is lost which can be a problem in cases (but can hardly be
64       avoided when using netpbm/pbmplus).  Datatype is dependent on the
65       maximum grey/color-component value (for raw and binary formats always
66       PDL_B). rpnm tries to read chopped files by zero padding the missing
67       data (well it currently doesn't, it barfs; I'll probably fix it when it
68       becomes a problem for me ;). You can also read directly into an
69       existing pdl that has to have the right size(!). This can come in handy
70       when you want to read a sequence of images into a datacube.
71
72       For details about the formats see appropriate manpages that come with
73       the netpbm/pbmplus packages.
74
75         $stack = zeroes(byte,3,500,300,4);
76         rpnm $stack->slice(':,:,:,(0)'),"PDL.ppm";
77
78       reads an rgb image (that had better be of size (500,300)) into the
79       first plane of a 3D RGB datacube (=4D pdl datacube). You can also do
80       inplace transpose/inversion that way.
81
82   wpnm
83       Write a pnm (portable bitmap/pixmap, pbm/ppm) file into a file or open
84       file-handle.
85
86         Usage:  $im = wpnm $pdl, $file, $format[, $raw];
87
88       Writes data in a pdl into pnm format (ascii or raw) (magic numbers
89       P1-P6).  The $format is required (normally produced by wpic) and
90       routine just checks if data is compatible with that format. All
91       conversions should already have been done. If possible, usage of wpic
92       is preferred. Currently RAW format is chosen if compliant with range of
93       input data. Explicit control of ASCII/RAW is possible through the
94       optional $raw argument. If RAW is set to zero it will enforce ASCII
95       mode. Enforcing RAW is somewhat meaningless as the routine will always
96       try to write RAW format if the data range allows (but maybe it should
97       reduce to a RAW supported type when RAW == 'RAW'?). For details about
98       the formats consult appropriate manpages that come with the
99       netpbm/pbmplus packages.
100

BUGS

102       "rpnm" currently relies on the fact that the header is separated from
103       the image data by a newline. This is not required by the p[bgp]m
104       formats (in fact any whitespace is allowed) but most of the pnm writers
105       seem to comply with that. Truncated files are currently treated
106       ungracefully ("rpnm" just barfs).
107

AUTHOR

109       Copyright (C) 1996,1997 Christian Soeller <c.soeller@auckland.ac.nz>
110       All rights reserved. There is no warranty. You are allowed to
111       redistribute this software / documentation under certain conditions.
112       For details, see the file COPYING in the PDL distribution. If this file
113       is separated from the PDL distribution, the copyright notice should be
114       included in the file.
115
116
117
118perl v5.36.0                      2023-01-20                            Pnm(3)
Impressum