### Install Python Dependencies for sync.py Source: https://github.com/laurenzv/hayro/blob/main/hayro-tests/README.md Installs the 'rich' Python package required by the sync.py script. Run this command before executing sync.py. ```bash python3 -m pip install --user rich ``` -------------------------------- ### Run Hayro Fuzzer Source: https://github.com/laurenzv/hayro/blob/main/hayro-fuzz/cmds.txt Executes the Hayro fuzzer with specified parameters. Use this to start fuzzing a target like fuzz_jpeg2000. ```bash cargo +nightly fuzz run fuzz_jpeg2000 --fuzz-dir . -- -print_final_stats=1 -timeout=3 -fork=$(sysctl -n hw.ncpu) -max_len=100000 -ignore_timeouts=1 -ignore_crashes=1 -ignore_ooms=1 ``` -------------------------------- ### Generate Baseline Snapshots Source: https://github.com/laurenzv/hayro/blob/main/hayro-jpeg2000/TESTS.md Execute this command to render all manifest entries and create initial PNG snapshots. This is useful for seeding the snapshot directory. ```bash REPLACE=1 cargo test --release ``` -------------------------------- ### Run Normal Test Suite Source: https://github.com/laurenzv/hayro/blob/main/hayro-jpeg2000/TESTS.md Run the test suite to verify changes against existing snapshots. If intentional changes are made to the decoder output, rerun with REPLACE=1 to update snapshots, then rerun without REPLACE to confirm. ```bash cargo test --release ``` -------------------------------- ### Synchronize Test Inputs Source: https://github.com/laurenzv/hayro/blob/main/hayro-jpeg2000/TESTS.md Run this script to download test inputs from the remote asset server. Use --force to redownload files even if a cached copy exists. ```bash python3 sync.py ``` -------------------------------- ### Generate Baseline Snapshots Source: https://github.com/laurenzv/hayro/blob/main/hayro-tests/README.md Runs the Hayro test suite in release mode to generate initial reference image snapshots. These are stored in the 'snapshots/' directory. ```bash cargo test --release ``` -------------------------------- ### Load PDF and Iterate Page Content Streams in Rust Source: https://github.com/laurenzv/hayro/blob/main/hayro-syntax/README.md Demonstrates loading a PDF file from bytes and iterating through the content stream operators of each page. Ensure proper error handling for file reading. ```rust use hayro_syntax::Pdf; use std::path::PathBuf; // First load the data that constitutes the PDF file. let data = std::fs::read( PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("../hayro-tests/pdfs/custom/text_with_rise.pdf"), ) .unwrap(); // Then create a new PDF file from it. // // Here we are just unwrapping in case reading the file failed, but you // might instead want to apply proper error handling. let pdf = Pdf::new(data).unwrap(); // First access all pages, and then iterate over the operators of each page's // content stream and print them. let pages = pdf.pages(); for page in pages.iter() { let mut ops = page.typed_operations(); while let Some(op) = ops.next() { println!("{op:?}"); } } ``` -------------------------------- ### Reduce Test Case with Hayro Fuzzer Source: https://github.com/laurenzv/hayro/blob/main/hayro-fuzz/cmds.txt Minimizes a specific test case, such as a crash artifact, to find the smallest reproducible input. Use the crash file path after the artifact name. ```bash cargo +nightly fuzz tmin --fuzz-dir . fuzz_jpeg2000 artifacts/fuzz_jpeg2000/crash-{} ``` -------------------------------- ### Decode JPEG 2000 Image in Rust Source: https://github.com/laurenzv/hayro/blob/main/hayro-jpeg2000/README.md Reads a JPEG 2000 image from a file and decodes it into a bitmap. Requires the `hayro_jpeg2000` crate and default decode settings. ```rust use hayro_jpeg2000::{Image, DecodeSettings}; let data = std::fs::read("image.jp2").unwrap(); let image = Image::new(&data, &DecodeSettings::default()).unwrap(); println!( "{}x{} image in {:?} with alpha={}", image.width, image.height, image.color_space, image.has_alpha, ); let bitmap = image.decode().unwrap(); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.