-
Notifications
You must be signed in to change notification settings - Fork 48
/
py-quart.py
executable file
·68 lines (57 loc) · 2.4 KB
/
py-quart.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# Authors:
# Jesus M. Gonzalez-Barahona <jgb@bitergia.com>
#
import argparse
import os.path
import sys
from pyqart import QArtist, QrHalftonePrinter, QrImagePrinter, QrPainter
description = "Generate QArt RQ codes with embedded logos"
QR_VERSION = 10
def parse_args ():
parser = argparse.ArgumentParser(description = description)
parser.add_argument("logo", type=str, nargs=1,
help="Logo file name (PNG, GIF, JPG)")
parser.add_argument("--url", type=str, default='https://jgbarah.github.io',
help="Directory where generated QRs are written")
parser.add_argument("--dir", type=str, default='.',
help="Directory where generated QRs are written")
parser.add_argument("--points", type=str, default=10,
help="Points per pixel")
args = parser.parse_args()
return args
def main ():
args = parse_args()
logo = args.logo[0]
dir = args.dir
url = args.url
points = args.points
artist = QArtist(url, logo, QR_VERSION)
painter = QrPainter(url, QR_VERSION)
artist_data_only = QArtist(url, logo, QR_VERSION, only_data=True)
# Normal
QrImagePrinter.print(painter, path=os.path.join(dir, 'normal.png'), point_width=points)
# Halftone
QrHalftonePrinter.print(painter, path=os.path.join(dir, 'halftone.png'), img=logo,
point_width=points, colorful=False)
# Halftone colorful
QrHalftonePrinter.print(painter, path=os.path.join(dir, 'halftone-color.png'), img=logo,
point_width=points)
# Halftone pixel
QrHalftonePrinter.print(painter, path=os.path.join(dir, 'halftone-pixel.png'), img=logo,
point_width=points, colorful=False,
pixelization=True)
# QArt
QrImagePrinter.print(artist, path=os.path.join(dir, 'qart.png'), point_width=points)
# QArt data only
QrImagePrinter.print(artist_data_only, path=os.path.join(dir, 'qart-data-only.png'),
point_width=points)
# HalfArt
QrHalftonePrinter.print(artist, path=os.path.join(dir, 'halfart.png'), point_width=points)
# HalfArt data only
QrHalftonePrinter.print(artist_data_only, path=os.path.join(dir, 'halfart-data-only.png'),
point_width=points)
if __name__ == "__main__":
main()