// SPDX-FileCopyrightText: 2022 Shun Sakai
//
// SPDX-License-Identifier: CC-BY-4.0

= qrtool-encode(1)
// Specify in UTC.
:docdate: 2024-07-02
:doctype: manpage
ifdef::revnumber[:mansource: qrtool {revnumber}]
ifndef::revnumber[:mansource: qrtool]
:manmanual: General Commands Manual
ifndef::site-gen-antora[:includedir: ./include]

== NAME

qrtool-encode - encode input data in a QR code

== SYNOPSIS

*qrtool encode* [_OPTION_]... [_STRING_]

== DESCRIPTION

This command encodes input data in a QR code. By default, the result will be
output to stdout.

*qrtool enc* and *qrtool e* are aliases for this command.

== POSITIONAL ARGUMENTS

_STRING_::

  Input data. If _STRING_ is not specified, data will be read from stdin.
  _STRING_ must be a valid UTF-8 string. Use *--read-from* or read from stdin
  if taking other than a valid UTF-8 string. This positional argument conflicts
  with *--read-from*.

== OPTIONS

*-o*, *--output* _FILE_::

  Output the result to a file.

*-r*, *--read-from* _FILE_::

  Read input data from a file. This option conflicts with _STRING_.

*-s*, *--size* _NUMBER_::

  The module size in pixels. If this option is not specified, the module size
  is 8 when the output format is PNG or SVG, and 1 when the output format is
  UTF-8 string.

*-l*, *--error-correction-level* _LEVEL_::

  Error correction level.

  The possible values are:{blank}:::

    *l*::::

      Level L. 7% of codewords can be restored.

    *m*::::

      Level M. 15% of codewords can be restored. This is the default value.

    *q*::::

      Level Q. 25% of codewords can be restored.

    *h*::::

      Level H. 30% of codewords can be restored.

*--level* _LEVEL_::

  Alias for *-l*, *--error-correction-level*.

*-v*, *--symbol-version* _NUMBER_::

  The version of the symbol. If this option is not specified, the minimum
  version required to store the data will be automatically chosen. For normal
  QR code, _NUMBER_ should be between *1* and *40*. For Micro QR code, _NUMBER_
  should be between *1* and *4*.

*--symversion* _NUMBER_::

  Alias for *-v*, *--symbol-version*.

*-m*, *--margin* _NUMBER_::

  The width of margin. If this option is not specified, the margin will be 4
  for normal QR code and 2 for Micro QR code.

*-t*, *--type* _FORMAT_::

  The format of the output.

  The possible values are:{blank}:::

    *png*::::

      Portable Network Graphics. This outputs 32-bit RGBA PNG image. This is
      the default value.

    *svg*::::

      Scalable Vector Graphics.

    *terminal*::::

      To the terminal as UTF-8 string.

ifdef::optimize-output-png,env-github,site-gen-antora[]
*--optimize-png* [_LEVEL_]::

  Set the optimization level for a PNG image. Lower levels are faster, higher
  levels provide better compression. If _LEVEL_ is not specified, it is assumed
  that the default level 2 is specified.

  The possible values are:{blank}:::

    *0*::::

      Level 0. This value is the minimum optimization level.

    *1*::::

      Level 1.

    *2*::::

      Level 2. This is the default value.

    *3*::::

      Level 3.

    *4*::::

      Level 4.

    *5*::::

      Level 5.

    *6*::::

      Level 6. This value is the maximum optimization level.

    *max*::::

      This value is an alias for the maximum optimization level.
endif::[]

ifdef::optimize-output-png,env-github,site-gen-antora[]
*--zopfli* [_ITERATION_]::

  Use Zopfli to compress PNG image. Perform compression for the number of
  iterations specified by _ITERATION_. If _ITERATION_ is not specified, it is
  assumed that 15 is specified as the number of iterations. This option
  requires *--optimize-png*.
endif::[]

*--mode* _MODE_::

  The mode of the output. If this option is not specified, use the optimal
  encoding. This option requires *--symbol-version*.

  The possible values are:{blank}:::

    *numeric*::::

      All digits.

    *alphanumeric*::::

      Alphanumerics and few symbols.

    *byte*::::

      Arbitrary binary data.

    *kanji*::::

      Shift JIS text.

*--variant* _TYPE_::

  The type of QR code. This option requires *--symbol-version*.

  The possible values are:{blank}:::

    *normal*::::

      Normal QR code. This is the default value.

    *micro*::::

      Micro QR code.

*--foreground* _COLOR_::

  Foreground color. _COLOR_ takes a CSS color string. Colored output is only
  available when the output format is PNG or SVG. Default is black.

*--background* _COLOR_::

  Background color. _COLOR_ takes a CSS color string. Colored output is only
  available when the output format is PNG or SVG. Default is white.

*--verbose*::

  Also print the metadata. It is output to stderr.

*-h*, *--help*::

  Print help message. The short flag (*-h*) will print a condensed help message
  while the long flag (*--help*) will print a detailed help message.

*-V*, *--version*::

  Print version number. The long flag (*--version*) will also print the
  copyright notice, the license notice and where to report bugs.

ifndef::site-gen-antora[include::{includedir}/section-exit-status.adoc[]]
ifdef::site-gen-antora[include::partial$man/man1/include/section-exit-status.adoc[]]

== NOTES

Source repository:{blank}::

  https://github.com/sorairolake/qrtool

QR code.com:{blank}::

  https://www.qrcode.com/

CSS Color Module Level 4:{blank}::

  https://www.w3.org/TR/css-color-4/

== EXAMPLES

Encode the given string in a QR code:{blank}::

  $ *qrtool encode "QR code" > output.png*

Encode the given file and output to the specified image:{blank}::

  $ *qrtool encode -o output.png -r go.mod*

Encode to a SVG image:{blank}::

  $ *qrtool encode -t svg "QR code" > output.svg*

Encode to a Micro QR code:{blank}::

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

Encode with the specified colors:{blank}::

  $ *qrtool encode -o output.png --foreground brown --background lightslategray "QR code"*

ifndef::site-gen-antora[include::{includedir}/section-reporting-bugs.adoc[]]
ifdef::site-gen-antora[include::partial$man/man1/include/section-reporting-bugs.adoc[]]

ifndef::site-gen-antora[include::{includedir}/section-copyright.adoc[]]
ifdef::site-gen-antora[include::partial$man/man1/include/section-copyright.adoc[]]

== SEE ALSO

*oxipng*(1), *qrencode*(1), *qrtool*(1), *qrtool-decode*(1), *qrtool-help*(1)
