generates a barcode image of "string" in the specified format.


attempts to generate a barcode image of the specified size.


  • BarcodeImage always returns a binary image.
  • Possible values for size include:
  • widthapproximate width, height is computed automatically
    {width,height}approximate width and height
  • If the specified size does not provide sufficient resolution for generating the barcode, an image of a larger size is generated. »
  • The following 1D barcode formats can be used for format:
  • "UPC"UPC-A12 numerical digits
    "EAN8"EAN-88 numerical digits
    "EAN13"EAN-1313 numerical digits
    "Code39"Code 39up to 80 characters of uppercase letters, numeric digits, special characters -, ., $, /, +, %, and space
    "Code128"Code 128up to 80 ASCII characters
    "ITF"ITFup to 80 numerical digits of an even length
    "Codabar"Codabarnumerical digits and special characters :, /, +, .
  • The following 2D barcode formats can be used for format:
  • "Aztec"Aztec code3000 ASCII or 3748 numeric
    "DataMatrix"Data Matrix code2335 ASCII or 3116 numeric
    "QR"QR (error correction "L")2953 ASCII, 7089 numeric or 4296 alphanumeric
    {"QR",lev}QR (error correction lev)ASCII characters (less storage for higher levels)
    "PDF417"PDF417 (error correction 2)up to 1781 ASCII characters
  • The error correction level lev can be "L", "M", "Q", or "H".


open allclose all

Basic Examples  (3)

Generate a UPC barcode:

Generate a QR barcode:

Generate a QR barcode of the specified size:

Scope  (12)

Generate a UPC barcode from a 12-digit numerical code:

With an 11-digit code, the checksum is automatically computed:

Generate an EAN-8 barcode:

With a 7-digit code, the checksum is automatically computed:

Generate an EAN-13 barcode from a 13-digit numerical code:

With a 12-digit code, the checksum is automatically computed:

Generate a Code 39 barcode from numerical digits:

Generate a Code 39 barcode from an alphanumeric string:

Generate a Code 128 barcode:

Generate an ITF barcode:

Generate a Codabar barcode:

Generate an Aztec code:

Generate a Data Matrix code:

Generate a QR code:

Generate a QR code with "M" error correction level:

Generate a PDF 417 code:

Applications  (3)

Encode a URL in a Code 39 barcode:

Encode graphics in a QR code:

Decode and evaluate the expression:

Add a QR code to a plot as an visual watermark:

Decode the QR code:

Properties & Relations  (4)

Use BarcodeRecognize to convert a barcode image to a string:

Compute the UPC-A checksum from an 11-digit code:

The checksum is automatically computed if not provided and used as the 12th digit:

Compute the EAN-8 checksum for a 7-digit code:

BarcodeImage automatically computes the checksum:

Compute the EAN-13 checksum for a 12-digit code:

BarcodeImage automatically computes the checksum:

Possible Issues  (5)

In generating 1D barcode images, the width specification might be ignored:

The resulting width is the minimum required to represent the barcode image:

In generating 2D barcode images, the size specification might be ignored:

Different formats have requirements for the input string, including length and supported characters:

For formats with a checksum character, an incorrect checksum is replaced with the correct value:

PDF417 barcodes can only be generated with error correction level of 2:

Neat Examples  (1)

Create two barcode images and color them based on the dominant colors of the US flag:

Compose barcode images to create a barcoded US flag:

Introduced in 2014