Skip to content

Commit 562e46d

Browse files
committed
PyPNM 2.21.3.12 "Victory II" update
1 parent c444323 commit 562e46d

3 files changed

Lines changed: 29 additions & 23 deletions

File tree

ScaleNxGUI.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
__copyright__ = '(c) 2025 Ilya Razmanov'
3030
__credits__ = 'Ilya Razmanov'
3131
__license__ = 'unlicense'
32-
__version__ = '25.09.09.09'
32+
__version__ = '25.09.16.08'
3333
__maintainer__ = 'Ilya Razmanov'
3434
__email__ = 'ilyarazmanov@gmail.com'
3535
__status__ = 'Production'

pypnm/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
"""PNM (PPM and PGM) image files reading, displaying and writing for Python > 3.10.
1+
"""PNM (PPM and PGM) image files reading, displaying and writing for Python 3.11 and above.
22
----
33
4-
2 Sep 2025 "Victory II" build. Fully interchangeable with previous
5-
9 May 2025 PyPNM 1.17.9.2 "Victory" build.
4+
3 Sep 2025 "Victory II" update. Fully interchangeable with previous PyPNM 1.17.9.2
5+
9 May 2025 "Victory" build.
66
77
Use `from pypnm import pnmlpnm` to access functions.
88

pypnm/pnmlpnm.py

Lines changed: 25 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,24 @@
11
#!/usr/bin/env python3
22

3-
"""PPM and PGM image files reading, displaying and writing for Python > 3.10.
4-
------------------------------------------------------------------------------
3+
"""PPM and PGM image files reading, displaying and writing for Python >= 3.11.
4+
-------------------------------------------------------------------------------
55
66
Overview
77
---------
88
99
PyPNM module is a pack of functions for dealing with PPM and PGM image files.
1010
Functions included are:
1111
12-
- `pnm2list`: reading binary or ascii RGB PPM or L PGM file and returning image data
12+
- `pnm2list`: reading binary or ASCII RGB PPM or L PGM file and returning image data
1313
as nested list of int.
1414
- `list2bin`: getting image data as nested list of int and creating binary PPM (P6) or PGM (P5)
15-
data structure in memory. Suitable for generating data to display with
16-
Tkinter `PhotoImage(data=...)` class.
15+
data structure in memory. Suitable for generating data to display with Tkinter `PhotoImage (data=...)` class.
1716
- `list2pnmbin`: getting image data as nested list of int and writing binary PPM (P6) or PGM (P5) image file.
18-
Note that bytes generations procedure is optimized to save memory while working with large files and
19-
therefore is different from that used in `list2bin`.
20-
- `list2pnmascii`: alternative function to write ASCII PPM (P3) or PGM (P2) files.
17+
Note that bytes generations procedure is different from that used in `list2bin`.
18+
- `list2pnmascii`: getting image data as nested list of int and writing ASCII PPM (P3) or PGM (P2) files.
2119
- `list2pnm`: getting image data as nested list of int and writing either binary or ASCII PNM
2220
depending on `bin` argument value.
2321
- `create_image`: creating empty nested 3D list for image representation.
24-
Not used within this particular module but often needed by programs this module is supposed to be used with.
2522
2623
Installation
2724
-------------
@@ -70,23 +67,25 @@
7067
with Tkinter `PhotoImage` class.
7168
7269
May be freely used, redistributed and modified.
73-
In case of introducing useful modifications, report to the developer at once.
70+
71+
In case of introducing useful modifications, report upstairs at once.
7472
7573
References
7674
-----------
7775
7876
1. Netpbm specifications: https://netpbm.sourceforge.net/doc/
79-
2. PyPNM at GitHub: https://github.com/Dnyarri/PyPNM/
80-
3. PyPNM at PyPI: https://pypi.org/project/PyPNM/
81-
4. PyPNM Documentation: https://dnyarri.github.io/pypnm/pypnm.pdf
77+
2. PyPNM for Python >= 3.11 at GitHub: https://github.com/Dnyarri/PyPNM/
78+
3. PyPNM for Python >= 3.4 at GitHub: https://github.com/Dnyarri/PyPNM/tree/py34
79+
4. PyPNM at PyPI: https://pypi.org/project/PyPNM/
80+
5. PyPNM Documentation: https://dnyarri.github.io/pypnm/pypnm.pdf
8281
8382
"""
8483

8584
__author__ = 'Ilya Razmanov'
8685
__copyright__ = '(c) 2024-2025 Ilya Razmanov'
8786
__credits__ = 'Ilya Razmanov'
8887
__license__ = 'unlicense'
89-
__version__ = '2.21.2.2'
88+
__version__ = '2.21.3.12'
9089
__maintainer__ = 'Ilya Razmanov'
9190
__email__ = 'ilyarazmanov@gmail.com'
9291
__status__ = 'Production'
@@ -112,7 +111,8 @@ def pnm2list(in_filename: str) -> tuple[int, int, int, int, list[list[list[int]]
112111
for reading data from PPM/PGM, where:
113112
114113
- `X`, `Y`, `Z`: image dimensions (int);
115-
- `maxcolors`: maximum of color per channel for current image (int), 255 for 8 bit and 65535 for 16 bit input. Note that 1 bit images get promoted to 8 bit L upon import;
114+
- `maxcolors`: maximum of color per channel for current image (int),
115+
255 for 8 bit and 65535 for 16 bit input. Note that 1 bit images get promoted to 8 bit L upon import.
116116
- `list_3d`: image pixel data as list(list(list(int)));
117117
- `in_filename`: PPM/PGM file name (str).
118118
@@ -345,7 +345,7 @@ def _p1(in_filename: str) -> tuple[int, int, int, int, list[list[list[int]]]]:
345345
╚══════════╝ """
346346

347347
def list2bin(list_3d: list[list[list[int]]], maxcolors: int, show_chessboard: bool = False) -> bytes:
348-
"""Convert nested image data list to PGM P5 or PPM P6 (binary) data structure in memory to be used with Tkinter PhotoImage(data=...).
348+
"""Convert nested image data list to PGM P5 or PPM P6 bytes in memory.
349349
350350
Usage:
351351
@@ -355,7 +355,9 @@ def list2bin(list_3d: list[list[list[int]]], maxcolors: int, show_chessboard: bo
355355
356356
- `list_3d`: Y * X * Z list (image) of lists (rows) of lists (pixels) of ints (channel values);
357357
- `maxcolors`: maximum of color per channel for current image (int);
358-
- `show_chessboard`: optional bool, set `True` to show LA and RGBA images against chessboard pattern; `False` or missing show existing L or RGB data for transparent areas as opaque. Default is `False` for backward compatibility.
358+
- `show_chessboard`: optional bool, set `True` to show LA and RGBA images against chessboard pattern;
359+
`False` or missing show existing L or RGB data for transparent areas as fully opaque.
360+
Default is `False` for backward compatibility.
359361
- `image_bytes`: PNM-structured binary data.
360362
361363
"""
@@ -523,7 +525,7 @@ def list2pnm(out_filename: str, list_3d: list[list[list[int]]], maxcolors: int,
523525
╚════════════════════╝ """
524526

525527
def create_image(X: int, Y: int, Z: int) -> list[list[list[int]]]:
526-
"""Create empty 3D nested list of X * Y * Z size."""
528+
"""Create 3D nested list of X * Y * Z size filled with zeroes."""
527529

528530
new_image = [[[0 for z in range(Z)] for x in range(X)] for y in range(Y)]
529531

@@ -532,4 +534,8 @@ def create_image(X: int, Y: int, Z: int) -> list[list[list[int]]]:
532534

533535
# ↓ Dummy stub for standalone execution attempt
534536
if __name__ == '__main__':
535-
print(f'Module PyPNM {__version__} to be imported, not run as standalone!')
537+
print('Module to be imported, not run as standalone.')
538+
need_help = input('Would you like to read some help (y/n)?')
539+
if need_help.startswith(('y', 'Y')):
540+
import pnmlpnm
541+
help(pnmlpnm)

0 commit comments

Comments
 (0)