PixQR

Qr Code Error Correction

Distance Test

Definition: A reliability term explaining Distance Test and how QR codes remain readable when damaged or altered.

Overview

Distance Test is a reliability metric used in QR code generation and decoding systems to determine how much physical damage or alteration a QR code can sustain while still being accurately scanned and interpreted. It is directly tied to the error correction capabilities of QR codes, which allow them to remain functional even when partially obscured, printed poorly, or exposed to environmental degradation.

For developers working with PixQR, understanding Distance Test is essential when designing systems that must maintain reliable scanning across various physical and digital conditions. It is especially important in environments where QR codes may be exposed to wear, lighting variations, or partial occlusion, such as in printed materials, outdoor signage, or industrial applications.

Distance Test developer glossary illustration

Why It Matters

In production systems, the Distance Test directly impacts user experience, operational efficiency, and brand safety. A QR code that fails to scan due to insufficient error correction can lead to lost conversions, frustrated users, and degraded trust in digital services. For PixQR, ensuring robust Distance Test compliance is part of the platform's promise to deliver reliable and secure scanning experiences.

From a security perspective, a weak Distance Test can expose systems to fraud or tampering, as attackers may attempt to alter QR codes to redirect users to malicious sites. A strong Distance Test ensures that even if a QR code is partially altered, it still leads to the intended destination, maintaining integrity in link management and redirect workflows.

How It Works

The Distance Test evaluates the minimum distance between valid QR code data patterns and how many errors can be corrected before decoding fails. QR codes use Reed-Solomon error correction, and the Distance Test quantifies how many data symbols can be corrupted or missing and still be recoverable.

  • QR codes have four error correction levels: L (Low), M (Medium), Q (Quartile), and H (High). Each level determines the maximum percentage of data that can be corrupted while still being readable.
  • The Distance Test is measured in terms of the number of codewords that can be corrected. For example, a Level H code can correct up to 30% of codewords.
  • Distance Test is not a fixed value but varies with the QR code version and error correction level. Higher versions and levels support greater resilience.
  • When generating QR codes, developers can specify error correction levels using parameters. PixQR supports all four levels, allowing customization for different use cases.
  • For dynamic QR codes, the Distance Test ensures that redirects remain valid even if the QR code is partially damaged during printing or scanning.

Quick Reference

ItemPurposeNotes
Error Correction LevelDetermines resilience to damageUse Level H for high reliability
QR Code VersionDefines size and capacityHigher versions support more error correction
Codeword CountNumber of data units in QR codeDirectly affects Distance Test capacity
Scanning AlgorithmDecodes QR code with error correctionMust support Reed-Solomon decoding
Damage TolerancePercentage of data that can be corruptedLevel H supports up to 30% corruption

Basic Example

PixQR Example QR

This QR links directly to this glossary page, so printed notes, onboarding docs, and support material can bring scanners back to the current reference.

/glossary/qr-code-error-correction/qr-code-error-correction-distance-test

QR code linking to Distance Test

This example shows how to configure a QR code with a high error correction level using PixQR's API to ensure robust Distance Test performance.

const qrConfig = {
  text: "https://example.com",
  errorCorrection: "H",
  size: 300
};

const qrCode = pixqr.generate(qrConfig);

The key line is setting errorCorrection to "H", which ensures the QR code can withstand up to 30% of data corruption. This is ideal for scenarios where print quality or scanning conditions may be suboptimal.

Production Example

In a production environment, a developer might use Distance Test to configure QR codes for outdoor signage, where environmental factors like weather and wear are common.

const outdoorQR = {
  text: "https://company.com/offer",
  errorCorrection: "H",
  size: 500,
  margin: 2,
  color: {
    foreground: "#000000",
    background: "#FFFFFF"
  },
  version: 10
};

const qrCode = pixqr.generate(outdoorQR);

This version uses a larger QR code version and high error correction to ensure that even if the printed QR code is partially degraded, it will still be scannable. The margin and color options further improve readability.

Common Mistakes

  • Using low error correction levels for critical applications, leading to poor scan reliability in real-world conditions.
  • Ignoring the relationship between QR code version and error correction capacity, resulting in oversized or underperforming codes.
  • Assuming all QR scanners support the same level of error correction, which may not be true in legacy or low-end devices.
  • Not testing QR codes under realistic environmental conditions, such as partial occlusion or poor lighting, before deployment.
  • Overlooking the trade-off between code size and resilience, which can increase bandwidth or storage usage unnecessarily.

Security And Production Notes

  • Always use the highest error correction level (H) for critical links or redirect services to prevent tampering.
  • Test QR codes under realistic scanning conditions to validate Distance Test performance before deployment.
  • Ensure that QR code generation tools support all error correction levels to avoid runtime failures.
  • Validate QR code output against expected data to ensure no unintended corruption occurs during generation.
  • Consider using PixQR's analytics to monitor scan success rates and adjust error correction levels accordingly.

Related Concepts

Distance Test is closely related to several core QR code technologies and practices:

  • Reed-Solomon Error Correction is the mathematical method used to implement Distance Test in QR codes.
  • QR Code Version determines the code size and, therefore, its error correction capacity.
  • Scan Reliability is a user-facing outcome that depends on successful Distance Test implementation.
  • Link Integrity ensures that even if a QR code is altered, it still points to the correct destination.
  • Print Quality Assurance ensures that physical QR codes meet Distance Test requirements before deployment.

Further Reading

Continue Exploring

More Qr Code Error Correction Terms

Browse the full topic index or move directly into related glossary entries.