Skip to main content

A 100% standalone Barcode Python API for Processing Barcode Files

Project description

Free Python Barcode Generation & Recognition API

Product PageDocumentationExamplesForumCustomized Demo

Foo

Free Spire.Barcode for Python is a versatile barcode generation and recognition library. It provides developers with an intuitive API to integrate barcode functionality into their Python programs. With support for various barcode formats, including 1D and 2D barcodes, it simplifies tasks of generating, reading, and scanning 1D and 2D barcodes.

Free Spire.Barcode for Python is a community edition of ** Spire.Barcode for Python** which supports to work with many more barcode types. If free Spire.Barcode does not fulfill your needs, please upgrade to the paid version of Spire.Barcode for Python.

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 Free 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:

  • CODABAR
  • CODE_11
  • CODE_39
  • CODE_39_EXTENDED
  • CODE_93
  • CODE_93_EXTENDED
  • CODE_128
  • EAN_8
  • EAN_13
  • EAN_128
  • EAN_14
  • SCC_14
  • QR_CODE
  • POST_NET

Barcode Types Only Supported on Paid Versions of Spire.Barcode for Python:

  • CODE_25
  • INTERLEAVED_25
  • SSCC_18
  • ITF_14
  • ITF_6
  • UPCA
  • UPCE
  • 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
  • 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 PageDocumentationExamplesForumCustomized 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

Spire.Barcode.Free-7.2.0-py3-none-win_amd64.whl (12.4 MB view details)

Uploaded Python 3Windows x86-64

Spire.Barcode.Free-7.2.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.Free-7.2.0-py3-none-win_amd64.whl.

File metadata

File hashes

Hashes for Spire.Barcode.Free-7.2.0-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 c872362401963fdc02f277edbd93a6aca53e4fa4a479d0bdcc11bc0de36cf757
MD5 751c29607662bb4a7346fbf2149a87fb
BLAKE2b-256 358fb023d6596ea7a825d81536b3466fb1f5a3e6f0d7508c0fca4600da9dbcdc

See more details on using hashes here.

File details

Details for the file Spire.Barcode.Free-7.2.0-py3-none-manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for Spire.Barcode.Free-7.2.0-py3-none-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 32df8318ac9a1c6f7521dceeccf6312b6a63b645700b74f6f5874fa2bcbf839e
MD5 b976b5b96562eb1eeb4788957cb00a26
BLAKE2b-256 f6f83f9d069864ea766ad44e82e5e2a10b381df57ed5e8ca01c0e7b82948c867

See more details on using hashes here.

File details

Details for the file Spire.Barcode.Free-7.2.0-py3-none-macosx_10_7_universal.whl.

File metadata

File hashes

Hashes for Spire.Barcode.Free-7.2.0-py3-none-macosx_10_7_universal.whl
Algorithm Hash digest
SHA256 3645dedcdb3ef32d148f4b4de2f36b18418cac7c99029f77d06b10d305a7af46
MD5 f58e3f470a6451066ef4b9489291e0ac
BLAKE2b-256 9f718484d911a1e82d1a46894969a487023713b333585c222599e5bfd06d0bd3

See more details on using hashes here.

Supported by

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