Skip to content

ValueError: buffer size must be a multiple of element size #78

Description

@sunknudsen

Trying to feed a PNG buffer to np.frombuffer and getting a buffer size error.

New to Python... would someone happen to know what is going on and how to fix this?

from cv2 import cv2
import pyqrcode
import io
import numpy as np
import sys

buffer = io.BytesIO()
qr = pyqrcode.create("foo")
qr.png(buffer, scale=2)

array = np.frombuffer(buffer.getvalue())
image = cv2.imdecode(array, cv2.IMREAD_COLOR)

cv2.imshow('QR code', image)
cv2.waitKey(0)
cv2.destroyAllWindows()

sys.exit()

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions