~ubuntu-branches/ubuntu/intrepid/graphicsmagick/intrepid

« back to all changes in this revision

Viewing changes to utilities/gm.c

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Kobras
  • Date: 2006-05-06 16:28:08 UTC
  • Revision ID: james.westby@ubuntu.com-20060506162808-vt2ni3r5nytcszms
Tags: upstream-1.1.7
ImportĀ upstreamĀ versionĀ 1.1.7

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
% Copyright (C) 2003 GraphicsMagick Group
 
3
% Copyright (C) 2002 ImageMagick Studio
 
4
%
 
5
% This program is covered by multiple licenses, which are described in
 
6
% Copyright.txt. You should have received a copy of Copyright.txt with this
 
7
% package; otherwise see http://www.graphicsmagick.org/www/Copyright.html.
 
8
%
 
9
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
10
%                                                                             %
 
11
%                                                                             %
 
12
%                                                                             %
 
13
%                                  GGGG  M   M                                %
 
14
%                                 G      MM MM                                %
 
15
%                                 G GG   M M M                                %
 
16
%                                 G   G  M   M                                %
 
17
%                                  GGG   M   M                                %
 
18
%                                                                             %
 
19
%                                                                             %
 
20
%                             GraphicsMagick Driver                           %
 
21
%                                                                             %
 
22
%                                                                             %
 
23
%                                                                             %
 
24
%                               Software Design                               %
 
25
%                            Glenn Randers-Pehrson                            %
 
26
%                                December 2002                                %
 
27
%                              Header Centered By                             %
 
28
%                               Bob Friesenhahn                               %
 
29
%                                  May 2003                                   %
 
30
%                                                                             %
 
31
%                                                                             %
 
32
%                                                                             %
 
33
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
34
%
 
35
%  Gm is a common wrapper around a set of commands, which include animate,
 
36
%  composite, conjure, convert, display, identify, import, mogrify, and
 
37
%  montage. Please see the manual page gm.1 for detailed usage information.
 
38
%
 
39
*/
 
40
 
 
41
/*
 
42
  Include declarations.
 
43
*/
 
44
#include "magick/studio.h"
 
45
#include "magick/attribute.h"
 
46
#include "magick/command.h"
 
47
#include "magick/magick.h"
 
48
#include "magick/utility.h"
 
49
#include "magick/version.h"
 
50
 
 
51
static void PrintUsage(void)
 
52
{
 
53
  (void) printf("Version: %.1024s\n",GetMagickVersion((unsigned long *) NULL));
 
54
  (void) printf("Copyright: %.1024s\n\n",GetMagickCopyright());
 
55
  (void) printf("Use:\n\n");
 
56
  (void) printf("  %.1024s help\n\n", SetClientName((char *) NULL));
 
57
  (void) printf("to obtain a list of available subcommands, or\n\n");
 
58
  (void) printf("  %.1024s help 'command'\n\n", SetClientName((char *) NULL));
 
59
  (void) printf("to obtain help information for 'command'\n");
 
60
}
 
61
 
 
62
/*
 
63
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
64
%                                                                             %
 
65
%                                                                             %
 
66
%                                                                             %
 
67
%  M a i n                                                                    %
 
68
%                                                                             %
 
69
%                                                                             %
 
70
%                                                                             %
 
71
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
72
%
 
73
%
 
74
*/
 
75
int main(int argc,char **argv)
 
76
{
 
77
  char
 
78
    command[MaxTextExtent],
 
79
    *text;
 
80
 
 
81
  ExceptionInfo
 
82
    exception;
 
83
 
 
84
  ImageInfo
 
85
    *image_info;
 
86
 
 
87
  unsigned int
 
88
    status=True;
 
89
 
 
90
  ReadCommandlLine(argc,&argv);
 
91
#if defined(WIN32)
 
92
  InitializeMagick((char *) NULL);
 
93
#else
 
94
  InitializeMagick(argv[0]);
 
95
#endif
 
96
 
 
97
  (void) SetClientName(argv[0]);
 
98
  {
 
99
    /*
 
100
      Support traditional alternate names for GraphicsMagick subcommands.
 
101
    */
 
102
    static const char *command_names [] =
 
103
      {
 
104
        "animate",
 
105
        "composite",
 
106
        "conjure",
 
107
        "convert",
 
108
        "display",
 
109
        "identify",
 
110
        "import",
 
111
        "mogrify",
 
112
        "montage",
 
113
        NULL
 
114
      };
 
115
 
 
116
    unsigned int
 
117
      i;
 
118
 
 
119
    GetPathComponent(argv[0],BasePath,command);
 
120
    for (i=0; command_names[i]; i++)
 
121
      if (LocaleCompare(command,command_names[i]) == 0)
 
122
        break;
 
123
 
 
124
    if (command_names[i])
 
125
      {
 
126
        /*
 
127
          Set command name to alternate name.
 
128
        */
 
129
        argv[0]=command;
 
130
      }
 
131
    else
 
132
      {
 
133
        if (argc < 2)
 
134
          {
 
135
            PrintUsage();
 
136
            Exit(1);
 
137
          }
 
138
 
 
139
        /*
 
140
          Skip to subcommand name.
 
141
        */
 
142
        argc--;
 
143
        argv++;
 
144
      }
 
145
  }
 
146
 
 
147
  GetExceptionInfo(&exception);
 
148
  image_info=CloneImageInfo((ImageInfo *) NULL);
 
149
  text=(char *) NULL;
 
150
  status=MagickCommand(image_info,argc,argv,&text,&exception);
 
151
  if (text != (char *) NULL)
 
152
    {
 
153
      (void) fputs(text,stdout);
 
154
      (void) fputc('\n',stdout);
 
155
      MagickFreeMemory(text);
 
156
    }
 
157
  if (exception.severity != UndefinedException)
 
158
    CatchException(&exception);
 
159
  DestroyImageInfo(image_info);
 
160
  DestroyExceptionInfo(&exception);
 
161
  DestroyMagick();
 
162
 
 
163
  Exit(!status);
 
164
  return(False);
 
165
}