1Pnm(3) User Contributed Perl Documentation Pnm(3)
2
3
4
6 PDL::IO::Pnm -- pnm format I/O for PDL
7
9 use PDL::IO::Pnm;
10 $im = wpnm $pdl, $file, $format[, $raw];
11 rpnm $stack->slice(':,:,:,(0)'),"PDL.ppm";
12
14 pnm I/O for PDL.
15
17 pnminraw
18 Signature: (type(); byte+ [o] im(m,n); int ms => m; int ns => n;
19 int isbin; char* fd)
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 piddles if the flag is set for any of the input piddles.
30
31 pnminascii
32 Signature: (type(); byte+ [o] im(m,n); int ms => m; int ns => n;
33 int format; char* fd)
34
35 Read in an ascii pnm file.
36
37 pnminascii does not process bad values. It will set the bad-value flag
38 of all output piddles if the flag is set for any of the input piddles.
39
40 pnmout
41 Signature: (a(m); int israw; int isbin; char *fd)
42
43 Write a line of pnm data.
44
45 This function is implemented this way so that threading works
46 naturally.
47
48 pnmout does not process bad values. It will set the bad-value flag of
49 all output piddles if the flag is set for any of the input piddles.
50
51 rpnm
52 Read a pnm (portable bitmap/pixmap, pbm/ppm) file into a piddle.
53
54 Usage: $im = rpnm $file;
55
56 Reads a file in pnm format (ascii or raw) into a pdl (magic numbers
57 P1-P6). Based on the input format it returns pdls with arrays of size
58 (width,height) if binary or grey value data (pbm and pgm) or
59 (3,width,height) if rgb data (ppm). This also means for a palette image
60 that the distinction between an image and its lookup table is lost
61 which can be a problem in cases (but can hardly be avoided when using
62 netpbm/pbmplus). Datatype is dependent on the maximum
63 grey/color-component value (for raw and binary formats always PDL_B).
64 rpnm tries to read chopped files by zero padding the missing data (well
65 it currently doesn't, it barfs; I'll probably fix it when it becomes a
66 problem for me ;). You can also read directly into an existing pdl that
67 has to have the right size(!). This can come in handy when you want to
68 read a sequence of images into a datacube.
69
70 For details about the formats see appropriate manpages that come with
71 the netpbm/pbmplus packages.
72
73 $stack = zeroes(byte,3,500,300,4);
74 rpnm $stack->slice(':,:,:,(0)'),"PDL.ppm";
75
76 reads an rgb image (that had better be of size (500,300)) into the
77 first plane of a 3D RGB datacube (=4D pdl datacube). You can also do
78 inplace transpose/inversion that way.
79
80 wpnm
81 Write a pnm (portable bitmap/pixmap, pbm/ppm) file into a file.
82
83 Usage: $im = wpnm $pdl, $file, $format[, $raw];
84
85 Writes data in a pdl into pnm format (ascii or raw) (magic numbers
86 P1-P6). The $format is required (normally produced by wpic) and
87 routine just checks if data is compatible with that format. All
88 conversions should already have been done. If possible, usage of wpic
89 is preferred. Currently RAW format is chosen if compliant with range of
90 input data. Explicit control of ASCII/RAW is possible through the
91 optional $raw argument. If RAW is set to zero it will enforce ASCII
92 mode. Enforcing RAW is somewhat meaningless as the routine will always
93 try to write RAW format if the data range allows (but maybe it should
94 reduce to a RAW supported type when RAW == 'RAW'?). For details about
95 the formats consult appropriate manpages that come with the
96 netpbm/pbmplus packages.
97
99 The stderr of the converters is redirected to a file. The filename is
100 currently generated in a probably non-portable way. A method that
101 avoids a file (and is portable) would be preferred.
102
103 "rpnm" currently relies on the fact that the header is separated from
104 the image data by a newline. This is not required by the p[bgp]m
105 formats (in fact any whitespace is allowed) but most of the pnm writers
106 seem to comply with that. Truncated files are currently treated
107 ungracefully ("rpnm" just barfs).
108
110 Copyright (C) 1996,1997 Christian Soeller <c.soeller@auckland.ac.nz>
111 All rights reserved. There is no warranty. You are allowed to
112 redistribute this software / documentation under certain conditions.
113 For details, see the file COPYING in the PDL distribution. If this file
114 is separated from the PDL distribution, the copyright notice should be
115 included in the file.
116
117
118
119perl v5.32.1 2021-02-15 Pnm(3)