Learn R Programming

odiffr (version 0.5.1)

compare_images_batch: Compare Multiple Image Pairs

Description

Compare multiple pairs of images in batch. Useful for visual regression testing across many screenshots.

Usage

compare_images_batch(pairs, diff_dir = NULL, parallel = FALSE, ...)

Value

A tibble (if available) or data.frame with class odiffr_batch, containing one row per comparison with all columns from compare_images()

plus a pair_id column. Use summary() to get aggregate statistics.

Arguments

pairs

A data.frame with columns img1 and img2 containing file paths, or a list of named lists with img1 and img2 elements.

diff_dir

Directory to save diff images. If NULL, no diff images are created. If provided, diff images are named based on the input file names.

parallel

Logical; if TRUE, compare images in parallel using multiple CPU cores. Uses parallel::mclapply on Unix systems (macOS, Linux) and falls back to sequential processing on Windows. Default is FALSE.

...

Additional arguments passed to compare_images().

See Also

summary.odiffr_batch() for summarizing batch results, compare_image_dirs() for directory-based comparison.

Examples

Run this code
if (FALSE) {
# Create a data frame of image pairs
pairs <- data.frame(
  img1 = c("baseline/page1.png", "baseline/page2.png"),
  img2 = c("current/page1.png", "current/page2.png")
)

# Compare all pairs
results <- compare_images_batch(pairs, diff_dir = "diffs/")

# Compare in parallel (Unix only)
results <- compare_images_batch(pairs, parallel = TRUE)

# Check which comparisons failed
results[!results$match, ]
}

Run the code above in your browser using DataLab