-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.qmd
More file actions
190 lines (141 loc) · 4.4 KB
/
index.qmd
File metadata and controls
190 lines (141 loc) · 4.4 KB
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
<!-- badges: start -->
[](https://www.repostatus.org/#inactive)
[](https://www.gnu.org/licenses/gpl-3.0)
[](https://creativecommons.org/licenses/by-nc-sa/4.0/)
<!-- badges: end -->
## Overview
This report presents a reproducible workflow for generating QR codes in [R](https://www.r-project.org/).
You can also use the [`qr_code()`](https://danielvartan.github.io/rutils/reference/qr_code.html) function from the [`rutils`](https://danielvartan.github.io/rutils/) package to automate the process.
For more details about the implementation, see the [README](https://github.com/danielvartan/qr-code#qr-code) in the code repository.
> If you find this project useful, please consider giving it a star! [](https://github.com/danielvartan/qr-code/)
## Set the Environment
### Load Packages
```{r}
#| label: Set the Environment
#| output: false
library(here)
library(magick)
library(qrcode)
library(rsvg)
```
```{r}
#| include: false
library(downlit)
library(xml2)
```
### Set Initial Variables
```{r}
link <- "https://github.com/danielvartan"
```
```{r}
logo <- here("images", "github-icon.svg")
```
```{r}
frame <- here("images", "qr-code-frame.svg")
```
## Generate the QR Code
```{r}
#| label: Generate the QR Code
qr_code <- link |> qr_code(ecl = "H")
```
```{r}
qr_code |>
generate_svg(
filename = here("images", "qr-code.svg"),
size = 530,
show = FALSE
)
```
```{r}
#| include: false
file.copy(
from = here("images", "qr-code.svg"),
to = here("images", "favicon.svg"),
overwrite = TRUE
)
```
{fig-align="center" style="width: 50%"}
## Add a Logo
```{r}
#| label: Generate QR Code
qr_code |>
add_logo(logo = logo, ecl = "L") |>
generate_svg(
filename = here("images", "qr-code-with-logo.svg"),
size = 530,
show = FALSE
)
```
{fig-align="center" style="width: 50%"}
## Add a Frame
```{r}
#| label: Add Frame
qr_code <-
here("images", "qr-code-with-logo.svg") |>
image_read() |>
image_trim() |>
image_resize("450x450!")
```
```{r}
image_info(qr_code)
```
```{r}
#| eval: false
#| include: false
image_display(qr_code)
```
```{r}
frame <-
frame |>
image_read_svg(width = 550, height = 650)
```
```{r}
image_info(frame)
```
```{r}
#| eval: false
#| include: false
image_display(frame)
```
```{r}
composite <- image_composite(
image = frame,
composite_image = qr_code,
offset = "+50 +50"
)
```
```{r}
image_info(composite)
```
```{r}
#| eval: false
#| include: false
image_display(composite)
```
```{r}
composite |>
image_write(
path = here("images", "qr-code-composite.png"),
format = "png",
quality = 100
)
```
{fig-align="center" style="width: 50%"}
## License
::: {style="text-align: left;"}
[](https://www.gnu.org/licenses/gpl-3.0)
[](https://creativecommons.org/licenses/by-nc-sa/4.0/)
:::
The code in this report is licensed under the [GNU General Public License Version 3](https://www.gnu.org/licenses/gpl-3.0), while the report is available under the [Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International](https://creativecommons.org/licenses/by-nc-sa/4.0/).
``` text
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/>.
```