Giter VIP home page Giter VIP logo

qrtool's Introduction

qrtool

CI Version MSRV License

qrtool is a command-line utility for encoding or decoding QR code.

Screenshot of qrtool

Installation

From source

cargo install qrtool

Via a package manager

Packaging status

OS Package manager Command
Any Homebrew brew install sorairolake/tap/qrtool
Any Nix nix-env -iA nixpkgs.qrtool
Arch Linux Pacman pacman -S qrtool
openSUSE Zypper zypper install qrtool

From binaries

The release page contains pre-built binaries for Linux, macOS and Windows.

How to build

Please see BUILD.adoc.

Usage

Basic usage

Encode a string in a QR code:

qrtool encode "QR code" > output.png

Generate this image:

Output

Decode a QR code from this image:

qrtool decode output.png

Output:

QR code

SVG generation

Use -t option to change the format of the generated image. The format is png (default), svg or terminal (to the terminal as UTF-8 string).

qrtool encode -o output.svg -t svg "QR code"

Generate this image:

Output

Micro QR code generation

Use --variant option to change the variant of the generated QR code. The variant is normal (default) or micro (Micro QR code).

qrtool encode -v 3 --variant micro "QR code" > output.png

Generate this image:

Output

Colored output

Use --foreground and --background options to change the foreground and background colors of the generated image. These options takes a CSS color string such as brown, #a52a2a or rgb(165 42 42). The default foreground color is black and the background color is white of CSS's named colors.

qrtool encode --foreground brown --background lightslategray "QR code" > output.png

Generate this image:

Output

Supported input image formats

qrtool decode supports decoding a QR code from the following image formats:

To support decoding from SVG image, the decode-from-svg feature must be enabled at compile time. Note that the SVG image is rasterized before scanning.

Image formats other than PNG can be disabled by disabling the default feature, and can be enabled individually.

Use -t option to specify the image format. If this option is not specified, the image format is determined based on the extension or the magic number.

Input this WebP image:

Input

Decode a QR code from the WebP image:

qrtool decode input.webp
# or
qrtool decode -t webp input.webp

Output:

QR code

Generate shell completion

--generate-completion option generates shell completions to stdout.

The following shells are supported:

  • bash
  • elvish
  • fish
  • nushell
  • powershell
  • zsh

Example:

qrtool --generate-completion bash > qrtool.bash

Integration with other programs

Both qrtool encode and qrtool decode can read from stdin and output to stdout.

Optimize the output image

The image output by qrtool encode is not optimized. For example, a PNG image is always output as the 32-bit RGBA format. If you want to reduce the image size or optimize the image, use an optimizer such as oxipng or svgcleaner.

Optimize the output PNG image:

qrtool encode "QR code" | oxipng - > output.png

Optimize the output SVG image:

qrtool encode -t svg "QR code" | svgcleaner -c - > output.svg

Reading and writing unsupported image formats

If you want to save the encoded image in an image format other than PNG or SVG, or decode an image in an unsupported image format, convert it using a converter such as ImageMagick.

Read Cargo.toml from stdin and save the encoded result as a JPEG XL image:

cat Cargo.toml | qrtool encode | magick png:- output.jxl

Decode this image and print the result using bat:

magick output.jxl png:- | qrtool decode | bat -l toml

Command-line options

Please see the following:

Changelog

Please see CHANGELOG.adoc.

Contributing

Please see CONTRIBUTING.adoc.

Acknowledgment

This program is inspired by qrencode and zbarimg.

License

Copyright © 2022–2024 Shun Sakai and other contributors (see AUTHORS.adoc)

  1. This program is distributed under the terms of either the Apache License 2.0 or the MIT License.
  2. Some files are distributed under the terms of the Creative Commons Attribution 4.0 International Public License.

This project is compliant with version 3.0 of the REUSE Specification. See copyright notices of individual files for more details on copyright and licensing information.

Footnotes

  1. CUR is also supported.

  2. SVGZ is also supported.

qrtool's People

Contributors

dependabot[bot] avatar orhun avatar sorairolake avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

qrtool's Issues

Add option to specify module size in pixels

Checklist

  • I have searched the existing issues

Summary

This is a similar purpose to --size of qrencode.

Additional context

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct

Supports installation using Homebrew

Checklist

  • I have searched the existing issues

Summary

Makes installation easier on macOS.

Additional context

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.