I am trying to work with some image data in R, and cannot figure out how to resize the images I have to ensure they are all the same size.
In Python, I approached th
Do these options cover what you need:
library(jpeg)
img <- readJPEG(system.file("img", "Rlogo.jpg", package="jpeg"))
# Set image size in pixels
for (i in 3:6) {
jpeg(paste0("Pixels",i,".jpeg"), width=200*i, height=200*i)
plot(as.raster(img))
dev.off()
}
# Set image size in inches (also need to set resolution in this case)
for (i in 3:6) {
jpeg(paste0("Inches",i,".jpeg"), width=i, height=i, unit="in", res=600)
plot(as.raster(img))
dev.off()
}
You can also save in other formats; png, bmp, tiff, pdf. ?jpeg
will display help for saving in bitmap formats. ?pdf
for help on saving as pdf.