Questions tagged [pypng]

Pure Python library for PNG image encoding/decoding

Definition:

PyPNG provides Python code for encoding and decoding PNG files.

Example Usage:

import png
f = open('example.png', 'wb')
w = png.Writer(255, 1, greyscale=True)
w.write(f, [range(256)])
f.close()

Important Links:

35 questions
1
vote
2 answers

Cannot open image. Not a valid bitmap file or its format is not currently supported

I wrote this Python Program to create and save a matrix (2D Array) to a .png file. The program compiles and runs without any error. Even the IMAGE.png file is created but the png file won't open. When I try to open it in MSpaint, it says: Cannot…
ArnabC
  • 181
  • 1
  • 3
  • 16
1
vote
1 answer

Create filled image with PyPNG module

How can I do this without numpy module? It draws a white square 256x256 rows = [[255 for element in xrange(4) for number_of_pixles in xrange(256)] for number_of_rows in xrange(256)] import numpy # Using numpy is much faster rows = numpy.zeros((256,…
1
vote
1 answer

PyPNG: What does 'plane' mean?

I just began working with PyPNG. But in the metadata is one item I don't understand: planes. So two examples of two files: File 1 'bitdepth': 8, 'interlace': 0, 'planes': 1, 'greyscale': False, 'alpha': False, 'size': (818, 1000) File 2 'bitdepth':…
FlorianM
  • 33
  • 4
1
vote
1 answer

Iterative writing with PyPNG

I was wondering if there is a way to iteratively write png files using PyPNG (as in, row-by-row, or chunk-by-chunk) without providing the png.Writer() with the entire data. I've looked through the documentation, but all the writer methods require…
1
vote
0 answers

Convert PNG image (using pypng) for use in matplotlib with figure.figimage

I need a little help. I have a chart that is produced with matplotlib, and the last requirement is to display the company logo (.PNG file) on the chart. However, I cannot use the Python Image Library (PIL) for this task and so am using pypng to read…
0
votes
1 answer

Python image processing for 16-bit grayscale png image

I'm writing a script to check if an image is normalized or not. I'm using Python PNG module to analyze the image. To test it I created a 16-bit image consisting of a 2 pixels line with a black and white pixel in Photoshop. My script correctly…
andresp
  • 1,624
  • 19
  • 31
0
votes
2 answers

Horizontal flip of Image on Python with pypng

I am trying to horizontally flip an image (from left to right) on Python using PyPNG, I have written the following codes but it does not seem to work, anybody have any idea what I'm doing wrong here? def horizontal_flip(image): rows =…
user1009134
  • 1
  • 1
  • 1
0
votes
0 answers

How to save a numpy array as an png/jpg image?

I have an 8-by-8 binary numpy array and want to convert it to a greyscale jpg/png image. Does anyone know a piece of code for it?
BlueCurve
  • 33
  • 1
  • 7
0
votes
1 answer

How to process IDATA from large PNG images chunk by chunk, in Python

First of all, I'd like to refer to question 29513549, where all respondents seem to agree that it makes sense that the PNG image format was designed to have multiple IDAT chunks in case of larger images - for reading and for writing. These IDAT…
Dobedani
  • 508
  • 5
  • 20
0
votes
1 answer

PyPng throws signature FormatError when PNG is valid

I'm trying to make a small python program that combines images in different ways, but when I try to open an image it throws: png.FormatError: FormatError: PNG file has invalid signature. Here's the code: from png import Reader, Writer from sys…
lenerdv
  • 177
  • 13
0
votes
1 answer

Can't create an image from an url with pypng

I'm very new to pypng and with python itself, I've been working on a weather api program which is supposed to fetch an image from openweathermap.org. I've googled for hours and can't seem to find a solution for the error I'm getting. The…
K.Hodzic
  • 3
  • 3
0
votes
0 answers

convert pypng to numpy array

I'm trying to convert pypng data struct to a numpy array (with PIL, you can just call numpy.array(img) and it works), but I'm not sure how to do it with pypng. I need to work with 48 bit images, so I need to use pypng. I've adapted the method…
dev_nut
  • 2,476
  • 4
  • 29
  • 49
0
votes
1 answer

Changing png pixels selectively with PyPNG on Raspbian

I am trying to go through each pixel of a png that I captured with my Raspberry pi's camera, and change selectively change pixels that are above or below a certain r, g, or b value. I know it is a pretty inefficient algorithm, I am just trying to…
Dan P
  • 15
  • 7
0
votes
0 answers

PyPng: AttributeError: 'module' object has not attribute 'Writer'

Somewhat new to Python. Trying out PyPNG (need to write some simple PNG files). Using the code (almost) exactly as in the examples in the documentation. import png def main(): f = open('ramp.png', 'wb') # binary mode is important w =…
0
votes
3 answers

Create RGB image with three grayscale png files - pypng

I'm trying to create an RGB png image by merging three grayscale png images using pypng. I've read the png files into numpy arrays as below pngFile1 = png.Reader("file1.png").read() pngFile2 = png.Reader("file2.png").read() pngFile3 =…
Olayinka
  • 2,813
  • 2
  • 25
  • 43