LoginSignup
1
0

バーコードとQRコードの生成プログラム

Last updated at Posted at 2023-12-19

バーコード生成プログラム

まだ詳しい事はわかっておりませんが、ひとまずバーコードを生成するところまで感覚でやってみました。

pip3 install python-barcode
pip3 install "python-barcode[images]"
from io import BytesIO
from barcode import Code128
from barcode.writer import ImageWriter

# Write to a file-like object:
rv = BytesIO()
Code128(str(100000902922), writer=ImageWriter()).write(rv)

data = "AbCd-123456"
fileName = data + ".jpeg"

# Or to an actual file:
with open(fileName, "wb") as f:
    Code128(data, writer=ImageWriter()).write(f)

生成バーコード

image.png

QRコード生成プログラム

pip install PyQRCode
pip install pypng
import qrcode
import pyqrcode

FILE_PNG_A = 'qrcode_A.png'

# QRコード作成
code = pyqrcode.create('https://qiita.com', error='L', version=3, mode='binary')
code.png("qiita.png", scale=5, module_color=[0, 0, 0, 128], background=[255, 255, 255])

生成QRコード

image.png

参考サイト

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0