Changeset 117

Show
Ignore:
Timestamp:
02/06/06 21:40:35 (3 years ago)
Author:
conrad
Message:

add --info option to commandline app (display width x height and comments)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • fastphoto/trunk/fastphoto.1

    r116 r117  
    3838\fB\-g\fR, \fB\-\-gray\fR 
    3939Convert to grayscale 
    40  
     40.PP 
     41\fBInformational options\fR 
     42.TP 
     43\fB\-i\fR, \fB\-\-info\fR 
     44Display information about the given image and exit 
    4145.PP 
    4246\fBMiscellaneous options\fR 
  • fastphoto/trunk/src/fastphoto.h

    r116 r117  
    1818    int gray; 
    1919    int quality; 
     20    int info; 
    2021}; 
    2122 
  • fastphoto/trunk/src/main.c

    r116 r117  
    2121{ 
    2222    printf ("Usage: fastphoto [options] infile outfile\n"); 
    23     printf ("Resize a JPEG image\n\n"); 
    24     printf ("Options\n"); 
     23    printf ("Rescale a JPEG image\n"); 
     24    printf ("\nScaling options\n"); 
    2525    printf ("  -x, --width          Set the width of the output image\n"); 
    2626    printf ("  -y, --height         Set the height of the output image\n"); 
    2727    printf ("  -s, --scale          Set a percentage to scale the image by\n"); 
     28    printf ("\nOutput options\n"); 
    2829    printf ("  -g, --gray           Output grayscale\n"); 
    2930    printf ("  -q, --quality        Set the output quality 0-100\n"); 
     31    printf ("\nInformational options\n"); 
     32    printf ("  -i, --info           Print information about image\n"); 
     33    printf ("\nMiscellaneous options\n"); 
     34    printf ("  -h, --help           Display this help and exit\n"); 
     35    printf ("  -v, --version        Output version information and exit\n"); 
    3036    printf ("\n"); 
    3137} 
     
    4450    params->gray = 0; 
    4551    params->quality = 0; /* default */ 
     52    params->info = 0; 
    4653 
    4754    while (1) { 
    48         char * optstring = "hvx:y:s:gq"; 
     55        char * optstring = "hvx:y:s:gq:i"; 
    4956 
    5057#ifdef HAVE_GETOPT_LONG 
     
    5764            {"gray", no_argument, 0, 'g'}, 
    5865            {"quality", required_argument, 0, 'q'}, 
     66            {"info", no_argument, 0, 'i'}, 
    5967            {0,0,0,0} 
    6068        }; 
     
    9098        case 'q': /* quality */ 
    9199            params->quality = atoi (optarg); 
     100        case 'i': /* info */ 
     101            params->info = 1; 
    92102        default: 
    93103            break; 
  • fastphoto/trunk/src/resize.c

    r116 r117  
     1#include <stdio.h> 
    12#include <Epeg.h> 
    23 
     
    89  Epeg_Image *im; 
    910  int x, y, w, h, scale; 
     11  const char * comment; 
    1012 
    1113  im = epeg_file_open(params->infile); 
    1214 
    1315  epeg_size_get (im, &w, &h); 
     16 
     17  if (params->info) { 
     18    printf ("%s\t%dx%d\n", params->infile, w, h); 
     19    comment = epeg_comment_get (im); 
     20    if (comment) printf ("Comment: %s\n", comment); 
     21    goto im_close; 
     22  } 
     23 
     24  if (params->outfile == NULL) goto im_close; 
    1425 
    1526  x = params->x; 
     
    3950  epeg_file_output_set(im, params->outfile); 
    4051  epeg_encode(im); 
     52 
     53im_close: 
    4154  epeg_close(im); 
    4255}