Scripts2026年7月23日·1 分钟阅读

ZXing — Open-Source Barcode and QR Code Processing Library

A multi-format 1D/2D barcode image processing library implemented in Java, with ports to other languages and a standalone Android barcode scanner app.

Agent 就绪

Agent 可直接安装

这个资产可安装;Agent 先选择当前运行时、检查安装计划,再运行匹配命令。

Native · 98/100策略:允许
Agent 入口
任意 MCP/CLI Agent
类型
Skill
安装
Single
信任
信任等级:Established
入口
ZXing
直接安装命令
npx -y tokrepo@latest install 5942b2b3-86d7-11f1-9bc6-00163e2b0d79 --target codex

先 dry-run 确认安装计划,再运行此命令。

Introduction

ZXing (pronounced "zebra crossing") is the most widely used open-source barcode scanning library in the Java ecosystem. Originally created at Google, it supports decoding and encoding of over a dozen barcode formats and serves as the foundation for barcode scanning in countless Android apps and server-side processing pipelines.

What ZXing Does

  • Decodes 1D barcodes including UPC-A, UPC-E, EAN-8, EAN-13, Code 39, Code 128, and ITF
  • Decodes 2D barcodes including QR Code, Data Matrix, Aztec, and PDF 417
  • Generates barcode images programmatically for embedding in apps or documents
  • Provides a standalone Android scanner app with camera preview and auto-focus
  • Offers a pure Java core with no native dependencies for cross-platform use

Architecture Overview

The core library is pure Java and processes barcode recognition through a pipeline of image binarization, format-specific detector, and decoder stages. The Reader interface abstracts format detection, allowing the MultiFormatReader to try multiple formats in priority order. The Android integration layer handles camera preview frames and feeds them to the core decoder on a background thread.

Setup & Configuration

  • Add the zxing-core dependency for server-side or pure Java barcode processing
  • Use zxing-android-embedded for an integrated Android scanner with camera preview
  • Configure supported barcode formats via IntentIntegrator or DecodeHintType map
  • Adjust camera resolution and autofocus settings for scanning distance requirements
  • Use the BarcodeEncoder class for generating QR code or barcode bitmap images

Key Features

  • Supports 15+ barcode formats covering retail, logistics, and identification use cases
  • Pure Java implementation with no JNI or native code for maximum portability
  • Battle-tested in production across thousands of apps over more than a decade
  • Barcode generation API for creating scannable images from arbitrary data
  • Modular design separating core decoding from platform-specific camera integration

Comparison with Similar Tools

  • ML Kit Barcode Scanning — Google's ML-based scanner with better angle tolerance, but requires Google Play Services
  • Dynamsoft Barcode Reader — commercial SDK with higher accuracy on damaged barcodes; ZXing is free and open source
  • CameraX MLKit — Jetpack integration for barcode scanning; depends on ML Kit under the hood
  • Scandit — enterprise-grade commercial scanner; ZXing provides a solid free alternative for standard use cases
  • ZBar — C-based scanner with Python bindings; ZXing is Java-native and better suited for Android and JVM projects

FAQ

Q: Is ZXing still actively maintained? A: The core library is stable and receives occasional updates. Community forks like zxing-android-embedded provide active Android integration maintenance.

Q: Can I use ZXing for server-side barcode processing? A: Yes. The core module is pure Java and works on any JVM without Android dependencies.

Q: How do I improve scan speed for QR codes? A: Restrict the supported formats to only QR_CODE via DecodeHintType, which avoids trying all format decoders.

Q: Does it support scanning from image files? A: Yes. Pass a BufferedImage or luminance source to the MultiFormatReader to decode barcodes from static images.

Sources

讨论

登录后参与讨论。
还没有评论,来写第一条吧。

相关资产