Outils pour utilisateurs

Outils du site


python:barcode

Barcode, Datamatrix, QR Code

Code 39

Package :

Installation :

pip install pybarcodes

Utilisation :

from pybarcodes import CODE39
 
barcode = CODE39("HELLO-WORLD")
barcode.save("myimage.png")

Code 128

Package :

Installation :

pip install code128

Utilisation :

import code128
 
code128.image("Hello World").save("hello.png")

DataMatrix

Docs:

Installer la librairie libdmtx sur le système :

sudo apt install libdmtx0b

Installer les packages Python :

pip install pylibdmtx
pip install pillow

Générer un Datamatrix :

from pylibdmtx.pylibdmtx import encode
from PIL import Image
 
encoded = encode("Hello world !".encode('utf8'))
img = Image.frombytes('RGB', (encoded.width, encoded.height), encoded.pixels)
img.save("example.png")

QR Code

Source: https://www.youtube.com/watch?v=y9VXWsU3FSE

Package :

Installation :

pip install qrcode
pip install pillow

Génération simple d'un QR Code :

import qrcode
 
img = qrcode.make("Bonjour tout le monde !")
img.save("exemple.png")

Génération d'un QR Code personnalisé :

import qrcode
 
qr = qrcode.QRCode(
    box_size=20,
    border=10
)
qr.add_data("Hello world !")
qr.make(fit=True)
 
img = qr.make_image(fill_color="blue", back_color="white")
img.save("example.png")
python/barcode.txt · Dernière modification: 2021/10/12 05:03 par marclebrun