- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试生成 SVG 格式的二维码。不幸的是,R qrencoder
包只生成光栅图像,例如PNG 等。因此,这是我第一次尝试生成它,在屏幕上绘制它,捕获屏幕,最后将屏幕写成 SVG。也许有更简单的方法来实现这一点?
library(rsvg)
library(raster)
library(qrencoder)
library(svglite)
tmp <- tempfile()
svglite::svglite(tmp, width = 10, height = 7)
#==============================================
old_mar <- par()$mar
par(mar=c(0,0,0,0))
image(qrencoder::qrencode_raster("http://rud.is/b"), asp=1, col=c("white", "black"),
axes=FALSE, xlab="", ylab="")
par(mar=old_mar)
#==============================================
dev.off()
rsvg::rsvg_svg(tmp, "out.svg")
输出文件将是包含 QR 码的 out.svg
。但是,执行最后一行 rsvg_svg
会导致以下错误:
(process:733): GdkPixbuf-WARNING **: Cannot open pixbuf loader module file '/usr/local/lib/gdk-pixbuf-2.0/2.10.0/loaders.cache': No such file or directory
This likely means that your installation is broken.
Try running the command
gdk-pixbuf-query-loaders > /usr/local/lib/gdk-pixbuf-2.0/2.10.0/loaders.cache
to make things work again for the time being.
(process:733): GdkPixbuf-WARNING **: Cannot open pixbuf loader module file '/usr/local/lib/gdk-pixbuf-2.0/2.10.0/loaders.cache': No such file or directory
This likely means that your installation is broken.
Try running the command
gdk-pixbuf-query-loaders > /usr/local/lib/gdk-pixbuf-2.0/2.10.0/loaders.cache
to make things work again for the time being.
(process:733): GdkPixbuf-WARNING **: Cannot open pixbuf loader module file '/usr/local/lib/gdk-pixbuf-2.0/2.10.0/loaders.cache': No such file or directory
This likely means that your installation is broken.
Try running the command
gdk-pixbuf-query-loaders > /usr/local/lib/gdk-pixbuf-2.0/2.10.0/loaders.cache
to make things work again for the time being.
我看到 Pixbuf 已正确安装在 macports 中:
/var/root$ port installed | grep pixbuf
gdk-pixbuf2 @2.36.9_0+x11
gdk-pixbuf2 @2.36.11_0+x11 (active)
我不知道真正的问题是什么……有没有更简单的方法来生成 SVG 格式的二维码?也许更简单的 API 最好不需要绘制到屏幕、捕获屏幕、保存文件并重新加载?
否则任何人都可以建议修复此错误吗?
最佳答案
您也可以从 qrencoder 生成的内联 png 代码中自己制作 svg(这只是一个文本文件),如
library(qrencoder)
qrencode_svg <- function(string, filename, width = "2cm", height = "2cm") {
inline_png <- qrencode_png(string)
con <- file(filename, open = "w+")
cat("<?xml version='1.0' encoding='UTF-8' ?>\n", file = con)
cat("<svg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' ",
"width='", width, "' height='", height, "'>\n", file = con, sep = "")
cat("<image width='", width, "' height='", height, "' x='0' y='0' xlink:href='", inline_png, "'/>\n",
file = con, sep = "")
cat("</svg>\n", file = con)
close(con)
}
qrencode_svg("http://rud.is/b", "test.svg", width = "2cm", height = "2cm")
但是,当尺寸太大时,结果会变得模糊,所以我只是为了完整性而在这里发布。或者也许有人知道如何改进它。
关于r - 如何生成 SVG 格式的二维码?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47110197/
可以在 R 中生成二维码吗?是否有允许它的包? 最佳答案 现在在 CRAN 您可以使用 qrencoder包 - https://github.com/hrbrmstr/qrencoder - 这样做
我有一个使用相机扫描二维码的应用程序。当我打开应用程序并转到二维码阅读器时,一切正常。一旦我扫描代码,信息就会发送到另一个 Activity ,但是一旦我点击后退按钮,相机就会变黑(见下文),我就无法
有没有办法为一个二维码创建多个 Action ? 目标是扫描二维码并执行这些操作: 连接WIFI 转至特定网址 我可以用 2 个二维码完成这 2 个操作,但只有一个会更容易 最佳答案 你不能。 仅仅是
在我的应用程序中,我需要实现 Blackberry Messenger 中可用的功能,即用户可以通过扫描他们的 QR 码来添加其他用户。 我找到了可以帮助生成二维码的库,也找到了线程来帮助生成二维码。
我尝试了新的 Google Play 服务功能 - 条码/QR 扫描仪。在 sample应用程序通过点击按钮开始扫描,结果也会在点击时返回。 有没有办法改变它的行为以立即返回第一个检测到的条形码/二维
我正在寻找解密(不仅是解码)二维码的逻辑。最近我看到几个加密二维码的应用程序,比如QuickMark。 .例如,此 QR 使用密码“pass”解密为“StackOverflow”: 如果你使用一个没有
我的公司有一个通过 URL 访问的社交网络平台。 我们正在尝试找到一种方法在体育商店中宣传我们的 URL,只有您来到商店才能访问我们的网站 - 我们不希望将 URL 分享给任何地方的任何人。 我们考虑
我想根据字段卷号生成一个二维码,并使用 JavaScript 文件(客户端验证)将其显示在 ID 名为“vyas_qrcode”的 div 容器中。 生成二维码的逻辑在js文件(qrcode_js.j
我正在研究使用 Android、iOS 和可能的 Windows Phone 上的浏览器扫描二维码的可用方法。理想的解决方案是拥有一个既可以在移动设备屏幕上又可以在全尺寸计算机屏幕上运行的 Ang
我正在开发 Instagram、Snap Chat 和 Facebook 等社交应用。我需要生成用户配置文件的二维码。我从数据库中隐藏了用户 ID。我的应用程序中有一个扫描仪来扫描二维码。该功能运行良
我有一个用于生成 jpeg 和 png 格式的二维码的代码,但还想在 PHP 中生成带有背景图像的 svg 二维码。我正在使用 qrlib.php 生成 jpeg 和 png 格式。 最佳答案 QRl
我正在使用 primefaces 开发网络应用程序。我正在尝试在网页上显示条形码。除了 QR 码外,所有编码器都显示了。我读到这需要两个 jar 文件 barcode4j: 2.1 qrgen:1.4
我正在寻找一个库或方法来解码二维码(或可能是另一种形式的二维条码)并能够实际确定相机的位置和方向。这似乎应该是可行的,但我不完全确定。 有谁知道最好的路线是什么?或者,如果它甚至可能? 最佳答案 zx
我正在尝试创建一个 QR 码,如果在安装了 Facebook 应用程序的手机上扫描,Facebook 应用程序将直接转到 QR 码中保存的类似页面。我尝试过什么this website已经说过了,但没
我使用python-qrcode和reportlab,我想生成一个二维码并显示它而不是将它保存为图像。 def member_card(request): response = HttpRes
好的,我正在使用这个 Javascript QR 代码生成器:https://github.com/davidshimjs/qrcodejs 开箱即用,您可以通过将其包含在页面上来获得字符串输出。
我在检测二维码在哪里时遇到问题。 我需要在它周围画边框。 我使用 AVMetadataObject 贝塞尔曲线路径,但它不起作用。 请帮助我。 - (void)captureOutput:(AVCap
我正在使用已弃用的 Camera 类。我在 onPreviewFrame(byte[] data, Camera camera) 方法中进行处理。 Zbar 扫描仪没有触发“尝试反向”扫描的选项。我发
1、搭个界面 2、写代码 ? 1
我正在尝试使用 pyqrcode 库生成一个 vCard 二维码,但我不知道该怎么做。 我已经阅读了他们的文档 5 次,其中没有提到 vCard,只提到了 URL,在互联网上,我只能找到关于 wifi
我是一名优秀的程序员,十分优秀!