Turn a folder of images into a corpus measure() can take
prepare_image.RdBuilds a tibble of one row per file, with the columns the rest of the package
expects. id keys the results and the audit joins, image is the path
measure() reads, and bytes is a size covariate.
Nothing is decoded. bytes comes from file.size(), which needs no image
reader and no system library.
Missing files
A path that does not resolve comes back with exists = FALSE and bytes as
NA rather than being silently removed, because a corpus that quietly lost
four documents is the failure this exists to prevent. Filter on exists
after reading the count.
See also
measure(), which reads the image column.
Examples
f <- tempfile(fileext = ".png")
grDevices::png(f, width = 8, height = 8)
graphics::par(mar = c(0, 0, 0, 0))
graphics::plot.new()
grDevices::dev.off()
#> agg_record_107ad7e455355
#> 2
prepare_image(f)
#> # A tibble: 1 × 5
#> id image bytes exists ext
#> <chr> <chr> <dbl> <lgl> <chr>
#> 1 file107ad1dceb57c /var/folders/0d/6_y1swz50c7gy3g7v86g9324… 1197 TRUE png