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-poster

v0.1.3

Published

创建带二维码的海报,在图片上指定位置创建二维码

Downloads

17

Readme

qrcode-poster

创建带二维码的海报,在图片指定位置创建二维码
gm
qrcode

安装依赖

首先需要安装 gm 模块依赖 graphicsmagick or imagemagick

# Centos
yum install GraphicsMagick -y

# Mac os x
brew install graphicsmagick

安装使用

npm i qrcode-poster
// @filepath /example/index.js

const path = require('path')
const Poster = require('qrcode-poster')

/**
 * options默认值参考「默认配置」
 */
const poster = new Poster({
    qrcode: {
        color: {
            dark: '#cb3837'
        },
        dist() {
            return path.join(__dirname, '../output/qrcode.png')
        }
    },
    index: 0,
    templates: [
        {
            x: 567,
            y: 32,
            qrWidth: 200,
            qrHeight: 200,
            filepath: path.join(__dirname, '1.jpg')
        },
        {
            x: 480,
            y: 822,
            qrWidth: 260,
            qrHeight: 260,
            filepath: path.join(__dirname, '1.jpg')
        },
    ],
    dist() {
        return path.join(__dirname, '../output/poster.jpg')
    }
})

// poster.toFile('qrcode')
poster.toFile('qrcode', { index: 1 }).then(console.log)

默认配置 Options

module.exports = {
    qrcode: { // 详情可参考qrcode模块toFile.options配置
        scale: 10, // 像素放大倍数
        margin: 1, // 二维码外间距
        color: {   // 二维码颜色配置
            dark: '#000',
            light: '#fff'
        },
        dist() { // 二维码默认生成路径,默认生成在系统临时目录
            return path.join(os.tmpDir(), sid.generate())
        }
    },
    index: 0, // 当前生效海报模板的索引
    templates: [
        {
            x: 567, // 二维码在海报模板上的横向位置 x轴坐标
            y: 32,  // 二维码在海报模板上的纵向位置 y轴坐标
            qrWidth: 200,  // 二维码宽度
            qrHeight: 200, // 二维码高度,默认为二维码宽度
            filepath: path.join(__dirname, '../example/1.jpg') // 海报模板位置
        }
    ],
    dist() { // 海报默认生成路径,默认生成在系统临时目录
        return path.join(os.tmpDir(), sid.generate())
    }
}

示例演示

git clone https://github.com/gavinning/qrcode-poster.git
cd qrcode-poster && npm i
node example # or DEBUG=* node example

Preview