All Projects → HerbLuo → Qr Code With Logo

HerbLuo / Qr Code With Logo

带头像(logo)的二维码(qrcode)生成工具,无jQuery依赖,自由调整大小

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Qr Code With Logo

Instascan
HTML5 QR code scanner using your webcam
Stars: ✭ 2,657 (+2454.81%)
Mutual labels:  qr-code, qrcode, html5
Qrcode
QR-code encoder/decoder (no image recognition)
Stars: ✭ 34 (-67.31%)
Mutual labels:  qr-code, qrcode
Ruby Gem Downloads Badge
Clean and simple gem downloads count badge, courtesy of http://shields.io/. You can checkout the application directly at the following URL:
Stars: ✭ 29 (-72.12%)
Mutual labels:  image, logo
Ngx Kjua
Angular QR-Code generator component using kjua.
Stars: ✭ 51 (-50.96%)
Mutual labels:  qr-code, qrcode
React Qr Reader
React component for reading QR codes from webcam.
Stars: ✭ 716 (+588.46%)
Mutual labels:  qr-code, qrcode
Vue Qrcode
QR code component for Vue.js
Stars: ✭ 724 (+596.15%)
Mutual labels:  qr-code, qrcode
Nodejs Socketio Chat App
MEAN Stack & Socket.IO Real-time Chat App | A MEAN stack based Real Time chat application
Stars: ✭ 45 (-56.73%)
Mutual labels:  npm, html5
React Native Blurhash
🖼️ A library to show colorful blurry placeholders while your content loads.
Stars: ✭ 430 (+313.46%)
Mutual labels:  image, npm
Qr Ascii
A small library to generate QR codes with ascii
Stars: ✭ 63 (-39.42%)
Mutual labels:  qr-code, qrcode
React Image Timeline
📆 An image-centric timeline component for React.js
Stars: ✭ 77 (-25.96%)
Mutual labels:  image, npm
Vue Qrcode Reader
A set of Vue.js components for detecting and decoding QR codes.
Stars: ✭ 1,240 (+1092.31%)
Mutual labels:  qr-code, qrcode
Php Qrcode
A QR Code generator for PHP7.4+
Stars: ✭ 685 (+558.65%)
Mutual labels:  qr-code, qrcode
Jspaint
🎨 Classic MS Paint, REVIVED + ✨Extras
Stars: ✭ 5,972 (+5642.31%)
Mutual labels:  image, html5
Privatekeyvault
Make Instructions: Airgapped raspberry pi computer for working with blockchains featuring LUKS full disk encryption and using qr-codes to pass encrypted files and offline transaction instructions across the airgap.
Stars: ✭ 29 (-72.12%)
Mutual labels:  qr-code, qrcode
React Native Vision Camera
📸 The Camera library that sees the vision.
Stars: ✭ 443 (+325.96%)
Mutual labels:  qr-code, qrcode
Qr Code Scanner
📠 A simple, fast and useful progressive web application
Stars: ✭ 982 (+844.23%)
Mutual labels:  qr-code, qrcode
Angular File Uploader
Angular file uploader is an Angular 2/4/5/6/7/8/9/10 + file uploader module with Real-Time Progress Bar, Responsive design, Angular Universal Compatibility, localization and multiple themes which includes Drag and Drop and much more.
Stars: ✭ 92 (-11.54%)
Mutual labels:  image, npm
Qr Code
Web Component for generating QR codes
Stars: ✭ 425 (+308.65%)
Mutual labels:  qr-code, qrcode
Html5 Qrcode
A cross platform HTML5 QR code reader
Stars: ✭ 428 (+311.54%)
Mutual labels:  qrcode, html5
Qrcode
💮 amazing QRCode generator in Python (supporting animated gif) - Python amazing 二维码生成器(支持 gif 动态图片二维码)
Stars: ✭ 8,613 (+8181.73%)
Mutual labels:  qrcode, qr-code

带Logo的QR Code(二维码)生成工具

注:当前版本的node-qrcode已支持调整大小,大家可以直接往生成的二维码上覆盖Logo即可。

node-qrcode的再封装,支持Logo,支持调整大小

Example Picture


一、支持列表

  • 支持npm方式引用,
  • 支持直接<script>方式引用
  • 支持vue
  • 支持react
  • 支持IE9+

二、使用方法:

1.npm:
npm i --save qr-code-with-logo
import QrCodeWithLogo from 'qr-code-with-logo'
import LocalImage from './Avatar.png'

const myCanvas = document.createElement('canvas')
document.body.appendChild(myCanvas)

QrCodeWithLogo.toCanvas({
  canvas: myCanvas,
  content: 'https://cdn.blog.cloudself.cn',
  width: 380,
  logo: {
    src: LocalImage,
    // src: 'https://cdn.blog.cloudself.cn/images/avatar.png',
    radius: 8
  }
})

更多示例代码参见此处

2.<script>标签形式, 点此处下载该文件
<canvas id="canvas"></canvas>

<!-- 有对 promise的依赖,如不考虑兼容,可尝试删除该依赖 -->
<script src="//www.promisejs.org/polyfills/promise-6.1.0.js"></script>
<!-- 将上方下载的文件放置于js文件夹下 -->
<script src="./js/qr-code-with-logo.browser.min.js"></script>
<script>
  QrCodeWithLogo.toCanvas({
    canvas: document.getElementById('canvas'), // 换成你的canvas节点
    content: 'https://cdn.blog.cloudself.cn/',
    width: 380,
    logo: {
      src: 'https://cdn.blog.cloudself.cn/images/avatar.png',
    }
  })
</script>

三、API

目前只能将QrCode转换成Canvas输出

QrCodeWithLogo.toCanvas({/* CanvasOptions */})
  .then(_ => console.log('success'))

或者将QrCode转换成Image输出,不过它也是基于Canvas的

QrCodeWithLogo.toImage({/* ImageOptions */})
  .then(_ => console.log('success'))

其中toCanvas的参数为一个对象,它包含特有的属性 CanvasOptions,以及公共的属性 BaseOptions

toImage的参数同为一个对象,它包含特有的属性 ImageOptions,以及公共的属性 BaseOptions

1. CanvasOptions

canvas

Type: DOMElement

配置dom节点,只允许为<canvas>,不可为<div>

2. ImageOptions

image

Type: DOMElement

可选的,配置dom节点,只允许为<image>,不可为<div>

download

Type: boolean
Default: false

可选,为true的时候,以文件的形式输出

downloadName

Type: string
Default: qr-code.png

可选,下载时,图片的文件名

3. BaseOptions

content

Type: string

二维码的内容

width

Type: number
Default: 0

可选,二维码的宽度(默认会随二维码内容的长度自动调整大小)

logo

Type: string | Logo Logo为js对象

可选,可以为字符串(代表src),也可以为对象,其中Logo对象的具体属性有

  • src

    Type: string

    Logo地址,(可以是远程的,也可以是本地的base64图片)当存在跨域时,该二维码(canvas)无法 toDataURL,亦无法使用JS转换成 image

  • crossOrigin

    Type: string
    Default: 'Anonymous'

    可选,一般不必修改,默认为 'Anonymous'

  • logoRadius

    Type: number

    可选,logo的 radius,如果配置了它,存在跨域时,Logo可能会加载失败

  • logoSize

    Type: number Default: 0.15

    可选,logo的 大小,范围在 0-1之间,代表logo在二维码中的比例 与 borderSize 共同组成了 logo的大小,他们的关系相当于标准盒模型

  • borderRadius

    Type: number Default: 8

    可选,logo的边框的 radius

  • borderSize

    Type: number Default: 0.05

    可选,border的 大小,范围在 0-1之间,代表border在二维码中的比例 与 logoSize 共同组成了 logo的大小,他们的关系相当于标准盒模型

  • bgColor

    Alias: borderColor
    Type: string
    Default: '#ffffff'

    可选,logo的背景色,可以为 'transparent'(透明)

nodeQrCodeOptions

Type: NodeQrCodeOptions node-qrcode的参数,参见

可选,本项目基于node-qrcode,并对其配置参数兼容,其中常用参数的有

  • margin

    Type: number
    Default: 4

    可选,二维码的外边框大小,单位是单块二维码的像素

  • errorCorrectionLevel

    Type: 'L' | 'M' | 'Q' | 'H'

    二维码容错率,
    默认情况下,
    当二维码文本长度大余36字符,采用 M(中),
    小于16,采用 H(高),
    否则采用Q

  • color.dark

    Type: string
    Default: '#000000ff' RGBA, IE下仅支持RGB

    可选,二维码的前景色

  • color.light

    Type: string
    Default: '#000000ff'

    可选,二维码的背景色


四:其它


  1. 如果控制台报错 “Promise”未定义
    添加如下代码即可
    import Promise from 'es6-promise'
    if (typeof window.Promise === 'undefined') {
      window.Promise = Promise
    }
    
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].