From fa1e43d6abadec9f10938d14052df38ed570f99f Mon Sep 17 00:00:00 2001 From: anthony Date: Sun, 12 Feb 2012 12:55:45 +0000 Subject: [PATCH] Adding initial development program of "magick" comamnd --- MagickWand/ChangeLog | 3 + MagickWand/magick-cli.c | 514 ++++++++++++++++++++++++++++++++++++++++ MagickWand/magick-cli.h | 38 +++ Makefile.am | 1 + Makefile.in | 49 +++- utilities/Makefile.am | 5 + utilities/magick.c | 106 +++++++++ 7 files changed, 710 insertions(+), 6 deletions(-) create mode 100644 MagickWand/magick-cli.c create mode 100644 MagickWand/magick-cli.h create mode 100644 utilities/magick.c diff --git a/MagickWand/ChangeLog b/MagickWand/ChangeLog index 3a3da83c6..3cc0b9a9f 100644 --- a/MagickWand/ChangeLog +++ b/MagickWand/ChangeLog @@ -1,3 +1,6 @@ +2012-02-12 7.0.0-0 Anthony + * new module "magick-cli" providing base for new "magick" command + 2011-10-04 7.0.0-0 Anthony * Rename adjust handling of wand iteration flags to be more logical * Remove initialization of unused "quantize_info" in wand diff --git a/MagickWand/magick-cli.c b/MagickWand/magick-cli.c new file mode 100644 index 000000000..8b84e7a6d --- /dev/null +++ b/MagickWand/magick-cli.c @@ -0,0 +1,514 @@ +/* +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% % +% % +% % +% 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 % +% % +% CCCC L IIIII % +% C L I % +% C L I % +% C L I % +% CCCC LLLLL IIIII % +% % +% Perform "Magick" on Images via the Command Line Interface % +% % +% Dragon Computing % +% Anthony Thyssen % +% January 2012 % +% % +% % +% Copyright 1999-2012 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" +#include "MagickWand/magick-wand-private.h" +#include "MagickWand/operation.h" +#include "MagickCore/version.h" +#include "MagickCore/string-private.h" +#include "MagickCore/utility-private.h" + +/* +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% % +% % +% % ++ M a g i c k C o m m a n d S p e c i a l % +% % +% % +% % +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% MagickS() Reads the various reads various options defining how +% to read, process and write images. The options can be sourced from the +% command line, or from script files, or pipelines. +% +% Processing is performed using stack of expanded 'Wand' structures, which +% not only define 'image_info' store of current global options, but also the +% current input source of the options. +% +% The format of the MagickImageCommand method is: +% +% void MagickSpecialOption(MagickWand *wand, +% const char *option, const char *arg) +% +% A description of each parameter follows: +% +% o wand: the main CLI Wand to use. +% +% o option: The special option (with any switch char) to process +% +% o arg: Argument for option, if required +% +*/ +WandExport void MagickSpecialOption(MagickWand *wand, + const char *option, const char *arg) +{ + if (LocaleCompare("-read",option) == 0) + { +#if 1 + /* MagickCore style of Read */ + Image * + new_images; + + CopyMagickString(wand->image_info->filename,arg,MaxTextExtent); + if (wand->image_info->ping != MagickFalse) + new_images=PingImages(wand->image_info,wand->exception); + else + new_images=ReadImages(wand->image_info,wand->exception); + AppendImageToList(&wand->images, new_images); +#else + /* MagickWand style of Read - append new images -- FAILS */ + MagickSetLastIterator(wand); + MagickReadImage(wand, arg); + MagickSetFirstIterator(wand); +#endif + return; + } +#if 0 + if (LocaleCompare(option,"(") == 0) + // push images/settings + if (LocaleCompare(option,")") == 0) + // pop images/settings + if (LocaleCompare(option,"respect_parenthesis") == 0) + // adjust stack handling + // Other 'special' options this should handle + // "region" "clone" "list" "version" "noop" "sans*"? + // It does not do "exit" however as due to its side-effect requirements +#endif +} +/* +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% % +% % +% % ++ M a g i c k C o m m a n d P r o c e s s O p t i o n s % +% % +% % +% % +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% MagickCommandsProcessOptions() reads and processes arguments in the given +% command line argument array. +% +% The format of the MagickImageCommand method is: +% +% void MagickCommandArgs(MagickWand *wand,int argc,char **argv) +% +% A description of each parameter follows: +% +% o wand: the main CLI Wand to use. +% +% o argc: the number of elements in the argument vector. +% +% o argv: A text array containing the command line arguments. +% +*/ +#define MagickExceptionContinue(severity,tag,option,arg) \ + (void) ThrowMagickException(wand->exception,GetMagickModule(),severity,tag, \ + "'%s' arg#%lu", option, (unsigned long)arg) +#define MagickExceptionReturn(severity,tag,option,arg) \ +{ \ + MagickExceptionContinue(severity,tag,option,arg); \ + return; \ +} + +WandExport void MagickCommandProcessOptions(MagickWand *wand,int argc, + char **argv) +{ + const char + *option, + *arg1, + *arg2; + + MagickBooleanType + plus_alt_op; + + ssize_t + i, + count; + + CommandOptionFlags + flags; + + assert(wand != (MagickWand *) NULL); + assert(wand->signature == WandSignature); + assert(wand->draw_info != (DrawInfo *) NULL); /* ensure it is a CLI wand */ + if (wand->debug != MagickFalse) + (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name); + + /* + Parse command-line options. + */ + count=0; + for (i=1; i < (ssize_t) (argc-1); i+=count+1) + { + option=argv[i]; + plus_alt_op = MagickFalse; + arg1=(char *)NULL; + arg2=(char *)NULL; + + /* FUTURE: merge these into one call */ + count=ParseCommandOption(MagickCommandOptions,MagickFalse,argv[i]); + flags=(CommandOptionFlags) GetCommandOptionFlags( + MagickCommandOptions,MagickFalse,argv[i]); + +#define MagickCommandDebug 0 + + if ( count == -1 || flags == UndefinedOptionFlag || + (flags & NonConvertOptionFlag) != 0 ) + { + count = 0; +#if MagickCommandDebug + (void) FormatLocaleFile(stderr, "CLI Non-Option: \"%s\"\n", option); +#endif + if (IsCommandOption(option) == MagickFalse) + { + /* non-option -- treat as a image read */ + MagickSpecialOption(wand,"-read",option); + continue; + } + else + MagickExceptionReturn(OptionError,"UnrecognizedOption",option,i); + } + + if ( (flags & DeprecateOptionFlag) != 0 ) + MagickExceptionContinue(OptionWarning,"DeprecatedOption",option,i); + /* continue processing option anyway */ + + if ((i+count) > (ssize_t) (argc-1)) + MagickExceptionReturn(OptionError,"MissingArgument",option,i); + if (*option=='+') plus_alt_op = MagickTrue; + if (*option!='+') arg1 = "true"; + if ( count >= 1 ) arg1 = argv[i+1]; + if ( count >= 2 ) arg2 = argv[i+2]; + +#if MagickCommandDebug + (void) FormatLocaleFile(stderr, + "CLI Option: \"%s\" \tCount: %d Flags: %04x Args: \"%s\" \"%s\"\n", + option,count,flags,arg1,arg2); +#endif + + if ( (flags & SpecialOptionFlag) != 0 ) + { + if (LocaleCompare(option,"-exit") == 0) + return; +#if 0 + if (LocaleCompare(option,"-script") == 0) + { + // Unbalanced Parenthesis if stack not empty + // Call Script, with filename as argv[0] + return; + } +#endif + MagickSpecialOption(wand,option,arg1); + } + + if ( (flags & SettingOptionFlags) != 0 ) + { + WandSettingOptionInfo(wand, option+1, arg1); + // FUTURE: Sync Specific Settings into Images + } + + if ( (flags & SimpleOperatorOptionFlag) != 0) + { + WandSimpleOperatorImages(wand, plus_alt_op, option+1, arg1, arg2); + } + + if ( (flags & ListOperatorOptionFlag) != 0 ) + { + WandListOperatorImages(wand, plus_alt_op, option+1, arg1, arg2); + } + + // FUTURE: '-regard_warning' causes IM to exit more prematurely! + // Note pipelined options may like more control over this level + if (wand->exception->severity > ErrorException) + { + if (wand->exception->severity > ErrorException) + //(regard_warnings != MagickFalse)) + return; /* FATAL - let caller handle */ + CatchException(wand->exception); /* output warnings and clear!!! */ + } + } + + /* FUTURE: in the following produce a better error report + -- Missing Output filename + */ + + assert(i!=(ssize_t)(argc-1)); + option=argv[i]; /* the last argument - output filename! */ + +#if MagickCommandDebug + (void) FormatLocaleFile(stderr, "CLI Output: \"%s\"\n", option ); +#endif + + // if stacks are not empty + // ThrowConvertException(OptionError,"UnbalancedParenthesis",option,i); + + + /* This is the only value 'do no write' option for a CLI */ + if (LocaleCompare(option,"-exit") == 0 ) + return; /* just exit, no image write */ + + /* If there is an option -- produce an error */ + if (IsCommandOption(option) != MagickFalse) + MagickExceptionReturn(OptionError,"MissingAnImageFilename",option,i); + + /* If no images */ + if ( wand->images == (Image *) NULL ) + { + /* a "null:" output coder with no images is ok */ + if ( LocaleCompare(option,"null:") == 0 ) + return; + MagickExceptionReturn(OptionError,"MissingAnImageFilename",option,i); + } + + /* + Write out final image! + */ + //WandListOperatorImages(wand,MagickFalse,"write",option,(const char *)NULL); + (void) SyncImagesSettings(wand->image_info,wand->images,wand->exception); + (void) WriteImages(wand->image_info,wand->images,option,wand->exception); + + return; +} + +/* +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% % +% % +% % ++ M a g i c k I m a g e C o m m a n d % +% % +% % +% % +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% MagickImageCommand() Handle special 'once only' CLI arguments and +% prepare to process the command line using a special CLI Magick Wand +% via the MagickImageProcess() function. +% +% The format of the MagickImageCommand method is: +% +% MagickBooleanType MagickImageCommand(ImageInfo *image_info, +% int argc, char **argv, char **metadata, ExceptionInfo *exception) +% +% A description of each parameter follows: +% +% o image_info: the starting image_info structure +% (for compatibilty with MagickCommandGenisis()) +% +% o argc: the number of elements in the argument vector. +% +% o argv: A text array containing the command line arguments. +% +% o metadata: any metadata is returned here. +% (for compatibilty with MagickCommandGenisis()) +% +% o exception: return any errors or warnings in this structure. +% +*/ + +static MagickBooleanType MagickUsage(void) +{ + printf("Version: %s\n",GetMagickVersion((size_t *) NULL)); + printf("Copyright: %s\n",GetMagickCopyright()); + printf("Features: %s\n\n",GetMagickFeatures()); + printf("\n"); + + printf("Usage: %s [(options|images) ...] output_image\n", GetClientName()); + printf(" %s -script filename [script args...]\n", GetClientName()); + printf(" ... | %s -script - | ...\n", GetClientName()); + printf("\n"); + + printf(" For more information on usage, options, examples, and technqiues\n"); + printf(" see the ImageMagick website at\n %s\n", MagickAuthoritativeURL); + printf(" Or the web pages in ImageMagick Sources\n"); + return(MagickFalse); +} + +/* + Concatanate given file arguments to the given output argument. + Used for a special -concatenate option used for specific 'delegates'. + The option is not formally documented. + + magick -concatenate files... output + + This is much like the UNIX "cat" command, but for both UNIX and Windows, + however the last argument provides the output filename. +*/ +#define ThrowFileException(exception,severity,tag,context) \ +{ \ + char \ + *message; \ + \ + message=GetExceptionMessage(errno); \ + (void) ThrowMagickException(exception,GetMagickModule(),severity, \ + tag == (const char *) NULL ? "unknown" : tag,"`%s': %s",context,message); \ + message=DestroyString(message); \ +} + +static MagickBooleanType ConcatenateImages(int argc,char **argv, + ExceptionInfo *exception) +{ + FILE + *input, + *output; + + int + c; + + register ssize_t + i; + + output=fopen_utf8(argv[argc-1],"wb"); + if (output == (FILE *) NULL) + { + ThrowFileException(exception,FileOpenError,"UnableToOpenFile", + argv[argc-1]); + return(MagickFalse); + } + for (i=2; i < (ssize_t) (argc-1); i++) + { + input=fopen_utf8(argv[i],"rb"); + if (input == (FILE *) NULL) + ThrowFileException(exception,FileOpenError,"UnableToOpenFile",argv[i]); + for (c=fgetc(input); c != EOF; c=fgetc(input)) + (void) fputc((char) c,output); + (void) fclose(input); + (void) remove_utf8(argv[i]); + } + (void) fclose(output); + return(MagickTrue); +} + +WandExport MagickBooleanType MagickImageCommand(ImageInfo *image_info, + int argc,char **argv,char **metadata,ExceptionInfo *exception) +{ + MagickWand + *wand; + + const char + *option; + + /* Handle special single use options */ + if (argc == 2) + { + option=argv[1]; + if ((LocaleCompare("-version",option+1) == 0) || + (LocaleCompare("--version",option+1) == 0) ) + { + (void) FormatLocaleFile(stdout,"Version: %s\n", + GetMagickVersion((size_t *) NULL)); + (void) FormatLocaleFile(stdout,"Copyright: %s\n", + GetMagickCopyright()); + (void) FormatLocaleFile(stdout,"Features: %s\n\n", + GetMagickFeatures()); + return(MagickFalse); + } + } + if (argc < 3) + return(MagickUsage()); + ReadCommandlLine(argc,&argv); +#if 0 + status=ExpandFilenames(&argc,&argv); + if (status == MagickFalse) + ThrowConvertException(ResourceLimitError,"MemoryAllocationFailed", + GetExceptionMessage(errno)); +#endif + if (LocaleCompare("-concatenate",argv[1]) == 0) + return(ConcatenateImages(argc,argv,exception)); + + /* create a special CLI Wand to hold all working settings */ + /* FUTURE: add this to 'operations.c' */ + wand=NewMagickWand(); + wand->image_info=DestroyImageInfo(wand->image_info); + wand->image_info=image_info; + wand->exception=DestroyExceptionInfo(wand->exception); + wand->exception=exception; + wand->draw_info=CloneDrawInfo(image_info,(DrawInfo *) NULL); + wand->quantize_info=AcquireQuantizeInfo(image_info); + + if (LocaleCompare("-list",argv[1]) == 0) + WandSettingOptionInfo(wand, argv[1]+1, argv[2]); + else + MagickCommandProcessOptions(wand,argc,argv); + + assert(wand->exception == exception); + assert(wand->image_info == image_info); + + /* Handle metadata for ImageMagickObject COM object for Windows VBS */ + if (metadata != (char **) NULL) + { + const char + *format; + + char + *text; + + format="%w,%h,%m"; // Get this from image_info Option splaytree + + text=InterpretImageProperties(image_info,wand->images,format,exception); + if (text == (char *) NULL) + ThrowMagickException(exception,GetMagickModule(),ResourceLimitError, + "MemoryAllocationFailed","`%s'", GetExceptionMessage(errno)); + else + { + (void) ConcatenateString(&(*metadata),text); + text=DestroyString(text); + } + } + + /* Destroy the special CLI Wand */ + wand->exception = (ExceptionInfo *)NULL; + wand->image_info = (ImageInfo *)NULL; + wand=DestroyMagickWand(wand); + + return((exception->severity > ErrorException) ? MagickFalse : MagickTrue); +} diff --git a/MagickWand/magick-cli.h b/MagickWand/magick-cli.h new file mode 100644 index 000000000..f6ba71a08 --- /dev/null +++ b/MagickWand/magick-cli.h @@ -0,0 +1,38 @@ +/* + Copyright 1999-2012 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. + 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. + + MagickWand convert command-line method. +*/ +#ifndef _MAGICKWAND_MAGICK_CLI_H +#define _MAGICKWAND_MAGICK_CLI_H + +#if defined(__cplusplus) || defined(c_plusplus) +extern "C" { +#endif + +extern WandExport void + MagickSpecialOption(MagickWand *,const char *,const char *); + +extern WandExport void + MagickCommandProcessOptions(MagickWand *,int,char **); + +extern WandExport MagickBooleanType + MagickImageCommand(ImageInfo *,int,char **,char **,ExceptionInfo *); + +#if defined(__cplusplus) || defined(c_plusplus) +} +#endif + +#endif diff --git a/Makefile.am b/Makefile.am index 4c0d2f5a1..9dea08358 100644 --- a/Makefile.am +++ b/Makefile.am @@ -70,6 +70,7 @@ TESTS_ENVIRONMENT = \ CONVERT="$(MEMCHECK) @abs_top_builddir@/utilities/convert" \ DISPLAY="$(MEMCHECK) @abs_top_builddir@/utilities/display" \ IDENTIFY="$(MEMCHECK) @abs_top_builddir@/utilities/identify" \ + MAGICK="$(MEMCHECK) @abs_top_builddir@/utilities/magick" \ MONTAGE="$(MEMCHECK) @abs_top_builddir@/utilities/montage" \ VALIDATE="$(MEMCHECK) @abs_top_builddir@/tests/validate" \ LD_LIBRARY_PATH="@abs_top_builddir@/MagickCore/.libs:${LD_LIBRARY_PATH}" \ diff --git a/Makefile.in b/Makefile.in index 39250ea6b..cb33c5346 100644 --- a/Makefile.in +++ b/Makefile.in @@ -747,6 +747,7 @@ am__objects_18 = MagickWand/MagickWand_libMagickWand_la-animate.lo \ MagickWand/MagickWand_libMagickWand_la-drawing-wand.lo \ MagickWand/MagickWand_libMagickWand_la-identify.lo \ MagickWand/MagickWand_libMagickWand_la-import.lo \ + MagickWand/MagickWand_libMagickWand_la-magick-cli.lo \ MagickWand/MagickWand_libMagickWand_la-magick-image.lo \ MagickWand/MagickWand_libMagickWand_la-magick-property.lo \ MagickWand/MagickWand_libMagickWand_la-magick-wand.lo \ @@ -1755,8 +1756,8 @@ am__EXEEXT_1 = utilities/animate$(EXEEXT) utilities/compare$(EXEEXT) \ utilities/composite$(EXEEXT) utilities/conjure$(EXEEXT) \ utilities/convert$(EXEEXT) utilities/display$(EXEEXT) \ utilities/identify$(EXEEXT) utilities/import$(EXEEXT) \ - utilities/mogrify$(EXEEXT) utilities/montage$(EXEEXT) \ - utilities/stream$(EXEEXT) + utilities/magick$(EXEEXT) utilities/mogrify$(EXEEXT) \ + utilities/montage$(EXEEXT) utilities/stream$(EXEEXT) am__EXEEXT_2 = tests/validate$(EXEEXT) am__EXEEXT_3 = Magick++/demo/analyze$(EXEEXT) \ Magick++/demo/button$(EXEEXT) Magick++/demo/demo$(EXEEXT) \ @@ -1941,6 +1942,13 @@ utilities_import_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \ $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \ $(AM_CFLAGS) $(CFLAGS) $(utilities_import_LDFLAGS) $(LDFLAGS) \ -o $@ +am_utilities_magick_OBJECTS = utilities/magick.$(OBJEXT) +utilities_magick_OBJECTS = $(am_utilities_magick_OBJECTS) +utilities_magick_DEPENDENCIES = $(MAGICKCORE_LIBS) $(MAGICKWAND_LIBS) +utilities_magick_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \ + $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \ + $(AM_CFLAGS) $(CFLAGS) $(utilities_magick_LDFLAGS) $(LDFLAGS) \ + -o $@ am_utilities_mogrify_OBJECTS = utilities/mogrify.$(OBJEXT) utilities_mogrify_OBJECTS = $(am_utilities_mogrify_OBJECTS) utilities_mogrify_DEPENDENCIES = $(MAGICKCORE_LIBS) $(MAGICKWAND_LIBS) @@ -2094,8 +2102,9 @@ SOURCES = $(Magick___lib_libMagick___la_SOURCES) \ $(utilities_compare_SOURCES) $(utilities_composite_SOURCES) \ $(utilities_conjure_SOURCES) $(utilities_convert_SOURCES) \ $(utilities_display_SOURCES) $(utilities_identify_SOURCES) \ - $(utilities_import_SOURCES) $(utilities_mogrify_SOURCES) \ - $(utilities_montage_SOURCES) $(utilities_stream_SOURCES) + $(utilities_import_SOURCES) $(utilities_magick_SOURCES) \ + $(utilities_mogrify_SOURCES) $(utilities_montage_SOURCES) \ + $(utilities_stream_SOURCES) DIST_SOURCES = $(Magick___lib_libMagick___la_SOURCES) \ $(am__MagickCore_libMagickCore_la_SOURCES_DIST) \ $(MagickWand_libMagickWand_la_SOURCES) \ @@ -2185,8 +2194,9 @@ DIST_SOURCES = $(Magick___lib_libMagick___la_SOURCES) \ $(utilities_compare_SOURCES) $(utilities_composite_SOURCES) \ $(utilities_conjure_SOURCES) $(utilities_convert_SOURCES) \ $(utilities_display_SOURCES) $(utilities_identify_SOURCES) \ - $(utilities_import_SOURCES) $(utilities_mogrify_SOURCES) \ - $(utilities_montage_SOURCES) $(utilities_stream_SOURCES) + $(utilities_import_SOURCES) $(utilities_magick_SOURCES) \ + $(utilities_mogrify_SOURCES) $(utilities_montage_SOURCES) \ + $(utilities_stream_SOURCES) man1dir = $(mandir)/man1 NROFF = nroff MANS = $(man_MANS) @@ -2744,6 +2754,7 @@ TESTS_ENVIRONMENT = \ CONVERT="$(MEMCHECK) @abs_top_builddir@/utilities/convert" \ DISPLAY="$(MEMCHECK) @abs_top_builddir@/utilities/display" \ IDENTIFY="$(MEMCHECK) @abs_top_builddir@/utilities/identify" \ + MAGICK="$(MEMCHECK) @abs_top_builddir@/utilities/magick" \ MONTAGE="$(MEMCHECK) @abs_top_builddir@/utilities/montage" \ VALIDATE="$(MEMCHECK) @abs_top_builddir@/tests/validate" \ LD_LIBRARY_PATH="@abs_top_builddir@/MagickCore/.libs:${LD_LIBRARY_PATH}" \ @@ -4336,6 +4347,8 @@ MAGICKWAND_SOURCES = \ MagickWand/identify.h \ MagickWand/import.c \ MagickWand/import.h \ + MagickWand/magick-cli.c \ + MagickWand/magick-cli.h \ MagickWand/magick-image.c \ MagickWand/magick-image.h \ MagickWand/magick-property.c \ @@ -4374,6 +4387,7 @@ MAGICKWAND_INCLUDE_HDRS = \ MagickWand/drawing-wand.h \ MagickWand/identify.h \ MagickWand/import.h \ + MagickWand/magick-cli.h \ MagickWand/magick-image.h \ MagickWand/magick-property.h \ MagickWand/mogrify.h \ @@ -4685,6 +4699,7 @@ UTILITIES_PGMS = \ utilities/display \ utilities/identify \ utilities/import \ + utilities/magick \ utilities/mogrify \ utilities/montage \ utilities/stream @@ -4717,6 +4732,9 @@ utilities_identify_SOURCES = utilities/identify.c utilities_import_LDADD = $(MAGICKCORE_LIBS) $(MAGICKWAND_LIBS) utilities_import_LDFLAGS = $(LDFLAGS) utilities_import_SOURCES = utilities/import.c +utilities_magick_LDADD = $(MAGICKCORE_LIBS) $(MAGICKWAND_LIBS) +utilities_magick_LDFLAGS = $(LDFLAGS) +utilities_magick_SOURCES = utilities/magick.c utilities_mogrify_LDADD = $(MAGICKCORE_LIBS) $(MAGICKWAND_LIBS) utilities_mogrify_LDFLAGS = $(LDFLAGS) utilities_mogrify_SOURCES = utilities/mogrify.c @@ -5689,6 +5707,9 @@ MagickWand/MagickWand_libMagickWand_la-identify.lo: \ MagickWand/MagickWand_libMagickWand_la-import.lo: \ MagickWand/$(am__dirstamp) \ MagickWand/$(DEPDIR)/$(am__dirstamp) +MagickWand/MagickWand_libMagickWand_la-magick-cli.lo: \ + MagickWand/$(am__dirstamp) \ + MagickWand/$(DEPDIR)/$(am__dirstamp) MagickWand/MagickWand_libMagickWand_la-magick-image.lo: \ MagickWand/$(am__dirstamp) \ MagickWand/$(DEPDIR)/$(am__dirstamp) @@ -6503,6 +6524,11 @@ utilities/import.$(OBJEXT): utilities/$(am__dirstamp) \ utilities/import$(EXEEXT): $(utilities_import_OBJECTS) $(utilities_import_DEPENDENCIES) $(EXTRA_utilities_import_DEPENDENCIES) utilities/$(am__dirstamp) @rm -f utilities/import$(EXEEXT) $(AM_V_CCLD)$(utilities_import_LINK) $(utilities_import_OBJECTS) $(utilities_import_LDADD) $(LIBS) +utilities/magick.$(OBJEXT): utilities/$(am__dirstamp) \ + utilities/$(DEPDIR)/$(am__dirstamp) +utilities/magick$(EXEEXT): $(utilities_magick_OBJECTS) $(utilities_magick_DEPENDENCIES) $(EXTRA_utilities_magick_DEPENDENCIES) utilities/$(am__dirstamp) + @rm -f utilities/magick$(EXEEXT) + $(AM_V_CCLD)$(utilities_magick_LINK) $(utilities_magick_OBJECTS) $(utilities_magick_LDADD) $(LIBS) utilities/mogrify.$(OBJEXT): utilities/$(am__dirstamp) \ utilities/$(DEPDIR)/$(am__dirstamp) utilities/mogrify$(EXEEXT): $(utilities_mogrify_OBJECTS) $(utilities_mogrify_DEPENDENCIES) $(EXTRA_utilities_mogrify_DEPENDENCIES) utilities/$(am__dirstamp) @@ -6804,6 +6830,8 @@ mostlyclean-compile: -rm -f MagickWand/MagickWand_libMagickWand_la-identify.lo -rm -f MagickWand/MagickWand_libMagickWand_la-import.$(OBJEXT) -rm -f MagickWand/MagickWand_libMagickWand_la-import.lo + -rm -f MagickWand/MagickWand_libMagickWand_la-magick-cli.$(OBJEXT) + -rm -f MagickWand/MagickWand_libMagickWand_la-magick-cli.lo -rm -f MagickWand/MagickWand_libMagickWand_la-magick-image.$(OBJEXT) -rm -f MagickWand/MagickWand_libMagickWand_la-magick-image.lo -rm -f MagickWand/MagickWand_libMagickWand_la-magick-property.$(OBJEXT) @@ -7345,6 +7373,7 @@ mostlyclean-compile: -rm -f utilities/display.$(OBJEXT) -rm -f utilities/identify.$(OBJEXT) -rm -f utilities/import.$(OBJEXT) + -rm -f utilities/magick.$(OBJEXT) -rm -f utilities/mogrify.$(OBJEXT) -rm -f utilities/montage.$(OBJEXT) -rm -f utilities/stream.$(OBJEXT) @@ -7488,6 +7517,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@MagickWand/$(DEPDIR)/MagickWand_libMagickWand_la-drawing-wand.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@MagickWand/$(DEPDIR)/MagickWand_libMagickWand_la-identify.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@MagickWand/$(DEPDIR)/MagickWand_libMagickWand_la-import.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@MagickWand/$(DEPDIR)/MagickWand_libMagickWand_la-magick-cli.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@MagickWand/$(DEPDIR)/MagickWand_libMagickWand_la-magick-image.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@MagickWand/$(DEPDIR)/MagickWand_libMagickWand_la-magick-property.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@MagickWand/$(DEPDIR)/MagickWand_libMagickWand_la-magick-wand.Plo@am__quote@ @@ -9311,6 +9341,13 @@ MagickWand/MagickWand_libMagickWand_la-import.lo: MagickWand/import.c @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(MagickWand_libMagickWand_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o MagickWand/MagickWand_libMagickWand_la-import.lo `test -f 'MagickWand/import.c' || echo '$(srcdir)/'`MagickWand/import.c +MagickWand/MagickWand_libMagickWand_la-magick-cli.lo: MagickWand/magick-cli.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(MagickWand_libMagickWand_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT MagickWand/MagickWand_libMagickWand_la-magick-cli.lo -MD -MP -MF MagickWand/$(DEPDIR)/MagickWand_libMagickWand_la-magick-cli.Tpo -c -o MagickWand/MagickWand_libMagickWand_la-magick-cli.lo `test -f 'MagickWand/magick-cli.c' || echo '$(srcdir)/'`MagickWand/magick-cli.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) MagickWand/$(DEPDIR)/MagickWand_libMagickWand_la-magick-cli.Tpo MagickWand/$(DEPDIR)/MagickWand_libMagickWand_la-magick-cli.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='MagickWand/magick-cli.c' object='MagickWand/MagickWand_libMagickWand_la-magick-cli.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(MagickWand_libMagickWand_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o MagickWand/MagickWand_libMagickWand_la-magick-cli.lo `test -f 'MagickWand/magick-cli.c' || echo '$(srcdir)/'`MagickWand/magick-cli.c + MagickWand/MagickWand_libMagickWand_la-magick-image.lo: MagickWand/magick-image.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(MagickWand_libMagickWand_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT MagickWand/MagickWand_libMagickWand_la-magick-image.lo -MD -MP -MF MagickWand/$(DEPDIR)/MagickWand_libMagickWand_la-magick-image.Tpo -c -o MagickWand/MagickWand_libMagickWand_la-magick-image.lo `test -f 'MagickWand/magick-image.c' || echo '$(srcdir)/'`MagickWand/magick-image.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) MagickWand/$(DEPDIR)/MagickWand_libMagickWand_la-magick-image.Tpo MagickWand/$(DEPDIR)/MagickWand_libMagickWand_la-magick-image.Plo diff --git a/utilities/Makefile.am b/utilities/Makefile.am index be2e0d43a..25bd19893 100644 --- a/utilities/Makefile.am +++ b/utilities/Makefile.am @@ -23,6 +23,7 @@ UTILITIES_PGMS = \ utilities/display \ utilities/identify \ utilities/import \ + utilities/magick \ utilities/mogrify \ utilities/montage \ utilities/stream @@ -63,6 +64,10 @@ utilities_import_LDADD = $(MAGICKCORE_LIBS) $(MAGICKWAND_LIBS) utilities_import_LDFLAGS = $(LDFLAGS) utilities_import_SOURCES = utilities/import.c +utilities_magick_LDADD = $(MAGICKCORE_LIBS) $(MAGICKWAND_LIBS) +utilities_magick_LDFLAGS = $(LDFLAGS) +utilities_magick_SOURCES = utilities/magick.c + utilities_mogrify_LDADD = $(MAGICKCORE_LIBS) $(MAGICKWAND_LIBS) utilities_mogrify_LDFLAGS = $(LDFLAGS) utilities_mogrify_SOURCES = utilities/mogrify.c diff --git a/utilities/magick.c b/utilities/magick.c new file mode 100644 index 000000000..a1618b3e5 --- /dev/null +++ b/utilities/magick.c @@ -0,0 +1,106 @@ +/* +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% % +% % +% % +% 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-2012 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) +{ + ExceptionInfo + *exception; + + ImageInfo + *image_info; + + MagickBooleanType + status; + + MagickCoreGenesis(*argv,MagickTrue); + exception=AcquireExceptionInfo(); + image_info=AcquireImageInfo(); + status=MagickCommandGenesis(image_info,MagickImageCommand,argc,argv, + (char **) NULL,exception); + image_info=DestroyImageInfo(image_info); + exception=DestroyExceptionInfo(exception); + MagickCoreTerminus(); + return(status); +} + +#if !defined(MAGICKCORE_WINDOWS_SUPPORT) || defined(__CYGWIN__) || defined(__MINGW32__) +int main(int argc,char **argv) +{ + return(ConvertMain(argc,argv)); +} +#else +int wmain(int argc,wchar_t *argv[]) +{ + char + **utf8; + + int + status; + + register int + i; + + utf8=NTArgvToUTF8(argc,argv); + status=ConvertMain(argc,utf8); + for (i=0; i < argc; i++) + utf8[i]=DestroyString(utf8[i]); + utf8=(char **) RelinquishMagickMemory(utf8); + return(status); +} +#endif -- 2.50.1