Skip to content

Instantly share code, notes, and snippets.

@inscapist
Created July 12, 2023 15:19
Show Gist options
  • Save inscapist/1c60823ef2895cc4d066c91a529bfa2e to your computer and use it in GitHub Desktop.
Save inscapist/1c60823ef2895cc4d066c91a529bfa2e to your computer and use it in GitHub Desktop.
QR code generator using Nim
import QRgen
import QRgen/renderer
import pkg/[pixie]
import os
# Create a new QR code
let qr = newQR("https://github.com/aruZeta/QRgen", ecLevel=qrECH)
# Generate the QR code
# https://github.com/aruZeta/QRgen/blob/48231c7afacb54b88968c4bc84f51f6093333b8a/src/QRgen/renderer.nim#L42
# first number is alignment roundness (the 3 circles/squares)
# second number is module roundness (the "dots")
# third number is module separation (the distance/density of dots), should be 25 at most
let image = qr.renderImg("#1d2021","#98971a",50,50,25, pixels=3000, img=readImage("mbsa.png"))
writeFile(image, "qr.png")
@inscapist
Copy link
Author

nimble install qrgen
nimble install pixie

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment