npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

qrcode-logo

v1.1.8

Published

qrcode fill with logo

Downloads

12

Readme

#qrcode-logo 基于node-gd图形处理库,用于生成带logo的二维码图片。

#效果

#安装 npm install qrcode-logo --save

##关于node-gd qrcode-logo依赖于node-gd, 若无法正常安装node-gd,请参考node-gd安装文档: https://www.npmjs.com/package/node-gd

#示例 ##生成带logo的二维码

var fs = require('fs'),
    qrCodeLogo = require('qrcode-logo'),

    url = 'https://www.baidu.com/',
    qrcodeImgFilePath = '/Users/test/myworkspace/qr_logo.png',
    logoBuffer = fs.readFileSync('/Users/test/myworkspace/logo.png', {
        encoding: null
    });

qrCodeLogo(url, qrcodeImgFilePath, {
    size: 10,  // 二维码单位块大小
    logo: logoBuffer // logo数据
});

##仅生成二维码图片

var fs = require('fs'),
    qrCodeLogo = require('qrcode-logo'),

    url = 'https://www.baidu.com/',
    qrcodeImgFilePath = '/Users/test/myworkspace/qr.png';

qrCodeLogo(url, qrcodeImgFilePath, function (err, img) {
    console.log(err, img); // img为生成二维码图片信息(包含高度、宽度等信息)
});

##生成带logo(带圆角边框)且带底部文本的二维码图片

var fs = require('fs'),
    qrCodeLogo = require('qrcode-logo'),

    url = 'https://www.baidu.com/',
    qrcodeImgFilePath = '/Users/test/myworkspace/qr_logo.png',
    logoBuffer = fs.readFileSync('/Users/test/myworkspace/logo.png', {
        encoding: null
    });

qrCodeLogo(url, qrcodeImgFilePath, {
    size: 10,  // 二维码单位块大小
    margin: 2,
    logo: logoBuffer, // logo数据
    logoBorder: {   // border边框配置
        width: 4,
        color: 0xcccfff
    },
    bottomText: {  // 底部文本框配置
        text: 'A12',
        bgColor: 0xeeefff
    }
});

#API

##调用方式 qrcode(text, outpath, qrOpts, cb) 或 qrcode(text, outpath, cb)

##参数 ###text(必填) (String)生成二维码的文本、url。

###outpath(必填) (String)生成的二维码图片的文件路径。

###cb(可选) 生成二维码图片文件回调方法: function (err, img) { // err 错误认息 // img 生成的二维码图片信息(高度、宽度、色值等) }

###qrOpts.size(可选) (Number)二维码图片中二维码每块大小,默认值为10(pixel)。(二维码版本区间为version1 ~ version40, 每个版本对应块数不同。该插件生成的二维码基本由41块组成,即整个二维码图片宽度为:41 * qrOpts.size + qrOpts.margin * 2 * qrOpts.size)

###qrOpts.margin(可选) (Number) 二维码周边的留白的块数,默认4(注意,此处不是真实的像素大小)。

###qrOpts.parse_url(可选) (Boolean)是否优化处理text为url的情况, 默认为true

###qrOpts.logo(可选) (Buffer) logo图片的buffer数据(目前仅支持png、jpeg格式图片)。 logo图片会设置额外背景色为白色(若logo为透明背景,则背景色会改为白色)

###qrOpts.logoBorder.width(可选) (Number)边框大小(pixel)。值为空时,不作边框渲染。

###qrOpts.logoBorder.radius(可选) (Number)logo圆角大小, 默认值为10(pixel)。

###qrOpts.logoBorder.color(可选) (Number)边框颜色,使用十六进制颜色值.默认值为0xffffff.

###qrOpts.bottomText.height(可选) (Number)文本框高度。默认值45。

###qrOpts.bottomText.align(可选) (String) 文本对齐方式。默认居中对齐。

###qrOpts.bottomText.size(可选) (Number)文本字体大小。默认值25。

###qrOpts.bottomText.angle(可选) (Number) 文本旋转角度,默认0(0~360)。

###qrOpts.bottomText.color(可选) (Number) 文本颜色,使用十六进制颜色值。默认值0x000000。

###qrOpts.bottomText.bgColor(可选) (Number) 文本框背景颜色,使用十六进制颜色值。默认值0xffffff。

###qrOpts.bottomText.fontFilePath(可选) (String) 文本字体文件路径。仅支持ttf字体文件。默认为楷体(gb-2312).