Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

Diff of /tools/PTcrop.c [28d66e] .. [1feb11] Maximize Restore

  Switch to side-by-side view

--- a/tools/PTcrop.c
+++ b/tools/PTcrop.c
@@ -29,10 +29,16 @@
  * 
  */
 
-#define PT_CROP_USAGE "PTuncrop [options] <inputFile> <outputFile>\n\n" \
+#define DEFAULT_PREFIX    "cropped"
+
+
+#define PT_CROP_USAGE "PTuncrop [options] <inputFiles+>\n\n" \
     "Options:\n"                                                        \
-    "-f\t\tForce processing: Overwrite output file if it exists\n"                        \
-    "\t-q\t\tQuiet run\n\t-h\t\tShow this message\n"                    \
+    "\t-p <prefix>\tPrefix for output files (defaults to " DEFAULT_PREFIX "%%4d)\n"	\
+    "\t-f\t\tForce processing: Overwrite output files if they exists (use with care)\n"      \
+    "\t-x\t\tDelete source files (use with care)\n"\
+    "\t-q\t\tQuiet run\n"\
+    "\t-h\t\tShow this message\n"\
     "\n"
 
 #define PT_CROP_VERSION "PTcrop Version " VERSION ", by Daniel M German\n"
@@ -46,69 +52,10 @@
 #include "panorama.h"
 #include "filter.h"
 #include "PTcommon.h"
-#include "pttiff.h"
-#include "file.h"
+
 
 int main(int argc,char *argv[])
 {
-    char opt;
-    int overwrite = 0;
-    int filesCount;
-    int retVal;
-    char *inputFile, *outputFile;
-    FILE *testFile;
-    pano_cropping_parms croppingParms;
-  
-    bzero(&croppingParms, sizeof(croppingParms));
-
-    //Need enough space for a message to be returned if something goes wrong
-  
-    printf(PT_CROP_VERSION);
-
-    while ((opt = getopt(argc, argv, "fhq")) != -1) {
-
-        // o overwrite
-        // h       -> help
-        // q       -> quiet?
-    
-        switch(opt) {  // fhoqs        f: 102 h:104  111 113 115  o:f:hsq
-        case 'f':
-            overwrite = 1;
-            break;
-        case 'q':
-            ptQuietFlag = 1;
-            break;
-        case 'h':
-            printf(PT_CROP_USAGE);
-            exit(0);
-        default:
-            break;
-        }
-    }
-    filesCount = argc - optind;
-
-    if (filesCount != 2) {
-        printf(PT_CROP_USAGE);
-        exit(0);
-    }
-
-    inputFile = argv[optind];
-    outputFile = argv[optind+1];
-
-    if (!overwrite) {
-        if ((testFile = fopen(outputFile, "r"))!= NULL) {
-            fprintf(stderr, "Output file already exists. Use -f to overwrite\n");
-            fclose(testFile);
-            exit(1);
-        }
-    }
-  
-    retVal = panoTiffCrop(inputFile, outputFile, &croppingParms);
-        
-    if (retVal == 0) {
-        return 1;
-    }
-  
-    return 0;
+    return panoCroppingMain(argc, argv, PANO_CROPPING_CROP, PT_CROP_VERSION, PT_CROP_USAGE, DEFAULT_PREFIX);
 }