qrencoder
qrencoder copied to clipboard
qrencode_png gives inverted QR codes?
qrencode_png seems to give me a white-on-black image, which isn't recognized (by my phone) as a QR code:
<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABUAAAAVCAAAAACMfPpKAAAACXBIWXMAAC4jAAAuIwF4pT92AAAAgklEQVQYlVWQWxIEIQgDO1ve/8q9Hzx0xtEyBEMgAkAEQqNDgEam0QEhlRwaHfoztQH4TTQjU7pkiaoInMkwhje/oi8O9kvbhpFjlzfXwpTazooL9q2ViLW2/7j6HyN9ZmdWSe1paBEFRXZm1Zw1pzudNJ94o2ICa3N0n3894DRA+AOyklQTTJcpUAAAAABJRU5ErkJggg==" />
(the github comment won't render this img, you'll have to copy and paste it if you want to see it?)
Whereas if I invert the raw qr object inside qrencode_png, changing tmp <- qrencode_raw(to_encode) to tmp <- 1-qrencode_raw(to_encode)
I get black-on-white, which looks right and my phone is happy with:
<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABUAAAAVCAAAAACMfPpKAAAACXBIWXMAAC4jAAAuIwF4pT92AAAAfklEQVQYlVWQQRIDIAgDNx3//+XtIVCtjgNRCDHQJYAOOsUBIA46EBBsKDrTQ+wB4MMlzuacGQQluail3ZeuyV+Vq7VRfxNsaftilqFzwr7ZLpdpZnr/v/BqeBTdO0dEmV7PDBLMqmzl8Ot1x3FRcz0LsW3x9cyfgrwEa5t+AcXuXeULGOYEAAAAAElFTkSuQmCC" />
> sessionInfo()
R version 3.4.0 (2017-04-21)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 16.04.2 LTS
other attached packages:
[1] base64enc_0.1-3 qrencoder_0.1.0
Not tested on other platforms, sorry. Update: same deal on Windows 7/x86_64, R3.3.0.
I also have this issue when trying to draw QR codes onto documents using the grid package. I've been using the same workaround:
code <- qrencode(my_label)
grid.draw(rasterGrob(1-code, interpolate = F))
R version 3.5.0 (2018-04-23) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows >= 8 x64 (build 9200)