Read the diff image produced by a comparison.
Usage
diff_image(x, as = c("magick", "raster"))Arguments
- x
An
odiff_resultfromodiff_run(), a one-row data.frame fromcompare_images(), a single row of anodiffr_batch(e.g.results[2, ]), or the path to a diff image file.- as
Output type:
"magick"(default) returns amagick-image(requires the magick package);"raster"returns arasterobject (seegrDevices::as.raster()) read withpng::readPNG(), so magick is not required.
Details
A diff image only exists when the comparison was run with diff_output
(or diff_dir for batches) and the images differ. An error is raised
otherwise.
Examples
if (FALSE) { # \dontrun{
result <- compare_images("baseline.png", "current.png", diff_output = TRUE)
img <- diff_image(result)
# Without magick
plot(diff_image(result, as = "raster"))
# One row of a batch
results <- compare_image_dirs("baseline/", "current/", diff_dir = "diffs/")
diff_image(failed_pairs(results)[1, ])
} # }
