add_logo <- function(recipe, logo) {
  # recipe: SUNSET recipe
  # logo: URL to the logo
  system <- list.files(paste0(recipe$Run$output_dir, "/plots/"))
  reference <- recipe$Analysis$Datasets$Reference$name
  calibration <- recipe$Analysis$Workflow$Calibration$method
  variable <- recipe$Analysis$Variable$name
  files <- lapply(variable, function(x) {
                  f <- list.files(paste0(recipe$Run$output_dir, "/plots/",
                                         system, "/", reference, "/", calibration, "/", x))
                  full_path <- paste0(recipe$Run$output_dir, "/plots/",
                                      system,"/", reference, "/", calibration, "/", x,"/", f)})[[1]]
  dim(files) <- c(file = length(files))
  Apply(list(files), target_dims = NULL, function(x) {
        system(paste("composite -gravity southeast -geometry +10+10",
                     logo, x, x))}, ncores = recipe$Analysis$ncores)
  
}

add_logo_scorecards <- function(recipe, logo) {
  # recipe: SUNSET recipe
  # logo: URL to the logo
  scorecards_f <- list.files(paste0(recipe$Run$output_dir, "/plots/Scorecards/"))
  scorecards <- paste0(recipe$Run$output_dir, "/plots/Scorecards/", scorecards_f)[[1]]
  dim(scorecards) <- c(file = length(scorecards))
    Apply(list(scorecards), target_dims = NULL, function(x) {
  
    system(paste('convert ',x, ' -gravity north -background white -splice 0x15 ', x))
      
    system(paste("composite -gravity northeast -geometry +15+15",
                 logo, x, x))}, ncores = recipe$Analysis$ncores)
    
}
