drj11 / pypng

Pure Python library for PNG image encoding/decoding
MIT License
451 stars 90 forks source link

How to handle monochromatic arrays ? #111

Open djibb opened 3 years ago

djibb commented 3 years ago

Hi guys, sorry for noob question... I'm in documentation since... 20' only. I have a 2d array [[1, 1, 1], [2, 2, 2], [3, 3, 3]] where each value is 1 single uint16. This array come form a camera monochrome 16 bits. (astronomical one) How write a png with good values ? Is there a way without *3 values ?

drj11 commented 3 years ago
import png
a = [[1, 1, 1], [2, 2, 2], [3, 3, 3]]
image = png.from_array(a, "L;16")
image.save("grey16.png")
drj11 commented 3 years ago

@drj11 please provide an example for this case that mentions "16-bit monochromatic array"