Does anyone have any suggestions on programs or code to add a permanent dashed centerline or Rectangle to a series of .jpg images. Either using ImageJ or IrfanView or R
EDIT. The suggestion of using the ImageMagick package in R is great and one image works well using the below code. But it's unclear how this can be batch performed on multiple images in a folder.
> test <- image_read('F:/11_Cairns/Data/2_Barron_Richter_Thomatis/FRAMES/2017_4_665_20171206083500_6.jpg')
> img <- image_draw(test)
> rect(600,0, 680, 720, border = "yellow", lty = "dashed", lwd = 2)
The following will work ...
# Return a vector of all file paths that end with "jpg":
files <- list.files("F:/11_Cairns/Data/2_Barron_Richter_Thomatis/FRAMES/", pattern = "jpg$", ignore.case = TRUE, full.names = TRUE)
# Loop over each image and add a dashed yellow lines.
for(i in files){
test <- image_read(i)
img <- image_draw(test)
rect(600, 0, 680, 720, border = "yellow", lty = "dashed", lwd = 2)
dev.off()
# And if you want to save it, but not overwrite the original file:
file_loc <- gsub("\\.jpg", "_new.jpg", i, ignore.case = TRUE)
image_write(img, path = file_loc, format = "jpg")
}