Long QR codes not scannable
Closed this issue · 3 comments
smallworlnd commented
Hello,
The example code on the main page creates an invalid/unreadable QR code from the long string.
library(qrcode)
inputString <- paste0(
rep("abcdefghijklmnopqrstuvwxyz1234567890", 63), collapse = ""
)
qrcode_gen(inputString, softLimitFlag = FALSE)
ThierryO commented
I can confirm this is a bug. It occurs when the input string is longer dan 134 characters with the default error correction level.
character_set <- c(letters, LETTERS, rep(" ", 20), 0:9)
random_character <- sample(character_set, 134, replace = TRUE)
input_string <- paste(random_character, collapse = "")
random_character <- sample(character_set, 135, replace = TRUE)
input_string2 <- paste(random_character, collapse = "")
qrcode_gen(input_string)
qrcode_gen(input_string2)
It occurs with shorter strings when the error correction level increases.
qrcode_gen(input_string, ErrorCorrectionLevel = "M")
random_character <- sample(character_set, 107, replace = TRUE)
input_string3 <- paste(random_character, collapse = "")
qrcode_gen(input_string3, ErrorCorrectionLevel = "M")
I didn't wrote the main functions of the package. So it will take me some time to fix this.
ThierryO commented
This should be fixed. Can you please try the new version?
remotes::install_github("thierryo/qrcode@bugfix")
library(qrcode)
inputString <- paste0(
rep("abcdefghijklmnopqrstuvwxyz1234567890", 63), collapse = ""
)
plot(qr_code(inputString))
smallworlnd commented
I had a hard time getting my QR code reader to recognise an image that complex, but at least a string 350 characters in length can now be properly encoded and recognised! Thanks!