A Reproducible Pipeline for Creating QR Codes in R
Overview
This report presents a reproducible workflow for generating QR codes in R.
You can also use the qr_code() function from the rutils package to automate the process.
For more details about the implementation, see the README in the code repository.
If you find this project useful, please consider giving it a star!
Set the Environment
Load Packages
Set Initial Variables
link <- "https://github.com/danielvartan"logo <- here("images", "github-icon.svg")frame <- here("images", "qr-code-frame.svg")Generate the QR Code
qr_code <- link |> qr_code(ecl = "H")qr_code |>
generate_svg(
filename = here("images", "qr-code.svg"),
size = 530,
show = FALSE
)Add a Logo
qr_code |>
add_logo(logo = logo, ecl = "L") |>
generate_svg(
filename = here("images", "qr-code-with-logo.svg"),
size = 530,
show = FALSE
)Add a Frame
qr_code <-
here("images", "qr-code-with-logo.svg") |>
image_read() |>
image_trim() |>
image_resize("450x450!")image_info(qr_code)frame <-
frame |>
image_read_svg(width = 550, height = 650)image_info(frame)composite <- image_composite(
image = frame,
composite_image = qr_code,
offset = "+50 +50"
)image_info(composite)composite |>
image_write(
path = here("images", "qr-code-composite.png"),
format = "png",
quality = 100
)License
The code in this report is licensed under the GNU General Public License Version 3, while the report is available under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International.
Copyright (C) 2025 Daniel Vartanian
The code in this report is free software: you can redistribute it and/or
modify it under the terms of the GNU General Public License as published by the
Free Software Foundation, either version 3 of the License, or (at your option)
any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program. If not, see <https://www.gnu.org/licenses/>.

