| /* |
| %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| % % |
| % % |
| % % |
| % M M AAA GGGG IIIII CCCC K K % |
| % MM MM A A G I C K K % |
| % M M M AAAAA G GGG I C KKK % |
| % M M A A G G I C K K % |
| % M M A A GGGG IIIII CCCC K K % |
| % % |
| % % |
| % Perform "Magick" on Images via the Command Line Interface % |
| % % |
| % Dragon Computing % |
| % Anthony Thyssen % |
| % January 2012 % |
| % % |
| % % |
| % Copyright 1999-2016 ImageMagick Studio LLC, a non-profit organization % |
| % dedicated to making software imaging solutions freely available. % |
| % % |
| % You may not use this file except in compliance with the License. You may % |
| % obtain a copy of the License at % |
| % % |
| % http://www.imagemagick.org/script/license.php % |
| % % |
| % Unless required by applicable law or agreed to in writing, software % |
| % distributed under the License is distributed on an "AS IS" BASIS, % |
| % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. % |
| % See the License for the specific language governing permissions and % |
| % limitations under the License. % |
| % % |
| %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| % |
| % Read CLI arguments, script files, and pipelines, to provide options that |
| % manipulate images from many different formats. |
| % |
| */ |
| |
| /* |
| Include declarations. |
| */ |
| #include "MagickWand/studio.h" |
| #include "MagickWand/MagickWand.h" |
| |
| /* |
| %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| % % |
| % % |
| % % |
| % M a i n % |
| % % |
| % % |
| % % |
| %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| % |
| % |
| */ |
| |
| static int MagickMain(int argc,char **argv) |
| { |
| #define MagickCommandSize(name,command) { (name), sizeof(name)-1, (command) } |
| |
| typedef struct _CommandInfo |
| { |
| const char |
| *client_name; |
| |
| size_t |
| extent; |
| |
| MagickCommand |
| command; |
| } CommandInfo; |
| |
| const CommandInfo |
| MagickCommands[] = |
| { |
| MagickCommandSize("convert", ConvertImageCommand), |
| MagickCommandSize("animate", AnimateImageCommand), |
| MagickCommandSize("compare", CompareImagesCommand), |
| MagickCommandSize("conjure", ConjureImageCommand), |
| MagickCommandSize("display", DisplayImageCommand), |
| MagickCommandSize("identify", IdentifyImageCommand), |
| MagickCommandSize("import", ImportImageCommand), |
| MagickCommandSize("magick-script", MagickImageCommand), |
| MagickCommandSize("mogrify", MogrifyImageCommand), |
| MagickCommandSize("montage", MontageImageCommand), |
| MagickCommandSize("stream", StreamImageCommand) |
| }; |
| |
| char |
| client_name[MagickPathExtent]; |
| |
| ExceptionInfo |
| *exception; |
| |
| ImageInfo |
| *image_info; |
| |
| MagickBooleanType |
| status; |
| |
| register ssize_t |
| i; |
| |
| MagickCoreGenesis(*argv,MagickTrue); |
| exception=AcquireExceptionInfo(); |
| image_info=AcquireImageInfo(); |
| GetPathComponent(argv[0],TailPath,client_name); |
| for (i=0; i < (sizeof(MagickCommands)/sizeof(MagickCommands[0])); i++) |
| { |
| int |
| offset; |
| |
| if (argc > 1) |
| { |
| offset=LocaleNCompare(MagickCommands[i].client_name,argv[1], |
| MagickCommands[i].extent); |
| if (offset == 0) |
| { |
| argc--; |
| argv++; |
| break; |
| } |
| } |
| offset=LocaleNCompare(MagickCommands[i].client_name,client_name, |
| MagickCommands[i].extent); |
| if (offset == 0) |
| break; |
| } |
| if (i == (sizeof(MagickCommands)/sizeof(MagickCommands[0]))) |
| status=MagickCommandGenesis(image_info,MagickImageCommand,argc,argv, |
| (char **) NULL,exception); |
| else |
| status=MagickCommandGenesis(image_info,MagickCommands[i].command,argc,argv, |
| (char **) NULL,exception); |
| image_info=DestroyImageInfo(image_info); |
| exception=DestroyExceptionInfo(exception); |
| MagickCoreTerminus(); |
| return(status != MagickFalse ? 0 : 1); |
| } |
| |
| #if !defined(MAGICKCORE_WINDOWS_SUPPORT) || defined(__CYGWIN__) || defined(__MINGW32__) || defined(__MINGW64__) |
| int main(int argc,char **argv) |
| { |
| return(MagickMain(argc,argv)); |
| } |
| #else |
| int wmain(int argc,wchar_t *argv[]) |
| { |
| char |
| **utf8; |
| |
| int |
| status; |
| |
| register int |
| i; |
| |
| utf8=NTArgvToUTF8(argc,argv); |
| status=MagickMain(argc,utf8); |
| for (i=0; i < argc; i++) |
| utf8[i]=DestroyString(utf8[i]); |
| utf8=(char **) RelinquishMagickMemory(utf8); |
| return(status); |
| } |
| #endif |