convert_plot_format <- function(recipe) {
  # Convert plots to user-chosen format
  if (!is.null(recipe$Analysis$Workflow$Visualization$file_format) &&
      tolower(recipe$Analysis$Workflow$Visualization$file_format) != "pdf") {
    extension <- tolower(recipe$Analysis$Workflow$Visualization$file_format)
    plot_files <- list.files(path = paste0(recipe$Run$output_dir),
                             pattern = "\\.pdf$",
                             recursive = TRUE, full.names = TRUE)
    for (file in plot_files) {
      system_command <- paste("convert -density 300", file,
                              "-resize 40% -alpha remove",
                              paste0(tools::file_path_sans_ext(file), ".",
                                     extension))
      system(system_command)
    }
    unlink(plot_files)
    info(recipe$Run$logger, retrieve = TRUE,
         paste0("##### PLOT FILES CONVERTED TO ", toupper(extension), " #####"))
  }
}
