Mercurial > hgrepos > Python2 > PyMuPDF
comparison mupdf-source/thirdparty/zxing-cpp/wrappers/python/demo_writer.py @ 2:b50eed0cc0ef upstream
ADD: MuPDF v1.26.7: the MuPDF source as downloaded by a default build of PyMuPDF 1.26.4.
The directory name has changed: no version number in the expanded directory now.
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Mon, 15 Sep 2025 11:43:07 +0200 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 1:1d09e1dec1d9 | 2:b50eed0cc0ef |
|---|---|
| 1 import sys | |
| 2 import zxingcpp | |
| 3 from PIL import Image | |
| 4 | |
| 5 if len(sys.argv) < 3: | |
| 6 format, content = zxingcpp.BarcodeFormat.QRCode, "I have the best words." | |
| 7 else: | |
| 8 format, content = zxingcpp.barcode_format_from_str(sys.argv[1]), sys.argv[2] | |
| 9 | |
| 10 # old writer API | |
| 11 img = zxingcpp.write_barcode(format, content, width=200, height=200) | |
| 12 Image.fromarray(img).save("test.png") | |
| 13 | |
| 14 # new/experimental writer API | |
| 15 # barcode = zxingcpp.create_barcode(content, format, ec_level = "50%") | |
| 16 | |
| 17 # img = barcode.to_image(size_hint = 500) | |
| 18 # Image.fromarray(img).save("test.png") | |
| 19 | |
| 20 # svg = barcode.to_svg(with_hrt = True) | |
| 21 # with open("test.svg", "w") as svg_file: | |
| 22 # svg_file.write(svg) |
