Skip to main content

A 100% standalone Barcode Python API for Processing Barcode Files

Project description

Python Barcode Generation & Recognition API

Product PageDocumentationExamplesForumTemporary LicenseCustomized Demo

Foo

Spire.Barcode for Python is a powerful and flexible Python API for barcode generation and recognition. It is designed to cater to the needs of developers to integrate barcode processing capabilities into their Python applications.

With support for various barcode formats, including 1D and 2D barcodes, this library streamlines the procedures involved in generating, reading, and scanning barcodes, making it suitable for a variety of use cases, such as inventory management, product labeling, document tracking, and more.

Key Features

  • Barcode Generation: Easily generate barcodes in different formats, such as EAN-13, Code 128, and QR Code.
  • Barcode Recognition: Accurately detect and decode barcodes, regardless of their orientation or position within an image.
  • Image Processing: High-quality barcode rendering on a variety of image formats, including Bitmap, JPG, PNG, EMF, TIFF, GIF, and WMF.
  • Customization Options: Customize barcode images by setting parameters like border style, color, width, and margins. Rotate barcodes at any angle and allow insertion of an image in the center.
  • Easy Integration: Seamlessly integrate Spire.Barcode for Python into your application to perform bracode generation & recognition functions with a few lines of code, saving development time and effort.

Supported Barcode Types:

  • CODE_25
  • CODABAR
  • CODE_11
  • INTERLEAVED_25
  • CODE_39
  • CODE_39_EXTENDED
  • CODE_93
  • CODE_93_EXTENDED
  • CODE_128
  • EAN_8
  • EAN_13
  • EAN_128
  • EAN_14
  • SCC_14
  • SSCC_18
  • ITF_14
  • ITF_6
  • UPCA
  • UPCE
  • POST_NET
  • SINGAPORE_POST_4_STATE
  • PLANET
  • MSI
  • RSS_14
  • RSS_14_TRUNCATED
  • RSS_LIMITED
  • RSS_EXPANDED
  • USPS
  • SWISS_POST_PARCEL
  • PZN
  • OPC
  • DEUTSCHE_POST_IDENTCODE
  • DEUTSCHE_POST_LEITCODE
  • ROYAL_MAIL_4_STATE
  • DATA_MATRIX
  • QR_CODE
  • PDF_417
  • PDF_417_MACRO

Generate a Code-128 Barcode in Python

from spire.barcode import *

# Function to write all bytes to a file
def WriteAllBytes(fname: str, data):
    with open(fname, "wb") as fp:
        fp.write(data)
    fp.close()

# Create an instance of BarcodeSettings
barcodeSettings = BarcodeSettings()

# Set the type of barcode to Code128
barcodeSettings.Type = BarCodeType.Code128

# Set the data for the barcode
barcodeSettings.Data = "12345"

# Set the Code128SetMode type of barcode to Auto
barcodeSettings.Code128SetMode = Code128SetMode.Auto

# Create an instance of BarCodeGenerator with the specified settings
barCodeGenerator = BarCodeGenerator(barcodeSettings)

# Generate the image for the barcode
barcodeimage = barCodeGenerator.GenerateImage()

# Write the PNG image to disk
WriteAllBytes("Code128.png", barcodeimage)

Generate QR Code with a Logo Image in Python

from spire.barcode import *

# Function to write all bytes to a file
def WriteAllBytes(fname:str,data):
    fp = open(fname,"wb")
    fp.write(data)
    fp.close()

# Initialize a new instance of BarcodeSettings
barcodeSettings = BarcodeSettings()

# Set the barcode type to QR Code
barcodeSettings.Type = BarCodeType.QRCode

# Specify the background color as WhiteSmoke
barcodeSettings.BackColor = Color.get_WhiteSmoke()

# Set the QR Code data mode to Byte
barcodeSettings.QRCodeDataMode = QRCodeDataMode.Byte

# Choose the error correction level (ECL) as M
barcodeSettings.QRCodeECL = QRCodeECL.M

# Set whether to display text at the bottom of the barcode
barcodeSettings.ShowTextOnBottom = True

# Define the horizontal offset (not sure what this does exactly)
barcodeSettings.X = 3

# Store the data to be encoded in variables and set it on the settings
data = "ABC 123456789"
barcodeSettings.Data2D = data
barcodeSettings.Data = data

# Add a logo image to the QR Code
barcodeSettings.SetQRCodeLogoImage("data/Logo.png")

# Create a new instance of BarCodeGenerator using the provided settings
barCodeGenerator = BarCodeGenerator(barcodeSettings)

# Generate the barcode image
barcodeimage = barCodeGenerator.GenerateImage()

# Write the resulting image to a file
WriteAllBytes("AddLogoImageQRCode.png", barcodeimage)

Scan a Barcode Image in Python

from spire.barcode import *

# Function to append all lines of text to a file
def AppendAllText(fname: str, text: List[str]):
    # Open the file in write mode
    fp = open(fname, "w")

    # Iterate over each line of text
    for s in text:
        # Write the line to the file
        fp.write(s)

    # Close the file handle
    fp.close()

# Use BarcodeScanner class to scan a file using the specified barcode type 
strCode = BarcodeScanner.ScanFileWithBarCodeType("data/QRCode.png",BarCodeType.QRCode)

# Append all scanned strings to a text file
AppendAllText("ScanFileWithBarCodeType.txt",strCode)

Product PageDocumentationExamplesForumTemporary LicenseCustomized Demo

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

spire_barcode-7.3.0-py3-none-win_amd64.whl (12.5 MB view details)

Uploaded Python 3Windows x86-64

spire_barcode-7.3.0-py3-none-manylinux_2_31_x86_64.whl (18.9 MB view details)

Uploaded Python 3manylinux: glibc 2.31+ x86-64

spire_barcode-7.3.0-py3-none-manylinux2014_aarch64.whl (11.7 MB view details)

Uploaded Python 3

spire_barcode-7.3.0-py3-none-macosx_11_0_arm64.whl (15.2 MB view details)

Uploaded Python 3macOS 11.0+ ARM64

spire_barcode-7.3.0-py3-none-macosx_10_7_universal.whl (24.2 MB view details)

Uploaded Python 3macOS 10.7+ universal (x86-64, i386, PPC64, PPC)

File details

Details for the file spire_barcode-7.3.0-py3-none-win_amd64.whl.

File metadata

File hashes

Hashes for spire_barcode-7.3.0-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 3319eb3d1bdfc6c664599b6d9ae9f80571a113047b26c7682e8b6ff6ee6e5820
MD5 821e0ee8c215d835a21ea85fffb7303b
BLAKE2b-256 02a9acf7f6f234f585874c824078f8dc1328362f4889f83c8ec0bbf8ae6dffd3

See more details on using hashes here.

File details

Details for the file spire_barcode-7.3.0-py3-none-manylinux_2_31_x86_64.whl.

File metadata

File hashes

Hashes for spire_barcode-7.3.0-py3-none-manylinux_2_31_x86_64.whl
Algorithm Hash digest
SHA256 5aefce7c398bc1610bcc3ac5f9780f89b1113aa5515f1409cf433f2e8d7b0332
MD5 56e9f9853c05c163570e1344dadbae40
BLAKE2b-256 72ebf717502b5b9fc931c65719adb5afeffbf1dafbeae556f81d0c7ac20ac944

See more details on using hashes here.

File details

Details for the file spire_barcode-7.3.0-py3-none-manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for spire_barcode-7.3.0-py3-none-manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 43f3f8a4868f83cc0018399110a877d915d0b361459bd8d07e06244afc55247b
MD5 d78729df10222eb79e02099ae872a205
BLAKE2b-256 f1f291a4d8ce581baa8eeba6f81da35bc0bb9ef87bdd01824da3dce1d2b31e25

See more details on using hashes here.

File details

Details for the file spire_barcode-7.3.0-py3-none-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for spire_barcode-7.3.0-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 97121006fbf34b10842c9e23280994321ec3f202132df5d181b30c5db39ed957
MD5 9f19018c83ee7165c752d1255cd75854
BLAKE2b-256 cd8b5d12c5ad008610aeebf3cf0313a5a47bd32654909d18fd61905572baf8e4

See more details on using hashes here.

File details

Details for the file spire_barcode-7.3.0-py3-none-macosx_10_7_universal.whl.

File metadata

File hashes

Hashes for spire_barcode-7.3.0-py3-none-macosx_10_7_universal.whl
Algorithm Hash digest
SHA256 c472ce278c07cb0856c2a3f86fefa60356e9d9785f4143c653ed9131387a4b14
MD5 bf6e5920bb19620f265d62ceb4caf336
BLAKE2b-256 9055e6a6f42c804fce7f364f5da5e711404bfa2a23c93d9bb9deeb4b137e9cc0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page