Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
.png data as matrix ?
#1
Hi,

What is the best python3 strategy for extracting the data chunk from a small monochrome .png file, representing a QR code? Ultimately, I want to print it serially, pixel line by pixel line, to a dumb serial label printer. I am thinking I need to extract the data field as a matrix to feed to the print routine.

Thoughts / suggestions?

Thanks,

Brian H.
Reply
#2
I'd probably use pillow. Can install with pip.

>>> from PIL import Image
>>> qr = Image.open("qr.png", "r")
>>> qr.size
(171, 171)
>>> 171 * 171
29241
>>> len(list(qr.getdata()))
29241
Reply
#3
Perfect! Thanks.

Brian H.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  How to multiply a matrix with herself, until the zero matrix results peanutbutterandjelly 3 803 May-03-2021, 06:30 AM
Last Post: Gribouillis
  matrix from matrix python numpy array shei7141 1 2,220 Jan-16-2017, 06:10 PM
Last Post: micseydel

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020