Files
telfax/test/test_tiff_convert.rs
Warren bf1ca90a9c Add PDF to fax conversion support
- pdf.rs: Ghostscript-based PDF to TIFF-F conversion
- tiff_to_fax_document: Parse TIFF and convert to 1-bit fax format
- CLI: Add 'convert' subcommand for dry testing
- CLI: Add resolution option for send command
- Test files for PDF/TIFF conversion validation
2026-07-01 17:17:49 +08:00

33 lines
1.2 KiB
Rust

use telfax::document::pdf::{pdf_to_fax_document, tiff_to_fax_document};
use telfax::config::FaxResolution;
use std::path::Path;
fn main() {
let tiff_path = "/Users/accusys/telfax/test/testfax.tif";
let tiff_data = std::fs::read(tiff_path).expect("Failed to read TIFF");
println!("=== Testing TIFF → FaxDocument conversion ===");
println!("Input TIFF: {} bytes", tiff_data.len());
let doc = tiff_to_fax_document(&tiff_data).expect("Conversion failed");
println!("Converted successfully:");
println!(" Pages: {}", doc.pages.len());
for (i, page) in doc.pages.iter().enumerate() {
println!(" Page {}: {}x{} pixels, {} bytes",
i + 1, page.width_pels, page.rows, page.pixels.len());
}
// Verify pixel data - check some sample values
let page = &doc.pages[0];
let bytes_per_row = ((page.width_pels + 7) / 8) as usize;
println!(" Bytes per row: {}", bytes_per_row);
println!(" Expected rows: {}", page.rows);
println!(" Actual data rows: {}", page.pixels.len() / bytes_per_row);
// Sample first few bytes of first row
println!(" First row bytes (hex): {:02x?}", &page.pixels[0..8.min(bytes_per_row)]);
println!("\n=== Test Passed ===");
}