An easy interface to read and write AV1 Image File Format in R, for both files and in-memory raw vectors.
Dependencies:
Install avif with:
# pak::pkg_install("r-zon/avif")
install.packages("avif", repos = c('https://r-zon.r-universe.dev', 'https://cloud.r-project.org'))
Read an AVIF file:
read_avif("foo.avif")
Save an RGB array into an AVIF file:
rgb_array <- hcl.colors(700) |>
col2rgb() |>
as.raw() |>
array(c(3, 700, 100)) |>
aperm()
write_avif(rgb_array, "8bpc.avif")
read_avif and write_avif can also output raw vectors:
write_avif(rgb_array) |> read_avif() |> plot()