dymoprint icon indicating copy to clipboard operation
dymoprint copied to clipboard

QR code size

Open andreas5232 opened this issue 7 years ago • 4 comments

QR codes containing longer text are printed with a smaller size than those containing only a short text. Maybe there is also a possibility to reduce the margins, so that there is more space for the QR code.

andreas5232 avatar Feb 15 '18 22:02 andreas5232

I've added a parameter which should help with that by reducing the amount of whitespace around the QRCode. Although as I see it, the problem is the rather poor resolution of the device: the QR Code is always scaled by a an integer: this is usually just 2 for a QRCode (so, one dot on the matrix results in 2 dots on the label). If the QRCode gets bigger than half the size it suddenly shrinks to 1 dot in the matrix being 1 pixel.

dev-zero avatar Sep 27 '18 13:09 dev-zero

I totally agree @dev-zero - with 64 dots there is no much option for scaling. I do not know if the printer-engine can be somehow re-written to get a higher (virtual) resolution.

computerlyrik avatar Mar 27 '19 19:03 computerlyrik

The QRCode size is larger than the actual size, the QRCode library adds a white frame around the QR. I changed the code as follows to detect how many "blank lines" are added and removes that lines (before and after the QR) and the same number of zeros before and after the "good lines".

        code = QRCode(labeltext[0],error='M')
        qr_text = code.text().split()
        # CHANGE_STARTS_HERE
        # Counts and removes trailing empty (0,0,...) lines
        allzz=0;
        for i in range(0,len(qr_text)-1):
            if qr_text[0][0:8]=='00000000':
                qr_text.pop(0)
                qr_text.pop(len(qr_text)-1)
                allzz=allzz+1
            else:
                break
        for i,line in enumerate(qr_text):
            qr_text[i]=line[allzz:-allzz]
        # CHANGE_ENDS_HERE
        # create an empty label image
        labelheight = lm._MAX_BYTES_PER_LINE * 8
        labelwidth = labelheight

hyppoCom avatar May 17 '21 14:05 hyppoCom

Hi @hyppoCom, this functionality looks really useful. This computerlyrik fork seems to be inactive, but I'd welcome a PR on my fork here: https://github.com/maresb/dymoprint

maresb avatar May 17 '21 15:05 maresb