Files
adaptronic_label-printer/old_code/test_quality.py
NAME 6a11cf3d8d Clean repository and update .gitignore
- Remove build artifacts from git tracking (build/, dist/, __pycache__/, *.spec)
- Updated .gitignore to properly exclude generated files
- Added old_code/ documentation folder
- Updated sample_data.txt to show new 5-field format
- Exclude user-specific conf/app.conf from tracking
2026-02-13 23:41:34 +02:00

148 lines
5.5 KiB
Python

"""
Test script to generate a quality test label
This script creates a test label with all features to verify quality improvements
"""
import sys
import os
# Add parent directory to path
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
from print_label import create_label_pdf, get_available_printers, print_to_printer
import datetime
def generate_quality_test_label():
"""Generate a test label to verify quality improvements"""
print("=" * 60)
print(" Label Quality Test - Verification Script")
print("=" * 60)
print()
# Test data with varied character types
test_data = {
'article': 'TEST-123-ABC', # Mixed alphanumeric
'nr_art': '999988887777', # All numeric (barcode test)
'serial': 'SN-2026-XY-001' # Complex serial number
}
# Create test label string
label_text = f"{test_data['article']};{test_data['nr_art']};{test_data['serial']}"
print("Test Label Data:")
print(f" Nr. Comanda: {test_data['article']}")
print(f" Nr. Art.: {test_data['nr_art']}")
print(f" Serial No.: {test_data['serial']}")
print()
# Generate PDF
print("Generating high-quality test label PDF...")
try:
pdf_path = create_label_pdf(label_text)
if pdf_path and os.path.exists(pdf_path):
print(f"✅ PDF generated successfully!")
print(f" Location: {pdf_path}")
print()
# Get file size
file_size = os.path.getsize(pdf_path)
print(f" File size: {file_size:,} bytes")
# Larger file size indicates uncompressed, higher quality
if file_size > 50000: # > 50 KB suggests good quality
print(" ✅ Good file size (uncompressed for quality)")
else:
print(" ⚠️ Small file size (may be compressed)")
print()
# Ask if user wants to print
print("Available printers:")
printers = get_available_printers()
for idx, printer in enumerate(printers, 1):
print(f" {idx}. {printer}")
print()
response = input("Print test label? (Y/N): ").strip().upper()
if response == 'Y':
print()
printer_idx = input(f"Select printer (1-{len(printers)}): ").strip()
try:
printer_idx = int(printer_idx) - 1
if 0 <= printer_idx < len(printers):
selected_printer = printers[printer_idx]
print(f"\nPrinting to: {selected_printer}")
print("Please wait...")
success = print_to_printer(selected_printer, pdf_path)
if success:
print("\n✅ Print job sent successfully!")
print()
print("Quality Check Checklist:")
print(" □ Is text sharp and readable?")
print(" □ Is the checkmark image crisp?")
print(" □ Are there no pixelation artifacts?")
print()
print("If quality is still poor:")
print(" 1. Run: .\\configure_printer_quality.ps1")
print(" 2. Adjust printer darkness/density")
print(" 3. Check printer driver is up to date")
print(" 4. Verify correct label material is loaded")
else:
print("\n⚠️ Print job may have failed")
else:
print("Invalid printer selection")
except ValueError:
print("Invalid input")
else:
print("\nPrint skipped. You can print the PDF manually from:")
print(f" {pdf_path}")
print()
print("=" * 60)
print("Quality Test Information:")
print("=" * 60)
print()
print("This test label uses the following quality settings:")
print(" • DPI: 1200 (increased from 600)")
print(" • Font Size: 8pt (increased from 6pt)")
print(" • PDF Compression: Disabled (was enabled)")
print(" • Image Mode: RGB (was Grayscale)")
print(" • Image Resampling: Modern API (fixed)")
print()
print("Expected improvements:")
print(" ✓ Sharper, more legible text")
print(" ✓ Crisper image rendering")
print(" ✓ Better contrast and clarity")
print()
print("See PRINT_QUALITY_IMPROVEMENTS.md for full details")
print()
else:
print("❌ Failed to generate PDF")
return False
except Exception as e:
print(f"❌ Error generating test label: {e}")
import traceback
traceback.print_exc()
return False
return True
if __name__ == "__main__":
print()
success = generate_quality_test_label()
print()
if not success:
print("Test failed. Please check error messages above.")
sys.exit(1)
else:
print("Test completed successfully!")
sys.exit(0)