浏览代码

Option to only keep the last file in postprocess_internal

Yannick Ulrich 3 年之前
父节点
当前提交
540b1a4714
共有 3 个文件被更改,包括 13 次插入5 次删除
  1. 1 1
      main.c
  2. 11 3
      postprocess.c
  3. 1 1
      postprocess.h

+ 1 - 1
main.c

@@ -29,7 +29,7 @@ start_processing(struct Job job)
         return child_pid;
     } else {
         // child process
-        postprocess_internal(job.burstdir, job.target);
+        postprocess_internal(job.burstdir, job.target, 1);
         exit(0);
     }
     return -1;

+ 11 - 3
postprocess.c

@@ -356,7 +356,7 @@ postprocess_setup()
 }
 
 void
-postprocess_internal(char *burst_dir, char *target_dir)
+postprocess_internal(char *burst_dir, char *target_dir, int keep)
 {
     struct dirent **namelist;
     int burst_size;
@@ -381,7 +381,11 @@ postprocess_internal(char *burst_dir, char *target_dir)
     while (burst_size--) {
         fprintf(stderr, "DEBAYER %s\n", namelist[burst_size]->d_name);
         snprintf(path, sizeof(path), "%s/%s", burst_dir, namelist[burst_size]->d_name);
-        snprintf(outpath, sizeof(outpath), "%s.%d.jpg", target_dir, burst_size);
+        if(keep)
+            snprintf(outpath, sizeof(outpath), "%s.%d.jpg", target_dir, burst_size);
+        else
+            snprintf(outpath, sizeof(outpath), "%s.jpg", target_dir);
+
         if (first) {
             first = 0;
             imagedata = read_exif(path);
@@ -412,7 +416,11 @@ postprocess_internal(char *burst_dir, char *target_dir)
 
     // Save the final file
     fprintf(stderr, "JPEG    stacked.jpg\n");
-    snprintf(stackpath, sizeof(stackpath), "%s.stacked.jpg", target_dir);
+    if(keep)
+        snprintf(stackpath, sizeof(stackpath), "%s.stacked.jpg", target_dir);
+    else
+        snprintf(stackpath, sizeof(stackpath), "%s.jpg", target_dir);
+
     save_jpeg(stackpath, stacked_data, 90, exif);
 }
 

+ 1 - 1
postprocess.h

@@ -27,7 +27,7 @@ struct Imagedata {
 };
 
 void
-postprocess_internal(char *burst_dir, char *target_dir);
+postprocess_internal(char *burst_dir, char *target_dir, int keep);
 
 void
 postprocess_single(char *in_path, char *out_path, int quality, int verbose);