I'm trying to batch resize (i.e., reduce the file size) of thousands of images using R. I've managed to achieve this using the code below, but it takes ages (especially when resizing >50,000) images. Is there any way that this task could be run on multiple cores? I'm a complete novice on parallel computing, so any assistance would be greatly appreciated. Thanks in advance!
library(imager)
pages <- list.files(path = '...insert directory path...',
full.names = TRUE)
for(x in 1:length(pages)) {
file <- load.image(pages[x])
resized <- imresize(file,
scale = 0.390625)
save.image(resized,
file = gsub("JPG", "jpg", paste(pages[x])))
}