Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

export qr_logo() #13

Merged
merged 19 commits into from
Dec 18, 2022
Merged

export qr_logo() #13

merged 19 commits into from
Dec 18, 2022

Conversation

ThierryO
Copy link
Owner

@badgettrg, can you give feedback on this branch? Install it with remotes::install_github("ThierryO/qrcode@hotfix")

@badgettrg
Copy link

Image looks very good and retrieves the requested URL, and the svg opens in MS Edge on my Windows computer. However, I could not programmatically save it as a png with:
png(file=paste(filename,'-logo.png',sep=''))
code <- qr_logo(x = url, logo = "logo.jpg", file=paste(filename,'..svg',sep=''))
plot (code)
dev.off()

Error in plot.window(...) : need finite 'ylim' values
In addition: Warning messages:
1: In xy.coords(x, y, xlabel, ylabel, log) : NAs introduced by coercion
2: In min(x) : no non-missing arguments to min; returning Inf
3: In max(x) : no non-missing arguments to max; returning -Inf

@ThierryO
Copy link
Owner Author

Currently qr_logo() only writes the svg file and returns invisible NULL. Hence plotting it's output doesn't work. What is your use case for png that doesn't work with svg?

@badgettrg
Copy link

badgettrg commented Nov 24, 2022 via email

@ThierryO
Copy link
Owner Author

ThierryO commented Dec 8, 2022

@badgettrg can you try this version? qr_logo() now works like qr_code(). So you can plot() the output. Use generate_svg() in case you want an svg format.

@badgettrg
Copy link

When I try:
remotes::install_github("ThierryO/qrcode", force = TRUE)
I get:
Skipping install of 'qrcode' from a github remote, the SHA1 (e610b2b) has not changed since last install.

When I try
remotes::install_github("ThierryO/qrcode@hotfix")
I get version 0.2.0 and when I try
code <- qr_logo(x = url, logo = "logo.jpg")
I get:
Could not find function "qr_logo"

@ThierryO
Copy link
Owner Author

ThierryO commented Dec 8, 2022

It looks like you reinstalled the hoxfix version (0.2.1) while the deploied version (0.2.0) was loaded. Can you try again in a clean session? It should load version 0.2.1. If not, close all R sessions, run remotes::install_github("ThierryO/qrcode@hotfix", force = TRUE) in a new R session before trying again.

@badgettrg
Copy link

Thanks, that allowed the code to run.

Looks good, but as compared to the prior SVG function, both the current functions, qr_code, and generate_svg, are placing the logo off center. See outputs at HTTP://sumsearch.org/r/qr/

@ThierryO
Copy link
Owner Author

ThierryO commented Dec 9, 2022

That's deliberate in the current implementation. The logo is scale so the error correction level is preserved. A logo with an more extreme width to height ratio could overlap with the finder and timing patterns. The logo is scaled and center to the area to the right and below the finder and timing patterns. Centering to the entire code might result in a smaller logo (to avoid the overlap).
qr code pattern locations

Maybe I could add an hjust and vjust argument to indicate the relative position of the logo center. E.g. hjust = 0.5 would place the center of the logo in the center of the qrcode. hjust = 0.75 would place the center at a quarter to the right side. But what if the logo is wider than half the qr code in such case? Clip the logo? Move the logo to the left until it fits? Keep the location of the logo center and shrink the logo until it fits?

@badgettrg
Copy link

badgettrg commented Dec 9, 2022 via email

@ThierryO
Copy link
Owner Author

@badgettrg and @markscherz, can you please test this version? I replaced qr_logo() with add_logo(). So you first generate a QR code and then add the logo. Hence it also works with qr_event() and qr_wifi(). The horizontal placement of the logo can be left, center or right. The vertical placement is either bottom, center or top.

Install it with remotes::install_github("ThierryO/qrcode@hotfix") in a clean R session.

@badgettrg
Copy link

badgettrg commented Dec 16, 2022 via email

@ThierryO
Copy link
Owner Author

qr_code() and add_logo() use by default the lowest error level ("L"). Adding a logo on top of a QR code decreases error level. Therefore you must provide a QR code with a higher error levels as input to add_logo().

# largest difference in error level, hence largest logo
code <- qr_code("my text", ecl = "H")
add_logo(code, "logo.jpg")
# minimal difference, hence small logo
code <- qr_code("my text", ecl = "M")
add_logo(code, "logo.jpg")
code <- qr_code("my text", ecl = "H")
add_logo(code, "logo.jpg", ecl = "Q")
# error level in input too small
code <- qr_code("my text", ecl = "M")
add_logo(code, "logo.jpg", ecl = "H")

@badgettrg
Copy link

badgettrg commented Dec 17, 2022 via email

@ThierryO ThierryO merged commit 60b0024 into main Dec 18, 2022
@ThierryO ThierryO deleted the hotfix branch December 18, 2022 10:32
@badgettrg
Copy link

badgettrg commented Apr 30, 2023

qr_code working very well.

Would like to handle a mailto link with subject line in order to solicit audience feedback at an oral presentation.

mailto:rbadgett@kumc.edu?subject=test%20message

...picks up the email address, but does not pick up the subject line

if you have time to add code to pick up subject and cc that would be great. No worries if no time. thanks

@ThierryO
Copy link
Owner Author

ThierryO commented May 2, 2023

The code below generates a qr code with the correct message. The problem is with the software scanning the code.

qrcode::qr_code("mailto:rbadgett@kumc.edu?subject=test%20message") |>
  plot()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants