Skip to content

Commit

Permalink
Docstring additions
Browse files Browse the repository at this point in the history
  • Loading branch information
Dnyarri committed Dec 1, 2024
1 parent 58b0b21 commit 00fb559
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
6 changes: 4 additions & 2 deletions pnglpng.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,10 @@ def png2list(in_filename: str) -> tuple[int, int, int, int, list[list[list[int]]
Takes PNG filename ``in_filename`` and returns the following tuple:
- ``X, Y, Z`` - int, PNG image sizes.
- ``image3D`` - Y*X*Z list (image) of lists (rows) of lists (pixels) of ints (channels), from PNG iDAT.
- ``maxcolors`` - int, value maximum per channel, either 255 or 65535, for 8 bpc and 16 bpc PNG respectively.
- ``image3D`` - Y*X*Z list (image) of lists (rows) of lists (pixels) of ints (channels), from PNG iDAT.
- ``info`` - dictionary, chunks like resolution etc. as they are accessible by PyPNG.
"""

source = png.Reader(in_filename)
Expand All @@ -106,7 +107,7 @@ def png2list(in_filename: str) -> tuple[int, int, int, int, list[list[list[int]]
image3D = [
[
[
int(((imagedata[y])[(x*Z) + z])) for z in range(Z)
int((imagedata[y])[(x*Z) + z]) for z in range(Z)
] for x in range(X)
] for y in range(Y)
]
Expand All @@ -131,6 +132,7 @@ def list2png(out_filename: str, image3D: list[list[list[int]]], info: dict) -> N
- ``image3D`` - Y*X*Z list (image) of lists (rows) of lists (pixels) of ints (channels).
- ``info`` - dictionary, chunks like resolution etc. as you want them to be present in PNG.
"""

# Determining list sizes
Expand Down
4 changes: 2 additions & 2 deletions scalenx.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@

def scale2x(ImageAsListListList: list[list[list[int]]]) -> list[list[list[int]]]:
"""Rescale image with Scale2x.
Takes ``ImageAsListListList`` as 3D nested list (image) of lists (rows) of lists (pixels) of int (channel values) (see pnglpng.py for detail), and performs Scale2x rescaling, returning scaled image of similar structure.
"""
Expand Down Expand Up @@ -108,7 +108,7 @@ def scale2x(ImageAsListListList: list[list[list[int]]]) -> list[list[list[int]]]

def scale3x(ImageAsListListList: list[list[list[int]]]) -> list[list[list[int]]]:
"""Rescale image with Scale3x.
Takes ``ImageAsListListList`` as 3D nested list (image) of lists (rows) of lists (pixels) of int (channel values) (see pnglpng.py for detail), and performs Scale3x rescaling, returning scaled image of similar structure.
"""
Expand Down

0 comments on commit 00fb559

Please sign in to comment.