hudora / huBarcode

huBarcode is a Python Library to generate 1D and 2D Barcodes
http://github.com/mdornseif/huBarcode
146 stars 83 forks source link

Crash during QR-Code generation #7

Open mdornseif opened 13 years ago

mdornseif commented 13 years ago

hongshan liu writes:

hi,Maximillian Dornseif, I was using your huBarcode,but I found some bugs when I using it.

bug example1:

-- coding: utf-8 --

# author: liu hongshan email: hongshan.liu@...
from hubarcode.qrcode import QRCodeEncoder
if **name** == "**main**":
    test = "12345"
    ENCODER = QRCodeEncoder(test)
    ENCODER.save( "test.png",3)

bug info: File "/home/works/hudora-huBarcode-7a9d83e/hubarcode/qrcode/textencoder.py", line 207, in create_matrix matrix_content = self.minfo.create_matrix(self.version, self.codewords) File "/home/works/hudora-huBarcode-7a9d83e/hubarcode/qrcode/isodata.py", line 109, in create_matrix codeword_i = codewords[i] IndexError: list index out of range

could you fix these? thank you!

pbgc commented 13 years ago

I have the same problem with:

from huBarcode.qrcode import QRCodeEncoder

qr_encoder = QRCodeEncoder(id.zfill(12)) return HttpResponse(content=qr_encoder.get_imagedata(cellsize = 5), mimetype="image/png")

for example with id = 832

mdornseif commented 12 years ago

Does anybody have a patch for this?

pbgc commented 12 years ago

Don't have a patch... but a workaround...thats works...:

from huBarcode.qrcode import QRCodeEncoder

qr_encoder = None

try:
    qr_encoder = QRCodeEncoder(id, "M")
except IndexError:
    try:
        qr_encoder = QRCodeEncoder(id, "L")
    except IndexError:
        try:
            qr_encoder = QRCodeEncoder(id, "H")
        except IndexError:
            qr_encoder = QRCodeEncoder(id, "Q")

return HttpResponse(content=qr_encoder.get_imagedata(cellsize = 5), mimetype="image/png")
rm-hull commented 10 years ago

I encountered this today on the 1.0.0 tar.gz from pypi, and fixed it locally - was going to submit a PR, but it looks to have been fixed in commit 205bb1d1f4c588a28c25b5a3e7454bcc41468430 ... is there any chance 1.0.1 call be pushed up to the cheeseshop?

ah450 commented 8 years ago

+1 for pushing 1.0.1