From 31f1bf7bb6ee2698a2afab42ee0329b11663636c Mon Sep 17 00:00:00 2001 From: anthony Date: Mon, 30 Jan 2012 12:37:22 +0000 Subject: [PATCH] Final part of operation.c code. Initial review of option handling complete. --- MagickCore/enhance.c | 15 +- MagickCore/list.c | 129 +-- MagickCore/option.c | 90 +- MagickCore/option.h | 2 +- MagickCore/quantize.c | 4 +- MagickCore/string.c | 6 + MagickWand/magick-wand-private.h | 2 +- MagickWand/mogrify.c | 14 - MagickWand/operation.c | 1733 +++++++++++++----------------- MagickWand/operation.h | 8 +- MagickWand/studio.h | 12 +- 11 files changed, 864 insertions(+), 1151 deletions(-) diff --git a/MagickCore/enhance.c b/MagickCore/enhance.c index 8b4eda5b9..65bb0d6b7 100644 --- a/MagickCore/enhance.c +++ b/MagickCore/enhance.c @@ -2314,10 +2314,10 @@ MagickExport MagickBooleanType LevelImage(Image *image,const double black_point, % LevelizeImage() can be called with by using a +level command line % API option, or using a '!' on a -level or LevelImage() geometry string. % -% It can be used for example de-contrast a greyscale image to the exact -% levels specified. Or by using specific levels for each channel of an image -% you can convert a gray-scale image to any linear color gradient, according -% to those levels. +% It can be used to de-contrast a greyscale image to the exact levels +% specified. Or by using specific levels for each channel of an image you +% can convert a gray-scale image to any linear color gradient, according to +% those levels. % % The format of the LevelizeImage method is: % @@ -3263,10 +3263,9 @@ MagickExport MagickBooleanType NormalizeImage(Image *image, % sigmoidal contrast algorithm. Increase the contrast of the image using a % sigmoidal transfer function without saturating highlights or shadows. % Contrast indicates how much to increase the contrast (0 is none; 3 is -% typical; 20 is pushing it); mid-point indicates where midtones fall in the -% resultant image (0 is white; 50% is middle-gray; 100% is black). Set -% sharpen to MagickTrue to increase the image contrast otherwise the contrast -% is reduced. +% typical; 20 is pushing it); mid-point indicates where threshold 'knee' of +% the curve falls (typical 50% for mid-gray). Set sharpen to MagickTrue to +% increase the image contrast otherwise the contrast is reduced. % % The format of the SigmoidalContrastImage method is: % diff --git a/MagickCore/list.c b/MagickCore/list.c index 7a5c68614..598eff10b 100644 --- a/MagickCore/list.c +++ b/MagickCore/list.c @@ -74,26 +74,26 @@ % o image: the appended image or image list. % */ -MagickExport void AppendImageToList(Image **images,const Image *image) +MagickExport void AppendImageToList(Image **images,const Image *append) { register Image *p, *q; assert(images != (Image **) NULL); - if (image == (Image *) NULL) + if (append == (Image *) NULL) return; - assert(image->signature == MagickSignature); - if (image->debug != MagickFalse) - (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename); + assert(append->signature == MagickSignature); + if (append->debug != MagickFalse) + (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",append->filename); if ((*images) == (Image *) NULL) { - *images=(Image *) image; + *images=(Image *) append; return; } assert((*images)->signature == MagickSignature); p=GetLastImageInList(*images); - q=GetFirstImageInList(image); + q=GetFirstImageInList(append); p->next=q; q->previous=p; } @@ -673,9 +673,9 @@ MagickExport size_t GetImageListLength(const Image *images) assert(images->signature == MagickSignature); if (images->debug != MagickFalse) (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",images->filename); - while (images->previous != (Image *) NULL) - images=images->previous; - for (i=0; images != (Image *) NULL; images=images->next) + while (images->next != (Image *) NULL) + images=images->next; + for (i=0; images != (Image *) NULL; images=images->previous) i++; return((size_t) i); } @@ -787,7 +787,10 @@ MagickExport Image *GetPreviousImageInList(const Image *images) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % ImageListToArray() is a convenience method that converts an image list to -% a sequential array. For example, +% a sequential array, with a NULL image pointer at the end of the array. +% +% The images remain part of the original image list, with the array providing +% an alternative means of indexing the image array. % % group = ImageListToArray(images, exception); % while (i = 0; group[i] != (Image *) NULL; i++) @@ -846,36 +849,36 @@ MagickExport Image **ImageListToArray(const Image *images, % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % -% InsertImageInList() insert second given image or image list, into the first +% InsertImageInList() insert the given image or image list, into the first % image list, immediately AFTER the image pointed to. The given image list % pointer is left unchanged unless previously empty. % % The format of the InsertImageInList method is: % -% InsertImageInList(Image **images,Image *image) +% InsertImageInList(Image **images,Image *insert) % % A description of each parameter follows: % % o images: the image list to insert into. % -% o image: the image list to insert. +% o insert: the image list to insert. % */ -MagickExport void InsertImageInList(Image **images,Image *image) +MagickExport void InsertImageInList(Image **images,Image *insert) { Image *split; assert(images != (Image **) NULL); - assert(image != (Image *) NULL); - assert(image->signature == MagickSignature); - if (image->debug != MagickFalse) - (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename); + assert(insert != (Image *) NULL); + assert(insert->signature == MagickSignature); + if (insert->debug != MagickFalse) + (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",insert->filename); if ((*images) == (Image *) NULL) return; assert((*images)->signature == MagickSignature); split=SplitImageList(*images); - AppendImageToList(images,image); + AppendImageToList(images,insert); AppendImageToList(images,split); } @@ -1105,46 +1108,48 @@ MagickExport Image *RemoveLastImageFromList(Image **images) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % ReplaceImageInList() replaces an image in the list with the given image, or -% list of images. Old image is destroyed. The image list pointer is set to -% point to the first image of the inserted list of images. +% list of images. Old image is destroyed. +% +% The images list pointer is set to point to the first image of the inserted +% list of images. % % The format of the ReplaceImageInList method is: % -% ReplaceImageInList(Image **images,Image *image) +% ReplaceImageInList(Image **images,Image *replace) % % A description of each parameter follows: % % o images: the list and pointer to image to replace % -% o image: the image or image list replacing the original +% o replace: the image or image list replacing the original % */ -MagickExport void ReplaceImageInList(Image **images,Image *image) +MagickExport void ReplaceImageInList(Image **images,Image *replace) { assert(images != (Image **) NULL); - assert(image != (Image *) NULL); - assert(image->signature == MagickSignature); - if (image->debug != MagickFalse) - (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename); + assert(replace != (Image *) NULL); + assert(replace->signature == MagickSignature); + if (replace->debug != MagickFalse) + (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",replace->filename); if ((*images) == (Image *) NULL) return; assert((*images)->signature == MagickSignature); /* link next pointer */ - image=GetLastImageInList(image); - image->next=(*images)->next; - if (image->next != (Image *) NULL) - image->next->previous=image; + replace=GetLastImageInList(replace); + replace->next=(*images)->next; + if (replace->next != (Image *) NULL) + replace->next->previous=replace; - /* link previous pointer - set image position to first replacement image */ - image=GetFirstImageInList(image); - image->previous=(*images)->previous; - if (image->previous != (Image *) NULL) - image->previous->next=image; + /* link previous pointer - set images position to first replacement image */ + replace=GetFirstImageInList(replace); + replace->previous=(*images)->previous; + if (replace->previous != (Image *) NULL) + replace->previous->next=replace; - /* destroy replaced image */ + /* destroy the replaced image that was in images */ (void) DestroyImage(*images); - (*images)=image; + (*images)=replace; } /* @@ -1159,48 +1164,50 @@ MagickExport void ReplaceImageInList(Image **images,Image *image) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % ReplaceImageInListReturnLast() is exactly as ReplaceImageInList() except -% the image pointer is set to the last image in the list. +% the images pointer is set to the last image in the list of replacemen +% images. % -% This allows you to simply use 'next' to go to the image that follows the -% just replaced image. +% This allows you to simply use GetNextImageInList() to go to the image +% that follows the just replaced image, even if a list of replacement images +% was inserted. % % The format of the ReplaceImageInList method is: % -% ReplaceImageInListReturnLast(Image **images,Image *image) +% ReplaceImageInListReturnLast(Image **images,Image *replace) % % A description of each parameter follows: % % o images: the list and pointer to image to replace % -% o image: the image or image list replacing the original +% o replace: the image or image list replacing the original % */ -MagickExport void ReplaceImageInListReturnLast(Image **images,Image *image) +MagickExport void ReplaceImageInListReturnLast(Image **images,Image *replace) { assert(images != (Image **) NULL); - assert(image != (Image *) NULL); - assert(image->signature == MagickSignature); - if (image->debug != MagickFalse) - (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename); + assert(replace != (Image *) NULL); + assert(replace->signature == MagickSignature); + if (replace->debug != MagickFalse) + (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",replace->filename); if ((*images) == (Image *) NULL) return; assert((*images)->signature == MagickSignature); /* link previous pointer */ - image=GetFirstImageInList(image); - image->previous=(*images)->previous; - if (image->previous != (Image *) NULL) - image->previous->next=image; + replace=GetFirstImageInList(replace); + replace->previous=(*images)->previous; + if (replace->previous != (Image *) NULL) + replace->previous->next=replace; - /* link next pointer - set image position to last replacement image */ - image=GetLastImageInList(image); - image->next=(*images)->next; - if (image->next != (Image *) NULL) - image->next->previous=image; + /* link next pointer - set images position to last replacement image */ + replace=GetLastImageInList(replace); + replace->next=(*images)->next; + if (replace->next != (Image *) NULL) + replace->next->previous=replace; - /* destroy replaced image */ + /* destroy the replaced image that was in images */ (void) DestroyImage(*images); - (*images)=image; + (*images)=replace; } /* diff --git a/MagickCore/option.c b/MagickCore/option.c index a16a3aadf..f694b8765 100644 --- a/MagickCore/option.c +++ b/MagickCore/option.c @@ -167,7 +167,7 @@ static const OptionInfo { "-adaptive-sharpen", 1L, SimpleOperatorOptionFlag, MagickFalse }, { "+affine", 0L, DrawInfoOptionFlag | DeprecateOptionFlag, MagickTrue }, { "-affine", 1L, DrawInfoOptionFlag | DeprecateOptionFlag, MagickTrue }, - { "+affinity", 0L, ListOperatorOptionFlag | FireOptionFlag, MagickFalse }, + { "+affinity", 0L, DeprecateOptionFlag, MagickTrue }, { "-affinity", 1L, DeprecateOptionFlag | FireOptionFlag, MagickTrue }, { "+alpha", 1L, DeprecateOptionFlag, MagickTrue }, { "-alpha", 1L, SimpleOperatorOptionFlag, MagickFalse }, @@ -239,8 +239,8 @@ static const OptionInfo { "-clip-mask", 1L, SimpleOperatorOptionFlag, MagickFalse }, { "+clip-path", 1L, SimpleOperatorOptionFlag, MagickFalse }, { "-clip-path", 1L, SimpleOperatorOptionFlag, MagickFalse }, - { "+clone", 0L, SpecialOperatorOptionFlag, MagickFalse }, - { "-clone", 1L, SpecialOperatorOptionFlag, MagickFalse }, + { "+clone", 0L, SpecialOptionFlag, MagickFalse }, + { "-clone", 1L, SpecialOptionFlag, MagickFalse }, { "+clut", 0L, FireOptionFlag | DeprecateOptionFlag, MagickTrue }, { "-clut", 0L, ListOperatorOptionFlag | FireOptionFlag, MagickFalse }, { "+coalesce", 0L, FireOptionFlag | DeprecateOptionFlag, MagickTrue }, @@ -281,8 +281,8 @@ static const OptionInfo { "-debug", 1L, GlobalOptionFlag|GenesisOptionFlag | FireOptionFlag, MagickFalse }, { "+decipher", 1L, DeprecateOptionFlag, MagickTrue }, { "-decipher", 1L, SimpleOperatorOptionFlag, MagickFalse }, - { "+deconstruct", 0L, FireOptionFlag | DeprecateOptionFlag, MagickTrue }, - { "-deconstruct", 0L, ListOperatorOptionFlag | FireOptionFlag, MagickFalse }, + { "+deconstruct", 0L, DeprecateOptionFlag, MagickTrue }, + { "-deconstruct", 0L, ListOperatorOptionFlag | FireOptionFlag | DeprecateOptionFlag, MagickTrue }, { "+define", 1L, ImageInfoOptionFlag, MagickFalse }, { "-define", 1L, ImageInfoOptionFlag, MagickFalse }, { "+delay", 0L, ImageInfoOptionFlag, MagickFalse }, @@ -351,8 +351,8 @@ static const OptionInfo { "-fill", 1L, ImageInfoOptionFlag | DrawInfoOptionFlag, MagickFalse }, { "+filter", 0L, ImageInfoOptionFlag, MagickFalse }, { "-filter", 1L, ImageInfoOptionFlag, MagickFalse }, - { "+flatten", 0L, DeprecateOptionFlag | FireOptionFlag, MagickTrue }, - { "-flatten", 0L, ListOperatorOptionFlag | FireOptionFlag | DeprecateOptionFlag, MagickTrue }, + { "+flatten", 0L, DeprecateOptionFlag, MagickTrue }, + { "-flatten", 0L, ListOperatorOptionFlag | FireOptionFlag, MagickFalse }, { "+flip", 0L, DeprecateOptionFlag, MagickTrue }, { "-flip", 0L, SimpleOperatorOptionFlag, MagickFalse }, { "+flop", 0L, DeprecateOptionFlag, MagickTrue }, @@ -387,8 +387,8 @@ static const OptionInfo { "-green-primary", 1L, ImageInfoOptionFlag, MagickFalse }, { "+hald-clut", 0L, DeprecateOptionFlag | FireOptionFlag, MagickTrue }, { "-hald-clut", 0L, ListOperatorOptionFlag | FireOptionFlag, MagickFalse }, - { "+help", 0L, SpecialOperatorOptionFlag, MagickFalse }, - { "-help", 0L, SpecialOperatorOptionFlag, MagickFalse }, + { "+help", 0L, SpecialOptionFlag, MagickFalse }, + { "-help", 0L, SpecialOptionFlag, MagickFalse }, { "+highlight-color", 1L, SimpleOperatorOptionFlag, MagickFalse }, { "-highlight-color", 1L, SimpleOperatorOptionFlag, MagickFalse }, { "+iconGeometry", 0L, NonConvertOptionFlag, MagickFalse }, @@ -445,12 +445,12 @@ static const OptionInfo { "-lowlight-color", 1L, SimpleOperatorOptionFlag, MagickFalse }, { "+magnify", 0L, NonConvertOptionFlag, MagickFalse }, { "-magnify", 1L, NonConvertOptionFlag, MagickFalse }, - { "+map", 0L, ListOperatorOptionFlag | FireOptionFlag, MagickFalse }, - { "-map", 1L, SimpleOperatorOptionFlag, MagickFalse }, + { "+map", 0L, ListOperatorOptionFlag | FireOptionFlag | DeprecateOptionFlag, MagickTrue }, + { "-map", 1L, SimpleOperatorOptionFlag | DeprecateOptionFlag, MagickTrue }, { "+mask", 0L, SimpleOperatorOptionFlag, MagickFalse }, { "-mask", 1L, SimpleOperatorOptionFlag, MagickFalse }, - { "+matte", 0L, DeprecateOptionFlag, MagickTrue }, - { "-matte", 0L, DeprecateOptionFlag, MagickTrue }, + { "+matte", 0L, SimpleOperatorOptionFlag | DeprecateOptionFlag, MagickTrue }, + { "-matte", 0L, SimpleOperatorOptionFlag | DeprecateOptionFlag, MagickTrue }, { "+mattecolor", 0L, ImageInfoOptionFlag, MagickFalse }, { "-mattecolor", 1L, ImageInfoOptionFlag, MagickFalse }, { "+maximum", 0L, DeprecateOptionFlag | FireOptionFlag, MagickTrue }, @@ -465,16 +465,16 @@ static const OptionInfo { "-mode", 1L, SimpleOperatorOptionFlag, MagickFalse }, { "+modulate", 1L, DeprecateOptionFlag, MagickTrue }, { "-modulate", 1L, SimpleOperatorOptionFlag, MagickFalse }, - { "+monitor", 0L, GlobalOptionFlag | SimpleOperatorOptionFlag, MagickFalse }, - { "-monitor", 0L, GlobalOptionFlag | SimpleOperatorOptionFlag, MagickFalse }, + { "+monitor", 0L, ImageInfoOptionFlag | SimpleOperatorOptionFlag, MagickFalse }, + { "-monitor", 0L, ImageInfoOptionFlag | SimpleOperatorOptionFlag, MagickFalse }, { "+monochrome", 0L, ImageInfoOptionFlag, MagickFalse }, { "-monochrome", 0L, ImageInfoOptionFlag | SimpleOperatorOptionFlag, MagickFalse }, { "+morph", 1L, DeprecateOptionFlag | FireOptionFlag, MagickTrue }, { "-morph", 1L, ListOperatorOptionFlag | FireOptionFlag, MagickFalse }, { "+morphology", 2L, DeprecateOptionFlag, MagickTrue }, { "-morphology", 2L, SimpleOperatorOptionFlag, MagickFalse }, - { "+mosaic", 0L, ListOperatorOptionFlag | FireOptionFlag | DeprecateOptionFlag, MagickTrue }, - { "-mosaic", 0L, ListOperatorOptionFlag | FireOptionFlag | DeprecateOptionFlag, MagickTrue }, + { "+mosaic", 0L, DeprecateOptionFlag, MagickTrue }, + { "-mosaic", 0L, ListOperatorOptionFlag | FireOptionFlag, MagickFalse }, { "+motion-blur", 1L, DeprecateOptionFlag, MagickTrue }, { "-motion-blur", 1L, SimpleOperatorOptionFlag, MagickFalse }, { "+name", 0L, NonConvertOptionFlag, MagickFalse }, @@ -483,8 +483,8 @@ static const OptionInfo { "-negate", 0L, SimpleOperatorOptionFlag, MagickFalse }, { "+noise", 1L, SimpleOperatorOptionFlag, MagickFalse }, { "-noise", 1L, SimpleOperatorOptionFlag, MagickFalse }, - { "+noop", 0L, SpecialOperatorOptionFlag, MagickFalse }, - { "-noop", 0L, SpecialOperatorOptionFlag, MagickFalse }, + { "+noop", 0L, SpecialOptionFlag, MagickFalse }, + { "-noop", 0L, SpecialOptionFlag, MagickFalse }, { "+normalize", 0L, DeprecateOptionFlag, MagickTrue }, { "-normalize", 0L, SimpleOperatorOptionFlag, MagickFalse }, { "+opaque", 1L, SimpleOperatorOptionFlag, MagickFalse }, @@ -499,8 +499,8 @@ static const OptionInfo { "-page", 1L, ImageInfoOptionFlag, MagickFalse }, { "+paint", 0L, DeprecateOptionFlag, MagickTrue }, { "-paint", 1L, SimpleOperatorOptionFlag, MagickFalse }, - { "+path", 0L, SpecialOperatorOptionFlag, MagickFalse }, - { "-path", 1L, SpecialOperatorOptionFlag, MagickFalse }, + { "+path", 0L, SpecialOptionFlag, MagickFalse }, + { "-path", 1L, SpecialOptionFlag, MagickFalse }, { "+pause", 0L, NonConvertOptionFlag, MagickFalse }, { "-pause", 1L, NonConvertOptionFlag, MagickFalse }, { "+passphrase", 0L, DeprecateOptionFlag, MagickTrue }, @@ -515,8 +515,8 @@ static const OptionInfo { "-posterize", 1L, SimpleOperatorOptionFlag, MagickFalse }, { "+precision", 0L, GlobalOptionFlag, MagickFalse }, { "-precision", 1L, GlobalOptionFlag, MagickFalse }, - { "+preview", 0L, ImageInfoOptionFlag, MagickFalse }, - { "-preview", 1L, ImageInfoOptionFlag, MagickFalse }, + { "+preview", 0L, ImageInfoOptionFlag | SimpleOperatorOptionFlag, MagickFalse }, + { "-preview", 1L, ImageInfoOptionFlag | SimpleOperatorOptionFlag, MagickFalse }, { "+print", 1L, DeprecateOptionFlag | FireOptionFlag, MagickTrue }, { "-print", 1L, ListOperatorOptionFlag | FireOptionFlag, MagickFalse }, { "+process", 1L, DeprecateOptionFlag | FireOptionFlag, MagickTrue }, @@ -536,18 +536,18 @@ static const OptionInfo { "+random-threshold", 1L, DeprecateOptionFlag, MagickTrue }, { "-random-threshold", 1L, SimpleOperatorOptionFlag, MagickFalse }, { "+recolor", 1L, DeprecateOptionFlag, MagickTrue }, - { "-recolor", 1L, SimpleOperatorOptionFlag | DeprecateOptionFlag, MagickTrue }, + { "-recolor", 1L, DeprecateOptionFlag, MagickTrue }, { "+red-primary", 0L, ImageInfoOptionFlag, MagickFalse }, { "-red-primary", 1L, ImageInfoOptionFlag, MagickFalse }, { "+regard-warnings", 0L, GenesisOptionFlag, MagickFalse }, { "-regard-warnings", 0L, GenesisOptionFlag, MagickFalse }, - { "+region", 0L, SpecialOperatorOptionFlag, MagickFalse }, - { "-region", 1L, SpecialOperatorOptionFlag, MagickFalse }, + { "+region", 0L, SpecialOptionFlag, MagickFalse }, + { "-region", 1L, SpecialOptionFlag, MagickFalse }, { "+remote", 0L, NonConvertOptionFlag, MagickFalse }, { "-remote", 1L, NonConvertOptionFlag, MagickFalse }, { "+render", 0L, DrawInfoOptionFlag, MagickFalse }, { "-render", 0L, DrawInfoOptionFlag, MagickFalse }, - { "+remap", 0L, DeprecateOptionFlag | FireOptionFlag, MagickTrue }, + { "+remap", 0L, ListOperatorOptionFlag | FireOptionFlag, MagickFalse }, { "-remap", 1L, SimpleOperatorOptionFlag, MagickFalse }, { "+repage", 0L, SimpleOperatorOptionFlag, MagickFalse }, { "-repage", 1L, SimpleOperatorOptionFlag, MagickFalse }, @@ -555,8 +555,8 @@ static const OptionInfo { "-resample", 1L, SimpleOperatorOptionFlag, MagickFalse }, { "+resize", 1L, DeprecateOptionFlag, MagickTrue }, { "-resize", 1L, SimpleOperatorOptionFlag, MagickFalse }, - { "+respect-parenthesis", 0L, SpecialOperatorOptionFlag, MagickFalse }, - { "-respect-parenthesis", 0L, SpecialOperatorOptionFlag, MagickFalse }, + { "+respect-parenthesis", 0L, SpecialOptionFlag, MagickFalse }, + { "-respect-parenthesis", 0L, SpecialOptionFlag, MagickFalse }, { "+reverse", 0L, DeprecateOptionFlag | FireOptionFlag, MagickTrue }, { "-reverse", 0L, ListOperatorOptionFlag | FireOptionFlag, MagickFalse }, { "+roll", 1L, DeprecateOptionFlag, MagickTrue }, @@ -567,12 +567,12 @@ static const OptionInfo { "-sample", 1L, SimpleOperatorOptionFlag, MagickFalse }, { "+sampling-factor", 0L, ImageInfoOptionFlag, MagickFalse }, { "-sampling-factor", 1L, ImageInfoOptionFlag, MagickFalse }, - { "+sans", 1L, NonConvertOptionFlag, MagickTrue }, - { "-sans", 1L, NonConvertOptionFlag, MagickTrue }, - { "+sans0", 0L, NonConvertOptionFlag, MagickTrue }, - { "-sans0", 0L, NonConvertOptionFlag, MagickTrue }, - { "+sans2", 2L, NonConvertOptionFlag, MagickTrue }, - { "-sans2", 2L, NonConvertOptionFlag, MagickTrue }, + { "+sans", 1L, SpecialOptionFlag, MagickTrue }, /* equivelent to 'noop' */ + { "-sans", 1L, SpecialOptionFlag, MagickTrue }, + { "+sans0", 0L, SpecialOptionFlag, MagickTrue }, + { "-sans0", 0L, SpecialOptionFlag, MagickTrue }, + { "+sans2", 2L, SpecialOptionFlag, MagickTrue }, + { "-sans2", 2L, SpecialOptionFlag, MagickTrue }, { "+scale", 1L, DeprecateOptionFlag, MagickTrue }, { "-scale", 1L, SimpleOperatorOptionFlag, MagickFalse }, { "+scene", 0L, ImageInfoOptionFlag, MagickFalse }, @@ -591,8 +591,8 @@ static const OptionInfo { "-separate", 0L, SimpleOperatorOptionFlag | FireOptionFlag, MagickFalse }, { "+sepia-tone", 1L, DeprecateOptionFlag, MagickTrue }, { "-sepia-tone", 1L, SimpleOperatorOptionFlag, MagickFalse }, - { "+set", 1L, ImageInfoOptionFlag | SimpleOperatorOptionFlag, MagickFalse }, - { "-set", 2L, ImageInfoOptionFlag | SimpleOperatorOptionFlag, MagickFalse }, + { "+set", 1L, SimpleOperatorOptionFlag, MagickFalse }, + { "-set", 2L, SimpleOperatorOptionFlag, MagickFalse }, { "+shade", 0L, DeprecateOptionFlag, MagickTrue }, { "-shade", 1L, SimpleOperatorOptionFlag, MagickFalse }, { "+shadow", 1L, DeprecateOptionFlag, MagickTrue }, @@ -685,8 +685,8 @@ static const OptionInfo { "-type", 1L, ImageInfoOptionFlag | SimpleOperatorOptionFlag, MagickFalse }, { "+undercolor", 0L, ImageInfoOptionFlag | DrawInfoOptionFlag, MagickFalse }, { "-undercolor", 1L, ImageInfoOptionFlag | DrawInfoOptionFlag, MagickFalse }, - { "+unique", 0L, DeprecateOptionFlag, MagickTrue }, - { "-unique", 0L, ImageInfoOptionFlag, MagickFalse }, + { "+unique", 0L, SimpleOperatorOptionFlag, MagickFalse }, + { "-unique", 0L, SimpleOperatorOptionFlag, MagickFalse }, { "+unique-colors", 0L, DeprecateOptionFlag, MagickTrue }, { "-unique-colors", 0L, SimpleOperatorOptionFlag, MagickFalse }, { "+units", 0L, ImageInfoOptionFlag, MagickFalse }, @@ -699,8 +699,8 @@ static const OptionInfo { "-use-pixmap", 1L, NonConvertOptionFlag, MagickFalse }, { "+verbose", 0L, ImageInfoOptionFlag, MagickFalse }, { "-verbose", 0L, ImageInfoOptionFlag, MagickFalse }, - { "+version", 0L, SpecialOperatorOptionFlag, MagickFalse }, - { "-version", 1L, SpecialOperatorOptionFlag, MagickFalse }, + { "+version", 0L, SpecialOptionFlag, MagickFalse }, + { "-version", 1L, SpecialOptionFlag, MagickFalse }, { "+view", 0L, ImageInfoOptionFlag, MagickFalse }, { "-view", 1L, ImageInfoOptionFlag, MagickFalse }, { "+vignette", 1L, DeprecateOptionFlag, MagickTrue }, @@ -2307,12 +2307,12 @@ MagickExport ssize_t ParseChannelOption(const char *channels) % % The format of the ParseCommandOption method is: % -% ssize_t ParseCommandOption(const CommandOption option, +% ssize_t ParseCommandOption(const CommandOption option_table, % const MagickBooleanType list,const char *options) % % A description of each parameter follows: % -% o option: Index to the option table to lookup +% o option_table: Index to the option table to lookup % % o list: A option other than zero permits more than one option separated by % a comma or pipe. @@ -2320,7 +2320,7 @@ MagickExport ssize_t ParseChannelOption(const char *channels) % o options: One or more options separated by commas. % */ -MagickExport ssize_t ParseCommandOption(const CommandOption option, +MagickExport ssize_t ParseCommandOption(const CommandOption option_table, const MagickBooleanType list,const char *options) { char @@ -2347,7 +2347,7 @@ MagickExport ssize_t ParseCommandOption(const CommandOption option, ssize_t option_types; - option_info=GetOptionInfo(option); + option_info=GetOptionInfo(option_table); if (option_info == (const OptionInfo *) NULL) return(-1); option_types=0; diff --git a/MagickCore/option.h b/MagickCore/option.h index 10e3d27fd..8ed06bf6a 100644 --- a/MagickCore/option.h +++ b/MagickCore/option.h @@ -142,7 +142,7 @@ typedef enum SimpleOperatorOptionFlag = 0x0010, /* Simple Image processing operator */ ListOperatorOptionFlag = 0x0020, /* Multi-Image processing operator */ - SpecialOperatorOptionFlag = 0x0040, /* Specially handled Operator Option */ + SpecialOptionFlag = 0x0040, /* Special handled Option */ GenesisOptionFlag = 0x0080, /* Genesis Command Wrapper Option */ NonConvertOptionFlag = 0x1000, /* Option not used by Convert */ diff --git a/MagickCore/quantize.c b/MagickCore/quantize.c index d607f5a72..02574e1e0 100644 --- a/MagickCore/quantize.c +++ b/MagickCore/quantize.c @@ -3069,8 +3069,8 @@ static void ReduceImageColors(const Image *image,CubeInfo *cube_info) % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % -% RemapImage() replaces the colors of an image with the closest color from -% a reference image. +% RemapImage() replaces the colors of an image with a dither of the colors +% provided. % % The format of the RemapImage method is: % diff --git a/MagickCore/string.c b/MagickCore/string.c index 2a949a707..71856b47d 100644 --- a/MagickCore/string.c +++ b/MagickCore/string.c @@ -1961,6 +1961,12 @@ MagickExport char *StringInfoToString(const StringInfo *string_info) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % StringToArgv() converts a text string into command line arguments. +% The 'argv' array of arguments, is returned while the number of arguments +% is returned via the provided integer variable pointer. +% +% Simple 'word' tokenizer, which allows for each word to be optionally +% quoted. However it will not allow use of partial quotes, or escape +% characters. % % The format of the StringToArgv method is: % diff --git a/MagickWand/magick-wand-private.h b/MagickWand/magick-wand-private.h index 30c4e3995..18496c50a 100644 --- a/MagickWand/magick-wand-private.h +++ b/MagickWand/magick-wand-private.h @@ -38,7 +38,7 @@ struct _MagickWand name[MaxTextExtent]; /* Wand name to use for MagickWand Logs */ Image - *images; /* The images in this wand */ + *images; /* The images in this wand - also the current image */ ImageInfo *image_info; /* Global settings used for images in Wand */ diff --git a/MagickWand/mogrify.c b/MagickWand/mogrify.c index 95b85ec1f..0a450bede 100644 --- a/MagickWand/mogrify.c +++ b/MagickWand/mogrify.c @@ -7317,20 +7317,6 @@ WandExport MagickBooleanType MogrifyImageList(ImageInfo *image_info, } case 'c': { - if (LocaleCompare("channel",option+1) == 0) - { - ChannelType - channel; - - if (*option == '+') - { - channel=DefaultChannels; - break; - } - channel=(ChannelType) ParseChannelOption(argv[i+1]); - SetPixelChannelMapMask(*images,channel); - break; - } if (LocaleCompare("clut",option+1) == 0) { Image diff --git a/MagickWand/operation.c b/MagickWand/operation.c index bf136e0b0..ada9bc538 100644 --- a/MagickWand/operation.c +++ b/MagickWand/operation.c @@ -152,7 +152,7 @@ static inline Image *GetImageCache(const ImageInfo *image_info,const char *path, */ static Image *SparseColorOption(const Image *image, const SparseColorMethod method,const char *arguments, - const MagickBooleanType color_from_image,ExceptionInfo *exception) + ExceptionInfo *exception) { char token[MaxTextExtent]; @@ -211,30 +211,16 @@ static Image *SparseColorOption(const Image *image, { GetMagickToken(p,&p,token); if ( token[0] == ',' ) continue; - if ( isalpha((int) token[0]) || token[0] == '#' ) { - if ( color_from_image ) { - (void) ThrowMagickException(exception,GetMagickModule(), - OptionError, "InvalidArgument", "`%s': %s", "sparse-color", - "Color arg given, when colors are coming from image"); - return( (Image *)NULL); - } - x += number_colors; /* color argument */ - } + if ( isalpha((int) token[0]) || token[0] == '#' ) + x += number_colors; /* color argument found */ else { x++; /* floating point argument */ } } error=MagickTrue; - if ( color_from_image ) { - /* just the control points are being given */ - error = ( x % 2 != 0 ) ? MagickTrue : MagickFalse; - number_arguments=(x/2)*(2+number_colors); - } - else { - /* control points and color values */ - error = ( x % (2+number_colors) != 0 ) ? MagickTrue : MagickFalse; - number_arguments=x; - } + /* control points and color values */ + error = ( x % (2+number_colors) != 0 ) ? MagickTrue : MagickFalse; + number_arguments=x; if ( error ) { (void) ThrowMagickException(exception,GetMagickModule(), OptionError, "InvalidArgument", "`%s': %s", "sparse-color", @@ -277,80 +263,70 @@ static Image *SparseColorOption(const Image *image, break; } sparse_arguments[x++]=StringToDouble(token,(char **) NULL); - /* color values for this control point */ -#if 0 - if ( (color_from_image ) { - /* get color from image */ - /* HOW??? */ + /* color name or function given in string argument */ + token[0]=','; while ( token[0] == ',' ) GetMagickToken(p,&p,token); + if ( token[0] == '\0' ) break; + if ( isalpha((int) token[0]) || token[0] == '#' ) { + /* Color string given */ + (void) QueryColorCompliance(token,AllCompliance,&color, + exception); + if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0) + sparse_arguments[x++] = QuantumScale*color.red; + if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0) + sparse_arguments[x++] = QuantumScale*color.green; + if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0) + sparse_arguments[x++] = QuantumScale*color.blue; + if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) && + (image->colorspace == CMYKColorspace)) + sparse_arguments[x++] = QuantumScale*color.black; + if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) && + (image->matte != MagickFalse)) + sparse_arguments[x++] = QuantumScale*color.alpha; } - else -#endif - { - /* color name or function given in string argument */ - token[0]=','; while ( token[0] == ',' ) GetMagickToken(p,&p,token); - if ( token[0] == '\0' ) break; - if ( isalpha((int) token[0]) || token[0] == '#' ) { - /* Color string given */ - (void) QueryColorCompliance(token,AllCompliance,&color, - exception); - if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0) - sparse_arguments[x++] = QuantumScale*color.red; - if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0) - sparse_arguments[x++] = QuantumScale*color.green; - if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0) - sparse_arguments[x++] = QuantumScale*color.blue; - if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) && - (image->colorspace == CMYKColorspace)) - sparse_arguments[x++] = QuantumScale*color.black; - if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) && - (image->matte != MagickFalse)) - sparse_arguments[x++] = QuantumScale*color.alpha; + else { + /* Colors given as a set of floating point values - experimental */ + /* NB: token contains the first floating point value to use! */ + if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0) + { + while ( token[0] == ',' ) GetMagickToken(p,&p,token); + if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' ) + break; + sparse_arguments[x++]=StringToDouble(token,(char **) NULL); + token[0] = ','; /* used this token - get another */ } - else { - /* Colors given as a set of floating point values - experimental */ - /* NB: token contains the first floating point value to use! */ - if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0) - { - while ( token[0] == ',' ) GetMagickToken(p,&p,token); - if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' ) - break; - sparse_arguments[x++]=StringToDouble(token,(char **) NULL); - token[0] = ','; /* used this token - get another */ - } - if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0) - { - while ( token[0] == ',' ) GetMagickToken(p,&p,token); - if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' ) - break; - sparse_arguments[x++]=StringToDouble(token,(char **) NULL); - token[0] = ','; /* used this token - get another */ - } - if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0) - { - while ( token[0] == ',' ) GetMagickToken(p,&p,token); - if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' ) - break; - sparse_arguments[x++]=StringToDouble(token,(char **) NULL); - token[0] = ','; /* used this token - get another */ - } - if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) && - (image->colorspace == CMYKColorspace)) - { - while ( token[0] == ',' ) GetMagickToken(p,&p,token); - if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' ) - break; - sparse_arguments[x++]=StringToDouble(token,(char **) NULL); - token[0] = ','; /* used this token - get another */ - } - if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) && - (image->matte != MagickFalse)) - { - while ( token[0] == ',' ) GetMagickToken(p,&p,token); - if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' ) - break; - sparse_arguments[x++]=StringToDouble(token,(char **) NULL); - token[0] = ','; /* used this token - get another */ - } + if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0) + { + while ( token[0] == ',' ) GetMagickToken(p,&p,token); + if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' ) + break; + sparse_arguments[x++]=StringToDouble(token,(char **) NULL); + token[0] = ','; /* used this token - get another */ + } + if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0) + { + while ( token[0] == ',' ) GetMagickToken(p,&p,token); + if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' ) + break; + sparse_arguments[x++]=StringToDouble(token,(char **) NULL); + token[0] = ','; /* used this token - get another */ + } + if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) && + (image->colorspace == CMYKColorspace)) + { + while ( token[0] == ',' ) GetMagickToken(p,&p,token); + if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' ) + break; + sparse_arguments[x++]=StringToDouble(token,(char **) NULL); + token[0] = ','; /* used this token - get another */ + } + if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) && + (image->matte != MagickFalse)) + { + while ( token[0] == ',' ) GetMagickToken(p,&p,token); + if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' ) + break; + sparse_arguments[x++]=StringToDouble(token,(char **) NULL); + token[0] = ','; /* used this token - get another */ } } } @@ -363,7 +339,7 @@ static Image *SparseColorOption(const Image *image, if ( error ) return( (Image *)NULL); - /* Call the Interpolation function with the parsed arguments */ + /* Call the Sparse Color Interpolation function with the parsed arguments */ sparse_image=SparseColorImage(image,method,number_arguments,sparse_arguments, exception); sparse_arguments=(double *) RelinquishMagickMemory(sparse_arguments); @@ -386,15 +362,15 @@ static Image *SparseColorOption(const Image *image, % used when processing the images also found within the wand. % % These options do no require images to be present in the wand for them to be -% able to be set, in which case they will be applied to +% able to be set, in which case they will be applied to % % Options handled by this function are listed in CommandOptions[] of % "option.c" that is one of "SettingOptionFlags" option flags. % % The format of the WandSettingOptionInfo method is: % -% MagickBooleanType WandSettingOptionInfo(MagickWand *wand, -% const char *option, const char *arg, ExceptionInfo *exception) +% void WandSettingOptionInfo(MagickWand *wand,const char *option, +% const char *arg) % % A description of each parameter follows: % @@ -404,10 +380,7 @@ static Image *SparseColorOption(const Image *image, % % o arg: The single argument used to set this option. % If NULL the setting is reset to its default value. -% For boolean (no argument) settings NULL=false, any_string=true -% -% o exception: return any errors or warnings in this structure. -% +% For boolean (no argument) settings false=NULL, true=any_string % % Example usage... % @@ -426,13 +399,11 @@ static Image *SparseColorOption(const Image *image, % WandSettingOptionInfo(wand, argv[i]+1, % (((*argv[i])!='-') ? (char *)NULL % : (count>0) ? argv[i+1] : "true") ); -% exception); -% ... % i += count+1; % */ -WandExport MagickBooleanType WandSettingOptionInfo(MagickWand *wand, - const char *option, const char *arg) +WandExport void WandSettingOptionInfo(MagickWand *wand,const char *option, + const char *arg) { assert(wand != (MagickWand *) NULL); assert(wand->signature == WandSignature); @@ -459,7 +430,7 @@ WandExport MagickBooleanType WandSettingOptionInfo(MagickWand *wand, } if (LocaleCompare("affine",option) == 0) { - /* DEPRECIATED: draw_info setting only */ + /* DEPRECIATED: draw_info setting only: for -draw and -transform */ if (IfSetOption) (void) ParseAffineGeometry(arg,&draw_info->affine,exception); else @@ -473,6 +444,11 @@ WandExport MagickBooleanType WandSettingOptionInfo(MagickWand *wand, draw_info->text_antialias = ArgBoolean; break; } + if (LocaleCompare("attenuate",option+1) == 0) + { + (void) SetImageOption(image_info,option,ArgOption(NULL)); + break; + } if (LocaleCompare("authenticate",option) == 0) { (void) SetImageOption(image_info,option,ArgOption(NULL)); @@ -501,8 +477,8 @@ WandExport MagickBooleanType WandSettingOptionInfo(MagickWand *wand, if (LocaleCompare("bias",option) == 0) { /* FUTURE: bias OBSOLETED, replaced by "convolve:bias" - as it is actually rarely used except in direct convolve - Usage outside direct convolve is actally non-sensible! + as it is actually rarely used except in direct convolve operations + Usage outside a direct convolve operation is actally non-sensible! SyncImageSettings() used to set per-image attribute. */ @@ -577,7 +553,9 @@ WandExport MagickBooleanType WandSettingOptionInfo(MagickWand *wand, } if (LocaleCompare("channel",option) == 0) { - /* This is applied to images in SimpleImageOperator!!! */ + /* This is applied to images in SimpleImageOperator!!! + FUTURE: move it to SyncImageSettings() - or alternative + */ image_info->channel=(ChannelType) ( IfSetOption ? ParseChannelOption(arg) : DefaultChannels ); break; @@ -1034,8 +1012,8 @@ WandExport MagickBooleanType WandSettingOptionInfo(MagickWand *wand, } if (LocaleCompare("monitor",option) == 0) { - (void) SetImageInfoProgressMonitor(image_info,MonitorProgress, - (void *) NULL); + (void) SetImageInfoProgressMonitor(image_info, IfSetOption? + MonitorProgress: (MagickProgressMonitor) NULL, (void *) NULL); break; } if (LocaleCompare("monochrome",option) == 0) @@ -1325,6 +1303,12 @@ WandExport MagickBooleanType WandSettingOptionInfo(MagickWand *wand, &image_info->transparent_color,exception); break; } + if (LocaleCompare("treedepth",option) == 0) + { + (void) SetImageOption(image_info,option,ArgOption(NULL)); + quantize_info->tree_depth=StringToUnsignedLong(ArgOption("0")); + break; + } if (LocaleCompare("type",option) == 0) { /* SyncImageSettings() used to set per-image attribute. */ @@ -1364,6 +1348,7 @@ WandExport MagickBooleanType WandSettingOptionInfo(MagickWand *wand, /* FUTURE: Also an image artifact, set in Simple Operators. But artifact is only used in verbose output. */ + (void) SetImageOption(image_info,option,ArgOption(NULL)); image_info->verbose= ArgBoolean; image_info->ping=MagickFalse; /* verbose can't be a ping */ break; @@ -1431,43 +1416,30 @@ WandExport MagickBooleanType WandSettingOptionInfo(MagickWand *wand, #undef ArgOption #undef ArgBoolean - return(MagickTrue); + return; } -#if 0 /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % -+ W a n d S i m p l e O p e r a t o r I m a g e % ++ W a n d S i m p l e O p e r a t o r I m a g e s % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % -% WandSimpleOperatorImage() apples one simple image operation given as -% strings to the current image pointed to by the CLI wand, with the settings -% that are saved in the CLI wand. -% -% The image in the list may be modified in three different ways... -% -% * directly modified (EG: -negate, -gamma, -level, -annotate, -draw), -% * replaced by a new image (EG: -spread, -resize, -rotate, -morphology) -% * one image replace by a list of images (-separate and -crop only!) -% -% In each case the result replaces the original image in the list, as well as -% the pointer to the modified image (last image added if replaced by a list -% of images) is returned. As the image pointed to may be replaced, the first -% image in the list may also change. GetFirstImageInList() should be used by -% caller if they wish return the Image pointer to the first image in list. +% WandSimpleOperatorImages() applys one simple image operation given to all +% the images in the current wand, with the settings that are saved in the +% CLI wand. % % It is assumed that any per-image settings are up-to-date with respect to % extra settings that have been saved in the wand. % % The format of the WandSimpleOperatorImage method is: % -% MagickBooleanType WandSimpleOperatorImage(MagickWand *wand, +% void WandSimpleOperatorImages(MagickWand *wand, % const MagickBooleanType plus_alt_op, const char *option, % const char *arg1, const char *arg2) % @@ -1481,14 +1453,17 @@ WandExport MagickBooleanType WandSettingOptionInfo(MagickWand *wand, % % o arg1, arg2: optional argument strings to the operation % -% o exception: return any errors or warnings in this structure. -% +% Any problems will be added to the 'exception' entry of the given wand. % -% Example usage +% Example usage... % -% WandSimpleOperatorImage(wand,MagickFalse,"append",NULL,NULL); -% WandSimpleOperatorImage(wand,MagickFalse,"crop","100x100+20+30",NULL); -% WandSimpleOperatorImage(wand,MagickTrue,"distort","SRT","45"); +% WandSimpleOperatorImages(wand,MagickFalse,"crop","100x100+20+30",NULL); +% WandSimpleOperatorImages(wand,MagickTrue,"repage",NULL,NULL); +% WandSimpleOperatorImages(wand,MagickTrue,"distort","SRT","45"); +% if ( wand->exception->severity != UndefinedException ) { +% CatchException(exception); +% exit(1); +% } % % Or for handling command line arguments EG: +/-option ["arg"] % @@ -1498,14 +1473,32 @@ WandExport MagickBooleanType WandSettingOptionInfo(MagickWand *wand, % count=ParseCommandOption(MagickCommandOptions,MagickFalse,argv[i]); % flags=GetCommandOptionFlags(MagickCommandOptions,MagickFalse,argv[i]); % if ( flags == SimpleOperatorOptionFlag ) -% WandSimpleOperatorImage(wand, +% WandSimpleOperatorImages(wand, % (MagickBooleanType)(*argv[i])=='+'), argv[i]+1, % count>=1 ? argv[i+1] : (char *)NULL, % count>=2 ? argv[i+2] : (char *)NULL ); % i += count+1; % */ -WandExport MagickBooleanType WandSimpleOperatorImage(MagickWand *wand, + +/* + Internal subrountine to apply one simple image operation to the current + image pointed to by the wand. + + The image in the list may be modified in three different ways... + * directly modified (EG: -negate, -gamma, -level, -annotate, -draw), + * replaced by a new image (EG: -spread, -resize, -rotate, -morphology) + * one image replace by a list of images (-separate and -crop only!) + + In each case the result replaces the original image in the list, as well as + the pointer to the modified image (last image added if replaced by a list + of images) is returned. + + As the image pointed to may be replaced, the first image in the list may + also change. GetFirstImageInList() should be used by caller if they wish + return the Image pointer to the first image in list. +*/ +static void WandSimpleOperatorImage(MagickWand *wand, const MagickBooleanType plus_alt_op, const char *option, const char *arg1, const char *arg2) { @@ -1518,23 +1511,21 @@ WandExport MagickBooleanType WandSimpleOperatorImage(MagickWand *wand, RectangleInfo geometry; - MagickStatusType - status; - MagickStatusType flags; #define image_info (wand->image_info) #define draw_info (wand->draw_info) #define quantize_info (wand->quantize_info) -#define image (&wand->image) -#define exception (&wand->exception) +#define image (wand->images) +#define exception (wand->exception) +#define normal_op (plus_alt_op?MagickFalse:MagickTrue) assert(image_info != (const ImageInfo *) NULL); assert(image_info->signature == MagickSignature); - assert(wand->draw_info != (DrawInfo *) NULL); /* ensure it is a CLI wand */ - assert((*image) != (Image *) NULL); /* there is an image */ - assert((*image)->signature == MagickSignature); /* and is a valid image */ + assert(draw_info != (DrawInfo *) NULL); /* ensure it is a CLI wand */ + assert(image != (Image *) NULL); /* there is an image */ + assert(image->signature == MagickSignature); /* and is a valid image */ if (wand->debug != MagickFalse) (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name); @@ -1546,7 +1537,7 @@ WandExport MagickBooleanType WandSimpleOperatorImage(MagickWand *wand, /* FUTURE: We may need somthing a little more optimized than this! Perhaps, do the 'sync' if 'settings tainted' before next operator. */ - (void) SyncImageSettings(image_info,*image,exception); + (void) SyncImageSettings(image_info,image,exception); switch (*option) { @@ -1559,28 +1550,25 @@ WandExport MagickBooleanType WandSimpleOperatorImage(MagickWand *wand, geometry_info.sigma=1.0; if ((flags & XiValue) == 0) geometry_info.xi=0.0; - new_image=AdaptiveBlurImage(*image,geometry_info.rho, + new_image=AdaptiveBlurImage(image,geometry_info.rho, geometry_info.sigma,geometry_info.xi,exception); break; } if (LocaleCompare("adaptive-resize",option) == 0) { - (void) ParseRegionGeometry(*image,arg1,&geometry,exception); - new_image=AdaptiveResizeImage(*image,geometry.width,geometry.height, + (void) ParseRegionGeometry(image,arg1,&geometry,exception); + new_image=AdaptiveResizeImage(image,geometry.width,geometry.height, exception); break; } if (LocaleCompare("adaptive-sharpen",option) == 0) { - /* - Adaptive sharpen image. - */ flags=ParseGeometry(arg1,&geometry_info); if ((flags & SigmaValue) == 0) geometry_info.sigma=1.0; if ((flags & XiValue) == 0) geometry_info.xi=0.0; - new_image=AdaptiveSharpenImage(*image,geometry_info.rho, + new_image=AdaptiveSharpenImage(image,geometry_info.rho, geometry_info.sigma,geometry_info.xi,exception); break; } @@ -1591,7 +1579,7 @@ WandExport MagickBooleanType WandSimpleOperatorImage(MagickWand *wand, alpha_type=(AlphaChannelType) ParseCommandOption(MagickAlphaOptions, MagickFalse,arg1); - (void) SetImageAlphaChannel(*image,alpha_type,exception); + (void) SetImageAlphaChannel(image,alpha_type,exception); break; } if (LocaleCompare("annotate",option) == 0) @@ -1604,7 +1592,7 @@ WandExport MagickBooleanType WandSimpleOperatorImage(MagickWand *wand, flags=ParseGeometry(arg1,&geometry_info); if ((flags & SigmaValue) == 0) geometry_info.sigma=geometry_info.rho; - text=InterpretImageProperties(image_info,*image,arg2, + text=InterpretImageProperties(image_info,image,arg2, exception); if (text == (char *) NULL) break; @@ -1621,63 +1609,57 @@ WandExport MagickBooleanType WandSimpleOperatorImage(MagickWand *wand, fmod(geometry_info.sigma,360.0)))); draw_info->affine.sy=cos(DegreesToRadians( fmod(geometry_info.sigma,360.0))); - (void) AnnotateImage(*image,draw_info,exception); + (void) AnnotateImage(image,draw_info,exception); GetAffineMatrix(&draw_info->affine); break; } if (LocaleCompare("auto-gamma",option) == 0) { - /* - Auto Adjust Gamma of image based on its mean - */ - (void) AutoGammaImage(*image,exception); + (void) AutoGammaImage(image,exception); break; } if (LocaleCompare("auto-level",option) == 0) { - /* - A Perfect Normalize (max/min stretch) the image - */ - (void) AutoLevelImage(*image,exception); + (void) AutoLevelImage(image,exception); break; } if (LocaleCompare("auto-orient",option) == 0) { - switch ((*image)->orientation) + switch (image->orientation) { case TopRightOrientation: { - new_image=FlopImage(*image,exception); + new_image=FlopImage(image,exception); break; } case BottomRightOrientation: { - new_image=RotateImage(*image,180.0,exception); + new_image=RotateImage(image,180.0,exception); break; } case BottomLeftOrientation: { - new_image=FlipImage(*image,exception); + new_image=FlipImage(image,exception); break; } case LeftTopOrientation: { - new_image=TransposeImage(*image,exception); + new_image=TransposeImage(image,exception); break; } case RightTopOrientation: { - new_image=RotateImage(*image,90.0,exception); + new_image=RotateImage(image,90.0,exception); break; } case RightBottomOrientation: { - new_image=TransverseImage(*image,exception); + new_image=TransverseImage(image,exception); break; } case LeftBottomOrientation: { - new_image=RotateImage(*image,270.0,exception); + new_image=RotateImage(image,270.0,exception); break; } default: @@ -1693,7 +1675,7 @@ WandExport MagickBooleanType WandSimpleOperatorImage(MagickWand *wand, { if (LocaleCompare("black-threshold",option) == 0) { - (void) BlackThresholdImage(*image,arg1,exception); + (void) BlackThresholdImage(image,arg1,exception); break; } if (LocaleCompare("blue-shift",option) == 0) @@ -1701,7 +1683,7 @@ WandExport MagickBooleanType WandSimpleOperatorImage(MagickWand *wand, geometry_info.rho=1.5; if (plus_alt_op == MagickFalse) flags=ParseGeometry(arg1,&geometry_info); - new_image=BlueShiftImage(*image,geometry_info.rho,exception); + new_image=BlueShiftImage(image,geometry_info.rho,exception); break; } if (LocaleCompare("blur",option) == 0) @@ -1712,13 +1694,13 @@ WandExport MagickBooleanType WandSimpleOperatorImage(MagickWand *wand, geometry_info.sigma=1.0; if ((flags & XiValue) == 0) geometry_info.xi=0.0; - new_image=BlurImage(*image,geometry_info.rho, + new_image=BlurImage(image,geometry_info.rho, geometry_info.sigma,geometry_info.xi,exception); break; } if (LocaleCompare("border",option) == 0) { - ComposeOperator + CompositeOperator compose; const char* @@ -1731,10 +1713,10 @@ WandExport MagickBooleanType WandSimpleOperatorImage(MagickWand *wand, else compose=OverCompositeOp; /* use Over not image->compose */ - flags=ParsePageGeometry(*image,arg1,&geometry,exception); + flags=ParsePageGeometry(image,arg1,&geometry,exception); if ((flags & SigmaValue) == 0) geometry.height=geometry.width; - new_image=BorderImage(*image,&geometry,compose,exception); + new_image=BorderImage(image,&geometry,compose,exception); break; } if (LocaleCompare("brightness-contrast",option) == 0) @@ -1754,7 +1736,7 @@ WandExport MagickBooleanType WandSimpleOperatorImage(MagickWand *wand, contrast=0.0; if ((flags & SigmaValue) != 0) contrast=geometry_info.sigma; - (void) BrightnessContrastImage(*image,brightness,contrast, + (void) BrightnessContrastImage(image,brightness,contrast, exception); break; } @@ -1773,7 +1755,7 @@ WandExport MagickBooleanType WandSimpleOperatorImage(MagickWand *wand, color_correction_collection=FileToString(arg1,~0,exception); if (color_correction_collection == (char *) NULL) break; - (void) ColorDecisionListImage(*image,color_correction_collection, + (void) ColorDecisionListImage(image,color_correction_collection, exception); break; } @@ -1783,7 +1765,7 @@ WandExport MagickBooleanType WandSimpleOperatorImage(MagickWand *wand, FUTURE: This probably should be part of WandSettingOptionInfo() or SyncImageSettings(). */ - SetPixelChannelMapMask(*image,image_info->channel); + SetPixelChannelMapMask(image,image_info->channel); break; } if (LocaleCompare("charcoal",option) == 0) @@ -1793,27 +1775,27 @@ WandExport MagickBooleanType WandSimpleOperatorImage(MagickWand *wand, geometry_info.sigma=1.0; if ((flags & XiValue) == 0) geometry_info.xi=1.0; - new_image=CharcoalImage(*image,geometry_info.rho, + new_image=CharcoalImage(image,geometry_info.rho, geometry_info.sigma,geometry_info.xi,exception); break; } if (LocaleCompare("chop",option) == 0) { - (void) ParseGravityGeometry(*image,arg1,&geometry,exception); - new_image=ChopImage(*image,&geometry,exception); + (void) ParseGravityGeometry(image,arg1,&geometry,exception); + new_image=ChopImage(image,&geometry,exception); break; } if (LocaleCompare("clamp",option) == 0) { - (void) ClampImage(*image,exception); + (void) ClampImage(image,exception); break; } if (LocaleCompare("clip",option) == 0) { if (plus_alt_op == MagickFalse) - (void) ClipImage(*image,exception); + (void) ClipImage(image,exception); else /* "+clip" remove the write mask */ - (void) SetImageMask(*image,(Image *) NULL,exception); + (void) SetImageMask(image,(Image *) NULL,exception); break; } if (LocaleCompare("clip-mask",option) == 0) @@ -1835,7 +1817,7 @@ WandExport MagickBooleanType WandSimpleOperatorImage(MagickWand *wand, if (plus_alt_op != MagickFalse) { /* "+clip-mask" Remove the write mask */ - (void) SetImageMask(*image,(Image *) NULL,exception); + (void) SetImageMask(image,(Image *) NULL,exception); break; } mask_image=GetImageCache(image_info,arg1,exception); @@ -1843,8 +1825,8 @@ WandExport MagickBooleanType WandSimpleOperatorImage(MagickWand *wand, break; if (SetImageStorageClass(mask_image,DirectClass,exception) == MagickFalse) - return(MagickFalse); - /* create a write mask from clip-mask image */ + break; + /* Create a write mask from clip-mask image */ /* FUTURE: use Alpha operations instead and create a Grey Image */ mask_view=AcquireCacheView(mask_image); for (y=0; y < (ssize_t) mask_image->rows; y++) @@ -1868,19 +1850,19 @@ WandExport MagickBooleanType WandSimpleOperatorImage(MagickWand *wand, /* clean up and set the write mask */ mask_view=DestroyCacheView(mask_view); mask_image->matte=MagickTrue; - (void) SetImageMask(*image,mask_image,exception); + (void) SetImageMask(image,mask_image,exception); mask_image=DestroyImage(mask_image); break; } if (LocaleCompare("clip-path",option) == 0) { - (void) ClipImagePath(*image,arg1, + (void) ClipImagePath(image,arg1, (MagickBooleanType)(!(int)plus_alt_op),exception); break; } if (LocaleCompare("colorize",option) == 0) { - new_image=ColorizeImage(*image,arg1,draw_info->fill,exception); + new_image=ColorizeImage(image,arg1,&draw_info->fill,exception); break; } if (LocaleCompare("color-matrix",option) == 0) @@ -1891,7 +1873,7 @@ WandExport MagickBooleanType WandSimpleOperatorImage(MagickWand *wand, kernel=AcquireKernelInfo(arg1); if (kernel == (KernelInfo *) NULL) break; - new_image=ColorMatrixImage(*image,kernel,exception); + new_image=ColorMatrixImage(image,kernel,exception); kernel=DestroyKernelInfo(kernel); break; } @@ -1903,29 +1885,33 @@ WandExport MagickBooleanType WandSimpleOperatorImage(MagickWand *wand, quantize_info->number_colors=StringToUnsignedLong(arg1); if (quantize_info->number_colors == 0) break; - if (((*image)->storage_class == DirectClass) || - (*image)->colors > quantize_info->number_colors) - (void) QuantizeImage(quantize_info,*image,exception); + if ((image->storage_class == DirectClass) || + image->colors > quantize_info->number_colors) + (void) QuantizeImage(quantize_info,image,exception); else - (void) CompressImageColormap(*image,exception); + (void) CompressImageColormap(image,exception); break; } if (LocaleCompare("colorspace",option) == 0) { - /* This is a Image Setting, which should already been set */ - /* FUTURE: default colorspace should be sRGB! + /* WARNING: this is both a image_info setting (already done) + and a operator to change image colorspace. + + FUTURE: default colorspace should be sRGB! Unless some type of 'linear colorspace' mode is set. + Note that +colorspace sets "undefined" or no effect on new images, but forces images already in memory back to RGB! + That seems to be a little strange! */ - (void) TransformImageColorspace(*image, - IfSetOption ? image_info->colorspace : RGBColorspace, + (void) TransformImageColorspace(image, + plus_alt_op ? RGBColorspace : image_info->colorspace, exception); break; } if (LocaleCompare("contrast",option) == 0) { - (void) ContrastImage(*image, + (void) ContrastImage(image, (MagickBooleanType)(!(int)plus_alt_op),exception); break; } @@ -1938,21 +1924,18 @@ WandExport MagickBooleanType WandSimpleOperatorImage(MagickWand *wand, MagickStatusType flags; - /* - Contrast stretch image. - */ flags=ParseGeometry(arg1,&geometry_info); black_point=geometry_info.rho; white_point=(flags & SigmaValue) != 0 ? geometry_info.sigma : black_point; if ((flags & PercentValue) != 0) { - black_point*=(double) (*image)->columns*(*image)->rows/100.0; - white_point*=(double) (*image)->columns*(*image)->rows/100.0; + black_point*=(double) image->columns*image->rows/100.0; + white_point*=(double) image->columns*image->rows/100.0; } - white_point=(MagickRealType) (*image)->columns*(*image)->rows- + white_point=(MagickRealType) image->columns*image->rows- white_point; - (void) ContrastStretchImage(*image,black_point,white_point, + (void) ContrastStretchImage(image,black_point,white_point, exception); break; } @@ -1964,19 +1947,20 @@ WandExport MagickBooleanType WandSimpleOperatorImage(MagickWand *wand, kernel_info=AcquireKernelInfo(arg1); if (kernel_info == (KernelInfo *) NULL) break; - kernel_info->bias=(*image)->bias; - new_image=ConvolveImage(*image,kernel_info,exception); + kernel_info->bias=image->bias; + new_image=ConvolveImage(image,kernel_info,exception); kernel_info=DestroyKernelInfo(kernel_info); break; } if (LocaleCompare("crop",option) == 0) { - new_image=CropImageToTiles(*image,arg1,exception); + /* WARNING: This can generate multiple images! */ + new_image=CropImageToTiles(image,arg1,exception); break; } if (LocaleCompare("cycle",option) == 0) { - (void) CycleColormapImage(*image,(ssize_t) StringToLong(arg1), + (void) CycleColormapImage(image,(ssize_t) StringToLong(arg1), exception); break; } @@ -1992,24 +1976,24 @@ WandExport MagickBooleanType WandSimpleOperatorImage(MagickWand *wand, passkey=FileToStringInfo(arg1,~0,exception); if (passkey != (StringInfo *) NULL) { - (void) PasskeyDecipherImage(*image,passkey,exception); + (void) PasskeyDecipherImage(image,passkey,exception); passkey=DestroyStringInfo(passkey); } break; } -#if 0 if (LocaleCompare("depth",option) == 0) { /* The image_info->depth setting has already been set We just need to apply it to all images in current sequence + WARNING: Depth from 8 to 16 causes 'quantum rounding to images! That is it really is an operation, not a setting! Arrgghhh + FUTURE: this should not be an operator!!! */ - (void) SetImageDepth(*image,image_info->depth); + (void) SetImageDepth(image,image_info->depth,exception); break; } -#endif if (LocaleCompare("deskew",option) == 0) { double @@ -2019,12 +2003,12 @@ WandExport MagickBooleanType WandSimpleOperatorImage(MagickWand *wand, threshold=40.0*QuantumRange/100.0; else threshold=StringToDoubleInterval(arg1,(double) QuantumRange+1.0); - new_image=DeskewImage(*image,threshold,exception); + new_image=DeskewImage(image,threshold,exception); break; } if (LocaleCompare("despeckle",option) == 0) { - new_image=DespeckleImage(*image,exception); + new_image=DespeckleImage(image,exception); break; } if (LocaleCompare("distort",option) == 0) @@ -2048,9 +2032,6 @@ WandExport MagickBooleanType WandSimpleOperatorImage(MagickWand *wand, size_t number_arguments; - /* - Distort image. - */ method=(DistortImageMethod) ParseCommandOption(MagickDistortOptions, MagickFalse,arg1); if (method == ResizeDistortion) @@ -2061,16 +2042,16 @@ WandExport MagickBooleanType WandSimpleOperatorImage(MagickWand *wand, ** Convert that to an appropriate distortion argument array. ** FUTURE: make a separate special resize operator */ - (void) ParseRegionGeometry(*image,arg2,&geometry, + (void) ParseRegionGeometry(image,arg2,&geometry, exception); resize_args[0]=(double) geometry.width; resize_args[1]=(double) geometry.height; - new_image=DistortImage(*image,method,(size_t)2, + new_image=DistortImage(image,method,(size_t)2, resize_args,MagickTrue,exception); break; } /* handle percent arguments */ - args=InterpretImageProperties(image_info,*image,arg2, + args=InterpretImageProperties(image_info,image,arg2, exception); if (args == (char *) NULL) break; @@ -2091,7 +2072,7 @@ WandExport MagickBooleanType WandSimpleOperatorImage(MagickWand *wand, sizeof(*arguments)); if (arguments == (double *) NULL) ThrowWandFatalException(ResourceLimitFatalError, - "MemoryAllocationFailed",(*image)->filename); + "MemoryAllocationFailed",image->filename); (void) ResetMagickMemory(arguments,0,number_arguments* sizeof(*arguments)); p=(char *) args; @@ -2103,7 +2084,7 @@ WandExport MagickBooleanType WandSimpleOperatorImage(MagickWand *wand, arguments[x]=StringToDouble(token,(char **) NULL); } args=DestroyString(args); - new_image=DistortImage(*image,method,number_arguments,arguments, + new_image=DistortImage(image,method,number_arguments,arguments, plus_alt_op,exception); arguments=(double *) RelinquishMagickMemory(arguments); break; @@ -2111,7 +2092,7 @@ WandExport MagickBooleanType WandSimpleOperatorImage(MagickWand *wand, if (LocaleCompare("draw",option) == 0) { (void) CloneString(&draw_info->primitive,arg1); - (void) DrawImage(*image,draw_info,exception); + (void) DrawImage(image,draw_info,exception); (void) CloneString(&draw_info->primitive,(char *)NULL); break; } @@ -2124,7 +2105,7 @@ WandExport MagickBooleanType WandSimpleOperatorImage(MagickWand *wand, flags=ParseGeometry(arg1,&geometry_info); if ((flags & SigmaValue) == 0) geometry_info.sigma=1.0; - new_image=EdgeImage(*image,geometry_info.rho, + new_image=EdgeImage(image,geometry_info.rho, geometry_info.sigma,exception); break; } @@ -2133,7 +2114,7 @@ WandExport MagickBooleanType WandSimpleOperatorImage(MagickWand *wand, flags=ParseGeometry(arg1,&geometry_info); if ((flags & SigmaValue) == 0) geometry_info.sigma=1.0; - new_image=EmbossImage(*image,geometry_info.rho, + new_image=EmbossImage(image,geometry_info.rho, geometry_info.sigma,exception); break; } @@ -2145,19 +2126,19 @@ WandExport MagickBooleanType WandSimpleOperatorImage(MagickWand *wand, passkey=FileToStringInfo(arg1,~0,exception); if (passkey != (StringInfo *) NULL) { - (void) PasskeyEncipherImage(*image,passkey,exception); + (void) PasskeyEncipherImage(image,passkey,exception); passkey=DestroyStringInfo(passkey); } break; } if (LocaleCompare("enhance",option) == 0) { - new_image=EnhanceImage(*image,exception); + new_image=EnhanceImage(image,exception); break; } if (LocaleCompare("equalize",option) == 0) { - (void) EqualizeImage(*image,exception); + (void) EqualizeImage(image,exception); break; } if (LocaleCompare("evaluate",option) == 0) @@ -2171,17 +2152,17 @@ WandExport MagickBooleanType WandSimpleOperatorImage(MagickWand *wand, op=(MagickEvaluateOperator) ParseCommandOption( MagickEvaluateOptions,MagickFalse,arg1); constant=StringToDoubleInterval(arg2,(double) QuantumRange+1.0); - (void) EvaluateImage(*image,op,constant,exception); + (void) EvaluateImage(image,op,constant,exception); break; } if (LocaleCompare("extent",option) == 0) { - flags=ParseGravityGeometry(*image,arg1,&geometry,exception); + flags=ParseGravityGeometry(image,arg1,&geometry,exception); if (geometry.width == 0) - geometry.width=(*image)->columns; + geometry.width=image->columns; if (geometry.height == 0) - geometry.height=(*image)->rows; - new_image=ExtentImage(*image,&geometry,exception); + geometry.height=image->rows; + new_image=ExtentImage(image,&geometry,exception); break; } break; @@ -2190,19 +2171,24 @@ WandExport MagickBooleanType WandSimpleOperatorImage(MagickWand *wand, { if (LocaleCompare("features",option) == 0) { - /* FUTURE: make this a Setting */ - (void) SetImageArtifact(*image,"identify:features", - (plus_alt_op != MagickFalse) ? arg1 : (char *) NULL); + /* FUTURE: move to SyncImageSettings() and AcqireImage()??? */ + if (plus_alt_op != MagickFalse) + { + (void) DeleteImageArtifact(image,"identify:features"); + break; + } + (void) SetImageArtifact(image,"identify:features","true"); + (void) SetImageArtifact(image,"verbose","true"); break; } if (LocaleCompare("flip",option) == 0) { - new_image=FlipImage(*image,exception); + new_image=FlipImage(image,exception); break; } if (LocaleCompare("flop",option) == 0) { - new_image=FlopImage(*image,exception); + new_image=FlopImage(image,exception); break; } if (LocaleCompare("floodfill",option) == 0) @@ -2210,9 +2196,9 @@ WandExport MagickBooleanType WandSimpleOperatorImage(MagickWand *wand, PixelInfo target; - (void) ParsePageGeometry(*image,arg1,&geometry,exception); + (void) ParsePageGeometry(image,arg1,&geometry,exception); (void) QueryColorCompliance(arg2,AllCompliance,&target,exception); - (void) FloodfillPaintImage(*image,draw_info,&target,geometry.x, + (void) FloodfillPaintImage(image,draw_info,&target,geometry.x, geometry.y,plus_alt_op,exception); break; } @@ -2221,7 +2207,7 @@ WandExport MagickBooleanType WandSimpleOperatorImage(MagickWand *wand, FrameInfo frame_info; - ComposeOperator + CompositeOperator compose; const char* @@ -2234,7 +2220,7 @@ WandExport MagickBooleanType WandSimpleOperatorImage(MagickWand *wand, else compose=OverCompositeOp; /* use Over not image->compose */ - flags=ParsePageGeometry(*image,arg1,&geometry,exception); + flags=ParsePageGeometry(image,arg1,&geometry,exception); frame_info.width=geometry.width; frame_info.height=geometry.height; if ((flags & HeightValue) == 0) @@ -2243,9 +2229,9 @@ WandExport MagickBooleanType WandSimpleOperatorImage(MagickWand *wand, frame_info.inner_bevel=geometry.y; frame_info.x=(ssize_t) frame_info.width; frame_info.y=(ssize_t) frame_info.height; - frame_info.width=(*image)->columns+2*frame_info.width; - frame_info.height=(*image)->rows+2*frame_info.height; - new_image=FrameImage(*image,&frame_info,compose,exception); + frame_info.width=image->columns+2*frame_info.width; + frame_info.height=image->rows+2*frame_info.height; + new_image=FrameImage(image,&frame_info,compose,exception); break; } if (LocaleCompare("function",option) == 0) @@ -2275,7 +2261,7 @@ WandExport MagickBooleanType WandSimpleOperatorImage(MagickWand *wand, */ function=(MagickFunction) ParseCommandOption(MagickFunctionOptions, MagickFalse,arg1); - arguments=InterpretImageProperties(image_info,*image,arg2, + arguments=InterpretImageProperties(image_info,image,arg2, exception); if (arguments == (char *) NULL) break; @@ -2291,7 +2277,7 @@ WandExport MagickBooleanType WandSimpleOperatorImage(MagickWand *wand, sizeof(*parameters)); if (parameters == (double *) NULL) ThrowWandFatalException(ResourceLimitFatalError, - "MemoryAllocationFailed",(*image)->filename); + "MemoryAllocationFailed",image->filename); (void) ResetMagickMemory(parameters,0,number_parameters* sizeof(*parameters)); p=(char *) arguments; @@ -2303,7 +2289,7 @@ WandExport MagickBooleanType WandSimpleOperatorImage(MagickWand *wand, parameters[x]=StringToDouble(token,(char **) NULL); } arguments=DestroyString(arguments); - (void) FunctionImage(*image,function,number_parameters,parameters, + (void) FunctionImage(image,function,number_parameters,parameters, exception); parameters=(double *) RelinquishMagickMemory(parameters); break; @@ -2314,10 +2300,10 @@ WandExport MagickBooleanType WandSimpleOperatorImage(MagickWand *wand, { if (LocaleCompare("gamma",option) == 0) { - if (plus_alt_op) - (*image)->gamma=StringToDouble(arg1,(char **) NULL); + if (plus_alt_op != MagickFalse) + image->gamma=StringToDouble(arg1,(char **) NULL); else - (void) GammaImage(*image,StringToDouble(arg1,(char **) NULL), + (void) GammaImage(image,StringToDouble(arg1,(char **) NULL), exception); break; } @@ -2327,30 +2313,30 @@ WandExport MagickBooleanType WandSimpleOperatorImage(MagickWand *wand, flags=ParseGeometry(arg1,&geometry_info); if ((flags & SigmaValue) == 0) geometry_info.sigma=1.0; - new_image=GaussianBlurImage(*image,geometry_info.rho, + new_image=GaussianBlurImage(image,geometry_info.rho, geometry_info.sigma,exception); break; } -/* ------------- */ if (LocaleCompare("geometry",option) == 0) { /* - Record Image offset for composition. This should be a setting! - Resize last image. -- FUTURE depreciate this aspect - Also why is it being recorded in the IMAGE - that makes no sense! + Record Image offset for composition. (A Setting) + Resize last image. (ListOperator) + FUTURE: Why if no 'offset' does this resize ALL images? + Also why is the setting recorded in the IMAGE non-sense! */ - if (plus_alt_op) + if (plus_alt_op != MagickFalse) { /* remove the previous composition geometry offset! */ - if ((*image)->geometry != (char *) NULL) - (*image)->geometry=DestroyString((*image)->geometry); + if (image->geometry != (char *) NULL) + image->geometry=DestroyString(image->geometry); break; } - flags=ParseRegionGeometry(*image,arg1,&geometry,exception); + flags=ParseRegionGeometry(image,arg1,&geometry,exception); if (((flags & XValue) != 0) || ((flags & YValue) != 0)) - (void) CloneString(&(*image)->geometry,arg1); + (void) CloneString(&image->geometry,arg1); else - new_image=ResizeImage(*image,geometry.width,geometry.height, - (*image)->filter,(*image)->blur,exception); + new_image=ResizeImage(image,geometry.width,geometry.height, + image->filter,image->blur,exception); break; } break; @@ -2359,7 +2345,7 @@ WandExport MagickBooleanType WandSimpleOperatorImage(MagickWand *wand, { if (LocaleCompare("highlight-color",option) == 0) { - (void) SetImageArtifact(*image,option,arg1); + (void) SetImageArtifact(image,option,arg1); break; } break; @@ -2368,39 +2354,37 @@ WandExport MagickBooleanType WandSimpleOperatorImage(MagickWand *wand, { if (LocaleCompare("identify",option) == 0) { - char + const char + *format, *text; + format=GetImageOption(image_info,"format"); if (format == (char *) NULL) { - (void) IdentifyImage(*image,stdout,image_info->verbose, + (void) IdentifyImage(image,stdout,image_info->verbose, exception); break; } - text=InterpretImageProperties(image_info,*image,format, - exception); + text=InterpretImageProperties(image_info,image,format,exception); if (text == (char *) NULL) break; (void) fputs(text,stdout); (void) fputc('\n',stdout); - text=DestroyString(text); + text=DestroyString((char *)text); break; } if (LocaleCompare("implode",option) == 0) { - /* - Implode image. - */ (void) ParseGeometry(arg1,&geometry_info); - new_image=ImplodeImage(*image,geometry_info.rho, - (*image)->interpolate,exception); + new_image=ImplodeImage(image,geometry_info.rho, + image->interpolate,exception); break; } if (LocaleCompare("interpolative-resize",option) == 0) { - (void) ParseRegionGeometry(*image,arg1,&geometry,exception); - new_image=InterpolativeResizeImage(*image,geometry.width, - geometry.height,(*image)->interpolate,exception); + (void) ParseRegionGeometry(image,arg1,&geometry,exception); + new_image=InterpolativeResizeImage(image,geometry.width, + geometry.height,image->interpolate,exception); break; } break; @@ -2409,15 +2393,12 @@ WandExport MagickBooleanType WandSimpleOperatorImage(MagickWand *wand, { if (LocaleCompare("lat",option) == 0) { - /* - Local adaptive threshold image. - */ flags=ParseGeometry(arg1,&geometry_info); if ((flags & PercentValue) != 0) geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0; - new_image=AdaptiveThresholdImage(*image,(size_t) - geometry_info.rho,(size_t) geometry_info.sigma,(double) - geometry_info.xi,exception); + new_image=AdaptiveThresholdImage(image,(size_t) geometry_info.rho, + (size_t) geometry_info.sigma,(double) geometry_info.xi, + exception); break; } if (LocaleCompare("level",option) == 0) @@ -2430,9 +2411,6 @@ WandExport MagickBooleanType WandSimpleOperatorImage(MagickWand *wand, MagickStatusType flags; - /* - Parse levels. - */ flags=ParseGeometry(arg1,&geometry_info); black_point=geometry_info.rho; white_point=(MagickRealType) QuantumRange; @@ -2448,11 +2426,11 @@ WandExport MagickBooleanType WandSimpleOperatorImage(MagickWand *wand, } if ((flags & SigmaValue) == 0) white_point=(MagickRealType) QuantumRange-black_point; - if ((*argv[0] == '+') || ((flags & AspectValue) != 0)) - (void) LevelizeImage(*image,black_point,white_point,gamma, + if (plus_alt_op || ((flags & AspectValue) != 0)) + (void) LevelizeImage(image,black_point,white_point,gamma, exception); else - (void) LevelImage(*image,black_point,white_point,gamma, + (void) LevelImage(image,black_point,white_point,gamma, exception); break; } @@ -2491,8 +2469,8 @@ WandExport MagickBooleanType WandSimpleOperatorImage(MagickWand *wand, (void) QueryColorCompliance("#ffffff",AllCompliance, &white_point,exception); } - (void) LevelImageColors(*image,&black_point,&white_point, - *argv[0] == '+' ? MagickTrue : MagickFalse,exception); + (void) LevelImageColors(image,&black_point,&white_point, + plus_alt_op,exception); break; } if (LocaleCompare("linear-stretch",option) == 0) @@ -2506,37 +2484,34 @@ WandExport MagickBooleanType WandSimpleOperatorImage(MagickWand *wand, flags=ParseGeometry(arg1,&geometry_info); black_point=geometry_info.rho; - white_point=(MagickRealType) (*image)->columns*(*image)->rows; + white_point=(MagickRealType) image->columns*image->rows; if ((flags & SigmaValue) != 0) white_point=geometry_info.sigma; if ((flags & PercentValue) != 0) { - black_point*=(double) (*image)->columns*(*image)->rows/100.0; - white_point*=(double) (*image)->columns*(*image)->rows/100.0; + black_point*=(double) image->columns*image->rows/100.0; + white_point*=(double) image->columns*image->rows/100.0; } if ((flags & SigmaValue) == 0) - white_point=(MagickRealType) (*image)->columns*(*image)->rows- + white_point=(MagickRealType) image->columns*image->rows- black_point; - (void) LinearStretchImage(*image,black_point,white_point,exception); + (void) LinearStretchImage(image,black_point,white_point,exception); break; } if (LocaleCompare("liquid-rescale",option) == 0) { - /* - Liquid rescale image. - */ - flags=ParseRegionGeometry(*image,arg1,&geometry,exception); + flags=ParseRegionGeometry(image,arg1,&geometry,exception); if ((flags & XValue) == 0) geometry.x=1; if ((flags & YValue) == 0) geometry.y=0; - new_image=LiquidRescaleImage(*image,geometry.width, + new_image=LiquidRescaleImage(image,geometry.width, geometry.height,1.0*geometry.x,1.0*geometry.y,exception); break; } if (LocaleCompare("lowlight-color",option) == 0) { - (void) SetImageArtifact(*image,option,arg1); + (void) SetImageArtifact(image,option,arg1); break; } break; @@ -2548,15 +2523,11 @@ WandExport MagickBooleanType WandSimpleOperatorImage(MagickWand *wand, Image *remap_image; - /* - Transform image colors to match this set of colors. - */ - if (*argv[0] == '+') - break; + /* DEPRECIATED use -remap */ remap_image=GetImageCache(image_info,arg1,exception); if (remap_image == (Image *) NULL) break; - (void) RemapImage(quantize_info,*image,remap_image,exception); + (void) RemapImage(quantize_info,image,remap_image,exception); remap_image=DestroyImage(remap_image); break; } @@ -2565,75 +2536,49 @@ WandExport MagickBooleanType WandSimpleOperatorImage(MagickWand *wand, Image *mask; - if (*argv[0] == '+') - { - /* - Remove a mask. - */ - (void) SetImageMask(*image,(Image *) NULL,exception); + if (plus_alt_op != MagickFalse) + { /* Remove a mask. */ + (void) SetImageMask(image,(Image *) NULL,exception); break; } - /* - Set the image mask. - */ + /* Set the image mask. */ mask=GetImageCache(image_info,arg1,exception); if (mask == (Image *) NULL) break; - (void) SetImageMask(*image,mask,exception); + (void) SetImageMask(image,mask,exception); mask=DestroyImage(mask); break; } if (LocaleCompare("matte",option) == 0) { - /* Depreciated */ - (void) SetImageAlphaChannel(*image,(*argv[0] == '-') ? - SetAlphaChannel : DeactivateAlphaChannel,exception); - break; - } - if (LocaleCompare("median",option) == 0) - { - /* - Median filter image. - */ - flags=ParseGeometry(arg1,&geometry_info); - if ((flags & SigmaValue) == 0) - geometry_info.sigma=geometry_info.rho; - new_image=StatisticImage(*image,MedianStatistic,(size_t) - geometry_info.rho,(size_t) geometry_info.sigma,exception); + /* DEPRECIATED */ + (void) SetImageAlphaChannel(image,plus_alt_op ? + DeactivateAlphaChannel:SetAlphaChannel ,exception); break; } if (LocaleCompare("mode",option) == 0) { - /* - Mode image. - */ flags=ParseGeometry(arg1,&geometry_info); if ((flags & SigmaValue) == 0) geometry_info.sigma=geometry_info.rho; - new_image=StatisticImage(*image,ModeStatistic,(size_t) + new_image=StatisticImage(image,ModeStatistic,(size_t) geometry_info.rho,(size_t) geometry_info.sigma,exception); break; } if (LocaleCompare("modulate",option) == 0) { - (void) ModulateImage(*image,arg1,exception); + (void) ModulateImage(image,arg1,exception); break; } if (LocaleCompare("monitor",option) == 0) { - if (*argv[0] == '+') - { - (void) SetImageProgressMonitor(*image, - (MagickProgressMonitor) NULL,(void *) NULL); - break; - } - (void) SetImageProgressMonitor(*image,MonitorProgress, - (void *) NULL); + (void) SetImageProgressMonitor(image, plus_alt_op? + (MagickProgressMonitor) NULL:MonitorProgress,(void *) NULL); break; } if (LocaleCompare("monochrome",option) == 0) { - (void) SetImageType(*image,BilevelType,exception); + (void) SetImageType(image,BilevelType,exception); break; } if (LocaleCompare("morphology",option) == 0) @@ -2667,26 +2612,21 @@ WandExport MagickBooleanType WandSimpleOperatorImage(MagickWand *wand, if (kernel == (KernelInfo *) NULL) { (void) ThrowMagickException(exception,GetMagickModule(), - OptionError,"UnabletoParseKernel","morphology"); - status=MagickFalse; + OptionError,"UnabletoParseKernel","morphology"); break; } - new_image=MorphologyImage(*image,method,iterations,kernel, - exception); + new_image=MorphologyImage(image,method,iterations,kernel,exception); kernel=DestroyKernelInfo(kernel); break; } if (LocaleCompare("motion-blur",option) == 0) { - /* - Motion blur image. - */ flags=ParseGeometry(arg1,&geometry_info); if ((flags & SigmaValue) == 0) geometry_info.sigma=1.0; - new_image=MotionBlurImage(*image,geometry_info.rho, - geometry_info.sigma,geometry_info.xi,geometry_info.psi, - exception); + new_image=MotionBlurImage(image,geometry_info.rho, + geometry_info.sigma,geometry_info.xi,geometry_info.psi, + exception); break; } break; @@ -2695,18 +2635,17 @@ WandExport MagickBooleanType WandSimpleOperatorImage(MagickWand *wand, { if (LocaleCompare("negate",option) == 0) { - (void) NegateImage(*image,*argv[0] == '+' ? MagickTrue : - MagickFalse,exception); + (void) NegateImage(image, plus_alt_op, exception); break; } if (LocaleCompare("noise",option) == 0) { - if (*argv[0] == '-') + if (plus_alt_op == MagickFalse) { flags=ParseGeometry(arg1,&geometry_info); if ((flags & SigmaValue) == 0) geometry_info.sigma=geometry_info.rho; - new_image=StatisticImage(*image,NonpeakStatistic,(size_t) + new_image=StatisticImage(image,NonpeakStatistic,(size_t) geometry_info.rho,(size_t) geometry_info.sigma,exception); } else @@ -2714,15 +2653,28 @@ WandExport MagickBooleanType WandSimpleOperatorImage(MagickWand *wand, NoiseType noise; + double + attenuate; + + const char* + value; + noise=(NoiseType) ParseCommandOption(MagickNoiseOptions, - MagickFalse,arg1); - new_image=AddNoiseImage(*image,noise,exception); + MagickFalse,arg1), + + value=GetImageOption(image_info,"attenuate"); + if (value != (const char *) NULL) + attenuate=StringToDouble(value,(char **) NULL); + else + attenuate=1.0; + + new_image=AddNoiseImage(image,noise,attenuate,exception); } break; } if (LocaleCompare("normalize",option) == 0) { - (void) NormalizeImage(*image,exception); + (void) NormalizeImage(image,exception); break; } break; @@ -2734,15 +2686,14 @@ WandExport MagickBooleanType WandSimpleOperatorImage(MagickWand *wand, PixelInfo target; - (void) QueryColorCompliance(arg1,AllCompliance,&target, - exception); - (void) OpaquePaintImage(*image,&target,&fill,*argv[0] == '-' ? - MagickFalse : MagickTrue,exception); + (void) QueryColorCompliance(arg1,AllCompliance,&target,exception); + (void) OpaquePaintImage(image,&target,&draw_info->fill,plus_alt_op, + exception); break; } if (LocaleCompare("ordered-dither",option) == 0) { - (void) OrderedPosterizeImage(*image,arg1,exception); + (void) OrderedPosterizeImage(image,arg1,exception); break; } break; @@ -2752,8 +2703,8 @@ WandExport MagickBooleanType WandSimpleOperatorImage(MagickWand *wand, if (LocaleCompare("paint",option) == 0) { (void) ParseGeometry(arg1,&geometry_info); - new_image=OilPaintImage(*image,geometry_info.rho, - geometry_info.sigma,exception); + new_image=OilPaintImage(image,geometry_info.rho,geometry_info.sigma, + exception); break; } if (LocaleCompare("polaroid",option) == 0) @@ -2764,33 +2715,31 @@ WandExport MagickBooleanType WandSimpleOperatorImage(MagickWand *wand, double angle; - RandomInfo - *random_info; + if (plus_alt_op != MagickFalse) + { + RandomInfo + *random_info; - /* - Simulate a Polaroid picture. - */ - random_info=AcquireRandomInfo(); - angle=22.5*(GetPseudoRandomValue(random_info)-0.5); - random_info=DestroyRandomInfo(random_info); - if (*argv[0] == '-') + random_info=AcquireRandomInfo(); + angle=22.5*(GetPseudoRandomValue(random_info)-0.5); + random_info=DestroyRandomInfo(random_info); + } + else { SetGeometryInfo(&geometry_info); flags=ParseGeometry(arg1,&geometry_info); angle=geometry_info.rho; } - caption=GetImageProperty(*image,"caption",exception); - new_image=PolaroidImage(*image,draw_info,caption,angle, - (*image)->interpolate,exception); + caption=GetImageProperty(image,"caption",exception); + new_image=PolaroidImage(image,draw_info,caption,angle, + image->interpolate,exception); break; } if (LocaleCompare("posterize",option) == 0) { - /* - Posterize image. - */ - (void) PosterizeImage(*image,StringToUnsignedLong(arg1), - quantize_info->dither,exception); + (void) ParseGeometry(arg1,&geometry_info); + (void) PosterizeImage(image,(size_t) geometry_info.rho, + quantize_info->dither,exception); break; } if (LocaleCompare("preview",option) == 0) @@ -2798,15 +2747,14 @@ WandExport MagickBooleanType WandSimpleOperatorImage(MagickWand *wand, PreviewType preview_type; - /* - Preview image. + /* FUTURE: should be a 'Genesis' option? + Option however is also in WandSettingOptionInfo() */ - if (*argv[0] == '+') - preview_type=UndefinedPreview; - else - preview_type=(PreviewType) ParseCommandOption( - MagickPreviewOptions,MagickFalse,arg1); - new_image=PreviewImage(*image,preview_type,exception); + preview_type=UndefinedPreview; + if (plus_alt_op == MagickFalse) + preview_type=(PreviewType) ParseCommandOption(MagickPreviewOptions, + MagickFalse,arg1); + new_image=PreviewImage(image,preview_type,exception); break; } if (LocaleCompare("profile",option) == 0) @@ -2823,20 +2771,15 @@ WandExport MagickBooleanType WandSimpleOperatorImage(MagickWand *wand, ImageInfo *profile_info; - if (*argv[0] == '+') - { - /* - Remove a profile from the image. - */ - (void) ProfileImage(*image,arg1,(const unsigned char *) + if (plus_alt_op != MagickFalse) + { /* Remove a profile from the image. */ + (void) ProfileImage(image,arg1,(const unsigned char *) NULL,0,exception); break; } - /* - Associate a profile with the image. - */ + /* Associate a profile with the image. */ profile_info=CloneImageInfo(image_info); - profile=GetImageProfile(*image,"iptc"); + profile=GetImageProfile(image,"iptc"); if (profile != (StringInfo *) NULL) profile_info->profile=(void *) CloneStringInfo(profile); profile_image=GetImageCache(profile_info,arg1,exception); @@ -2852,7 +2795,7 @@ WandExport MagickBooleanType WandSimpleOperatorImage(MagickWand *wand, profile=FileToStringInfo(profile_info->filename,~0UL,exception); if (profile != (StringInfo *) NULL) { - (void) ProfileImage(*image,profile_info->magick, + (void) ProfileImage(image,profile_info->magick, GetStringInfoDatum(profile),(size_t) GetStringInfoLength(profile),exception); profile=DestroyStringInfo(profile); @@ -2866,7 +2809,7 @@ WandExport MagickBooleanType WandSimpleOperatorImage(MagickWand *wand, { profile=GetImageProfile(profile_image,name); if (profile != (StringInfo *) NULL) - (void) ProfileImage(*image,name,GetStringInfoDatum(profile), + (void) ProfileImage(image,name,GetStringInfoDatum(profile), (size_t) GetStringInfoLength(profile),exception); name=GetNextImageProfile(profile_image); } @@ -2875,42 +2818,26 @@ WandExport MagickBooleanType WandSimpleOperatorImage(MagickWand *wand, } break; } - case 'q': - { - if (LocaleCompare("quantize",option) == 0) - { - if (*argv[0] == '+') - { - quantize_info->colorspace=UndefinedColorspace; - break; - } - quantize_info->colorspace=(ColorspaceType) ParseCommandOption( - MagickColorspaceOptions,MagickFalse,arg1); - break; - } - break; - } case 'r': { if (LocaleCompare("radial-blur",option) == 0) { flags=ParseGeometry(arg1,&geometry_info); - new_image=RadialBlurImage(*image,geometry_info.rho, + new_image=RadialBlurImage(image,geometry_info.rho, geometry_info.sigma,exception); break; } if (LocaleCompare("raise",option) == 0) { - flags=ParsePageGeometry(*image,arg1,&geometry,exception); + flags=ParsePageGeometry(image,arg1,&geometry,exception); if ((flags & SigmaValue) == 0) geometry.height=geometry.width; - (void) RaiseImage(*image,&geometry,*argv[0] == '-' ? MagickTrue : - MagickFalse,exception); + (void) RaiseImage(image,&geometry,normal_op,exception); break; } if (LocaleCompare("random-threshold",option) == 0) { - (void) RandomThresholdImage(*image,arg1,exception); + (void) RandomThresholdImage(image,arg1,exception); break; } if (LocaleCompare("remap",option) == 0) @@ -2918,61 +2845,56 @@ WandExport MagickBooleanType WandSimpleOperatorImage(MagickWand *wand, Image *remap_image; - if (*argv[0] == '+') - break; remap_image=GetImageCache(image_info,arg1,exception); if (remap_image == (Image *) NULL) break; - (void) RemapImage(quantize_info,*image,remap_image,exception); + (void) RemapImage(quantize_info,image,remap_image,exception); remap_image=DestroyImage(remap_image); break; } if (LocaleCompare("repage",option) == 0) { - if (*argv[0] == '+') - { - (void) ParseAbsoluteGeometry("0x0+0+0",&(*image)->page); - break; - } - (void) ResetImagePage(*image,arg1); + if (plus_alt_op == MagickFalse) + (void) ResetImagePage(image,arg1); + else + (void) ParseAbsoluteGeometry("0x0+0+0",&image->page); break; } if (LocaleCompare("resample",option) == 0) { - /* FUTURE: remove blur - no longer used */ + /* FUTURE: remove blur arguemnt - no longer used */ flags=ParseGeometry(arg1,&geometry_info); if ((flags & SigmaValue) == 0) geometry_info.sigma=geometry_info.rho; - new_image=ResampleImage(*image,geometry_info.rho, - geometry_info.sigma,(*image)->filter,(*image)->blur,exception); + new_image=ResampleImage(image,geometry_info.rho, + geometry_info.sigma,image->filter,image->blur,exception); break; } if (LocaleCompare("resize",option) == 0) { /* FUTURE: remove blur argument - no longer used */ - (void) ParseRegionGeometry(*image,arg1,&geometry,exception); - new_image=ResizeImage(*image,geometry.width,geometry.height, - (*image)->filter,(*image)->blur,exception); + (void) ParseRegionGeometry(image,arg1,&geometry,exception); + new_image=ResizeImage(image,geometry.width,geometry.height, + image->filter,image->blur,exception); break; } if (LocaleCompare("roll",option) == 0) { - (void) ParsePageGeometry(*image,arg1,&geometry,exception); - new_image=RollImage(*image,geometry.x,geometry.y,exception); + (void) ParsePageGeometry(image,arg1,&geometry,exception); + new_image=RollImage(image,geometry.x,geometry.y,exception); break; } if (LocaleCompare("rotate",option) == 0) { - /* special case rotation flags */ if (strchr(arg1,'>') != (char *) NULL) - if ((*image)->columns <= (*image)->rows) + if (image->columns <= image->rows) break; if (strchr(arg1,'<') != (char *) NULL) - if ((*image)->columns >= (*image)->rows) + if (image->columns >= image->rows) break; (void) ParseGeometry(arg1,&geometry_info); - new_image=RotateImage(*image,geometry_info.rho,exception); + new_image=RotateImage(image,geometry_info.rho,exception); break; } break; @@ -2981,15 +2903,15 @@ WandExport MagickBooleanType WandSimpleOperatorImage(MagickWand *wand, { if (LocaleCompare("sample",option) == 0) { - (void) ParseRegionGeometry(*image,arg1,&geometry,exception); - new_image=SampleImage(*image,geometry.width,geometry.height, + (void) ParseRegionGeometry(image,arg1,&geometry,exception); + new_image=SampleImage(image,geometry.width,geometry.height, exception); break; } if (LocaleCompare("scale",option) == 0) { - (void) ParseRegionGeometry(*image,arg1,&geometry,exception); - new_image=ScaleImage(*image,geometry.width,geometry.height, + (void) ParseRegionGeometry(image,arg1,&geometry,exception); + new_image=ScaleImage(image,geometry.width,geometry.height, exception); break; } @@ -2998,17 +2920,14 @@ WandExport MagickBooleanType WandSimpleOperatorImage(MagickWand *wand, flags=ParseGeometry(arg1,&geometry_info); if ((flags & PercentValue) != 0) geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0; - new_image=SelectiveBlurImage(*image,geometry_info.rho, + new_image=SelectiveBlurImage(image,geometry_info.rho, geometry_info.sigma,geometry_info.xi,geometry_info.psi,exception); break; } if (LocaleCompare("separate",option) == 0) { - /* - Break channels into separate images. - WARNING: This can generate multiple images! - */ - new_image=SeparateImages(*image,exception); + /* WARNING: This can generate multiple images! */ + new_image=SeparateImages(image,exception); break; } if (LocaleCompare("sepia-tone",option) == 0) @@ -3017,7 +2936,7 @@ WandExport MagickBooleanType WandSimpleOperatorImage(MagickWand *wand, threshold; threshold=StringToDoubleInterval(arg1,(double) QuantumRange+1.0); - new_image=SepiaToneImage(*image,threshold,exception); + new_image=SepiaToneImage(image,threshold,exception); break; } if (LocaleCompare("segment",option) == 0) @@ -3025,7 +2944,7 @@ WandExport MagickBooleanType WandSimpleOperatorImage(MagickWand *wand, flags=ParseGeometry(arg1,&geometry_info); if ((flags & SigmaValue) == 0) geometry_info.sigma=1.0; - (void) SegmentImage(*image,(*image)->colorspace, + (void) SegmentImage(image,image->colorspace, image_info->verbose,geometry_info.rho,geometry_info.sigma, exception); break; @@ -3035,21 +2954,21 @@ WandExport MagickBooleanType WandSimpleOperatorImage(MagickWand *wand, char *value; - if (*argv[0] == '+') + if (plus_alt_op != MagickFalse) { if (LocaleNCompare(arg1,"registry:",9) == 0) (void) DeleteImageRegistry(arg1+9); else - if (LocaleNCompare(arg1,"argv[0]:",7) == 0) + if (LocaleNCompare(arg1,"option:",7) == 0) { (void) DeleteImageOption(image_info,arg1+7); - (void) DeleteImageArtifact(*image,arg1+7); + (void) DeleteImageArtifact(image,arg1+7); } else - (void) DeleteImageProperty(*image,arg1); + (void) DeleteImageProperty(image,arg1); break; } - value=InterpretImageProperties(image_info,*image,arg2, + value=InterpretImageProperties(image_info,image,arg2, exception); if (value == (char *) NULL) break; @@ -3060,10 +2979,10 @@ WandExport MagickBooleanType WandSimpleOperatorImage(MagickWand *wand, if (LocaleNCompare(arg1,"option:",7) == 0) { (void) SetImageOption(image_info,arg1+7,value); - (void) SetImageArtifact(*image,arg1+7,value); + (void) SetImageArtifact(image,arg1+7,value); } else - (void) SetImageProperty(*image,arg1,value,exception); + (void) SetImageProperty(image,arg1,value,exception); value=DestroyString(value); break; } @@ -3072,8 +2991,8 @@ WandExport MagickBooleanType WandSimpleOperatorImage(MagickWand *wand, flags=ParseGeometry(arg1,&geometry_info); if ((flags & SigmaValue) == 0) geometry_info.sigma=1.0; - new_image=ShadeImage(*image,(*argv[0] == '-') ? MagickTrue : - MagickFalse,geometry_info.rho,geometry_info.sigma,exception); + new_image=ShadeImage(image,normal_op,geometry_info.rho, + geometry_info.sigma,exception); break; } if (LocaleCompare("shadow",option) == 0) @@ -3085,8 +3004,8 @@ WandExport MagickBooleanType WandSimpleOperatorImage(MagickWand *wand, geometry_info.xi=4.0; if ((flags & PsiValue) == 0) geometry_info.psi=4.0; - new_image=ShadowImage(*image,geometry_info.rho, - geometry_info.sigma,(*image)->bias,(ssize_t) + new_image=ShadowImage(image,geometry_info.rho, + geometry_info.sigma,image->bias,(ssize_t) ceil(geometry_info.xi-0.5),(ssize_t) ceil(geometry_info.psi-0.5), exception); break; @@ -3098,14 +3017,14 @@ WandExport MagickBooleanType WandSimpleOperatorImage(MagickWand *wand, geometry_info.sigma=1.0; if ((flags & XiValue) == 0) geometry_info.xi=0.0; - new_image=SharpenImage(*image,geometry_info.rho, + new_image=SharpenImage(image,geometry_info.rho, geometry_info.sigma,geometry_info.xi,exception); break; } if (LocaleCompare("shave",option) == 0) { - flags=ParsePageGeometry(*image,arg1,&geometry,exception); - new_image=ShaveImage(*image,&geometry,exception); + flags=ParsePageGeometry(image,arg1,&geometry,exception); + new_image=ShaveImage(image,&geometry,exception); break; } if (LocaleCompare("shear",option) == 0) @@ -3113,7 +3032,7 @@ WandExport MagickBooleanType WandSimpleOperatorImage(MagickWand *wand, flags=ParseGeometry(arg1,&geometry_info); if ((flags & SigmaValue) == 0) geometry_info.sigma=geometry_info.rho; - new_image=ShearImage(*image,geometry_info.rho, + new_image=ShearImage(image,geometry_info.rho, geometry_info.sigma,exception); break; } @@ -3125,8 +3044,8 @@ WandExport MagickBooleanType WandSimpleOperatorImage(MagickWand *wand, if ((flags & PercentValue) != 0) geometry_info.sigma=(double) QuantumRange*geometry_info.sigma/ 100.0; - (void) SigmoidalContrastImage(*image,(*argv[0] == '-') ? - MagickTrue : MagickFalse,geometry_info.rho,geometry_info.sigma, + (void) SigmoidalContrastImage(image,normal_op,geometry_info.rho, + geometry_info.sigma, exception); break; } @@ -3135,17 +3054,14 @@ WandExport MagickBooleanType WandSimpleOperatorImage(MagickWand *wand, flags=ParseGeometry(arg1,&geometry_info); if ((flags & SigmaValue) == 0) geometry_info.sigma=1.0; - new_image=SketchImage(*image,geometry_info.rho, + new_image=SketchImage(image,geometry_info.rho, geometry_info.sigma,geometry_info.xi,geometry_info.psi,exception); break; } if (LocaleCompare("solarize",option) == 0) { - double - threshold; - - threshold=StringToDoubleInterval(arg1,(double) QuantumRange+1.0); - (void) SolarizeImage(*image,threshold,exception); + (void) SolarizeImage(image,StringToDoubleInterval(arg1,(double) + QuantumRange+1.0),exception); break; } if (LocaleCompare("sparse-color",option) == 0) @@ -3158,26 +3074,24 @@ WandExport MagickBooleanType WandSimpleOperatorImage(MagickWand *wand, method=(SparseColorMethod) ParseCommandOption( MagickSparseColorOptions,MagickFalse,arg1); - arguments=InterpretImageProperties(image_info,*image,arg2, - exception); + arguments=InterpretImageProperties(image_info,image,arg2,exception); if (arguments == (char *) NULL) break; - new_image=SparseColorOption(*image,method,arguments, - argv[0][0] == '+' ? MagickTrue : MagickFalse,exception); + new_image=SparseColorOption(image,method,arguments,exception); arguments=DestroyString(arguments); break; } if (LocaleCompare("splice",option) == 0) { - (void) ParseGravityGeometry(*image,arg1,&geometry,exception); - new_image=SpliceImage(*image,&geometry,exception); + (void) ParseGravityGeometry(image,arg1,&geometry,exception); + new_image=SpliceImage(image,&geometry,exception); break; } if (LocaleCompare("spread",option) == 0) { (void) ParseGeometry(arg1,&geometry_info); - new_image=SpreadImage(*image,geometry_info.rho, - (*image)->interpolate,exception); + new_image=SpreadImage(image,geometry_info.rho,image->interpolate, + exception); break; } if (LocaleCompare("statistic",option) == 0) @@ -3188,20 +3102,20 @@ WandExport MagickBooleanType WandSimpleOperatorImage(MagickWand *wand, type=(StatisticType) ParseCommandOption(MagickStatisticOptions, MagickFalse,arg1); (void) ParseGeometry(arg2,&geometry_info); - new_image=StatisticImage(*image,type,(size_t) geometry_info.rho, + new_image=StatisticImage(image,type,(size_t) geometry_info.rho, (size_t) geometry_info.sigma,exception); break; } if (LocaleCompare("strip",option) == 0) { - (void) StripImage(*image,exception); + (void) StripImage(image,exception); break; } if (LocaleCompare("swirl",option) == 0) { (void) ParseGeometry(arg1,&geometry_info); - new_image=SwirlImage(*image,geometry_info.rho, - (*image)->interpolate,exception); + new_image=SwirlImage(image,geometry_info.rho, + image->interpolate,exception); break; } break; @@ -3213,32 +3127,29 @@ WandExport MagickBooleanType WandSimpleOperatorImage(MagickWand *wand, double threshold; - if (*argv[0] == '+') + if (plus_alt_op != MagickFalse) threshold=(double) QuantumRange/2; else threshold=StringToDoubleInterval(arg1,(double) QuantumRange+1.0); - (void) BilevelImage(*image,threshold,exception); + (void) BilevelImage(image,threshold,exception); break; } if (LocaleCompare("thumbnail",option) == 0) { - /* - Thumbnail image. - */ - (void) ParseRegionGeometry(*image,arg1,&geometry,exception); - new_image=ThumbnailImage(*image,geometry.width,geometry.height, + (void) ParseRegionGeometry(image,arg1,&geometry,exception); + new_image=ThumbnailImage(image,geometry.width,geometry.height, exception); break; } if (LocaleCompare("tint",option) == 0) { - new_image=TintImage(*image,arg1,&fill,exception); + new_image=TintImage(image,arg1,&draw_info->fill,exception); break; } if (LocaleCompare("transform",option) == 0) { /* DEPRECIATED */ - new_image=AffineTransformImage(*image,&draw_info->affine, + new_image=AffineTransformImage(image,&draw_info->affine, exception); break; } @@ -3247,37 +3158,30 @@ WandExport MagickBooleanType WandSimpleOperatorImage(MagickWand *wand, PixelInfo target; - (void) QueryColorCompliance(arg1,AllCompliance,&target, - exception); - (void) TransparentPaintImage(*image,&target,(Quantum) - TransparentAlpha,*argv[0] == '-' ? MagickFalse : MagickTrue, - exception); + (void) QueryColorCompliance(arg1,AllCompliance,&target,exception); + (void) TransparentPaintImage(image,&target,(Quantum) + TransparentAlpha,plus_alt_op,exception); break; } if (LocaleCompare("transpose",option) == 0) { - new_image=TransposeImage(*image,exception); + new_image=TransposeImage(image,exception); break; } if (LocaleCompare("transverse",option) == 0) { - new_image=TransverseImage(*image,exception); - break; - } - if (LocaleCompare("treedepth",option) == 0) - { - quantize_info->tree_depth=StringToUnsignedLong(arg1); + new_image=TransverseImage(image,exception); break; } if (LocaleCompare("trim",option) == 0) { - new_image=TrimImage(*image,exception); + new_image=TrimImage(image,exception); break; } if (LocaleCompare("type",option) == 0) { /* Note that "type" setting should have already been defined */ - (void) SetImageType(*image,type,exception); + (void) SetImageType(image,image_info->type,exception); break; } break; @@ -3286,18 +3190,19 @@ WandExport MagickBooleanType WandSimpleOperatorImage(MagickWand *wand, { if (LocaleCompare("unique",option) == 0) { - if (*argv[0] == '+') + /* FUTURE: move to SyncImageSettings() and AcqireImage()??? */ + if (plus_alt_op != MagickFalse) { - (void) DeleteImageArtifact(*image,"identify:unique-colors"); + (void) DeleteImageArtifact(image,"identify:unique-colors"); break; } - (void) SetImageArtifact(*image,"identify:unique-colors","true"); - (void) SetImageArtifact(*image,"verbose","true"); + (void) SetImageArtifact(image,"identify:unique-colors","true"); + (void) SetImageArtifact(image,"verbose","true"); break; } if (LocaleCompare("unique-colors",option) == 0) { - new_image=UniqueImageColors(*image,exception); + new_image=UniqueImageColors(image,exception); break; } if (LocaleCompare("unsharp",option) == 0) @@ -3309,7 +3214,7 @@ WandExport MagickBooleanType WandSimpleOperatorImage(MagickWand *wand, geometry_info.xi=1.0; if ((flags & PsiValue) == 0) geometry_info.psi=0.05; - new_image=UnsharpMaskImage(*image,geometry_info.rho, + new_image=UnsharpMaskImage(image,geometry_info.rho, geometry_info.sigma,geometry_info.xi,geometry_info.psi,exception); break; } @@ -3319,26 +3224,26 @@ WandExport MagickBooleanType WandSimpleOperatorImage(MagickWand *wand, { if (LocaleCompare("verbose",option) == 0) { - (void) SetImageArtifact(*image,option, - *argv[0] == '+' ? "false" : "true"); + /* FUTURE: move to SyncImageSettings() and AcqireImage()??? + three places! ImageArtifact ImageOption image_info->verbose + Some how new images also get this artifact -- how??? + */ + (void) SetImageArtifact(image,option, + (plus_alt_op != MagickFalse) ? "false" : "true" ); break; } if (LocaleCompare("vignette",option) == 0) { - /* - Vignette image. - */ flags=ParseGeometry(arg1,&geometry_info); if ((flags & SigmaValue) == 0) geometry_info.sigma=1.0; if ((flags & XiValue) == 0) - geometry_info.xi=0.1*(*image)->columns; + geometry_info.xi=0.1*image->columns; if ((flags & PsiValue) == 0) - geometry_info.psi=0.1*(*image)->rows; - new_image=VignetteImage(*image,geometry_info.rho, - geometry_info.sigma,(*image)->bias,(ssize_t) - ceil(geometry_info.xi-0.5),(ssize_t) ceil(geometry_info.psi-0.5), - exception); + geometry_info.psi=0.1*image->rows; + new_image=VignetteImage(image,geometry_info.rho,geometry_info.sigma, + image->bias,(ssize_t) ceil(geometry_info.xi-0.5), + (ssize_t) ceil(geometry_info.psi-0.5),exception); break; } break; @@ -3350,13 +3255,13 @@ WandExport MagickBooleanType WandSimpleOperatorImage(MagickWand *wand, flags=ParseGeometry(arg1,&geometry_info); if ((flags & SigmaValue) == 0) geometry_info.sigma=1.0; - new_image=WaveImage(*image,geometry_info.rho,geometry_info.sigma, - (*image)->interpolate,exception); + new_image=WaveImage(image,geometry_info.rho,geometry_info.sigma, + image->interpolate,exception); break; } if (LocaleCompare("white-threshold",option) == 0) { - (void) WhiteThresholdImage(*image,arg1,exception); + (void) WhiteThresholdImage(image,arg1,exception); break; } break; @@ -3366,23 +3271,48 @@ WandExport MagickBooleanType WandSimpleOperatorImage(MagickWand *wand, } /* Replace current image with any image that was generated + and set image point to last image (so image->next is correct) */ if (new_image != (Image *) NULL) - ReplaceImageInListReturnLast(image,new_image); - - /* - Free resources. - */ - quantize_info=DestroyQuantizeInfo(quantize_info); - draw_info=DestroyDrawInfo(draw_info); - status=(MagickStatusType) (exception->severity == UndefinedException ? 1 : 0); + ReplaceImageInListReturnLast(&image,new_image); + return; #undef image_info #undef draw_info #undef quantize_info +#undef image #undef exception +#undef normal_op +} + +WandExport void WandSimpleOperatorImages(MagickWand *wand, + const MagickBooleanType plus_alt_op, const char *option, + const char *arg1, const char *arg2) +{ + size_t + n; + + register ssize_t + i; - return(status == 0 ? MagickFalse : MagickTrue); + assert(wand->image_info != (const ImageInfo *) NULL); + assert(wand->image_info->signature == MagickSignature); + assert(wand->draw_info != (DrawInfo *) NULL); /* ensure it is a CLI wand */ + assert(wand->images != (Image *) NULL); /* there is one image */ + + i=0; + n=GetImageListLength(wand->images); + wand->images=GetFirstImageInList(wand->images); + for ( ; ; ) + { + WandSimpleOperatorImage(wand, plus_alt_op, option, arg1, arg2); + if ( wand->images->next == (Image *) NULL ) + break; + wand->images=wand->images->next; + i++; + } + wand->images=GetFirstImageInList(wand->images); + return; } /* @@ -3390,191 +3320,116 @@ WandExport MagickBooleanType WandSimpleOperatorImage(MagickWand *wand, % % % % % % -+ S e q u e n c e O p e r a t i o n I m a g e s % ++ W a n d L i s t O p e r a t o r I m a g e s % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % -% SequenceOperationImages() applies a single operation that apply to the -% entire image list (e.g. -append, -layers, -coalesce, etc.). +% WandListOperatorImages() applies a single operation that is apply to the +% entire image list as a whole. The result is often a complete replacment +% of the image list with a completely new list, or just a single image. % % The format of the MogrifyImage method is: % -% MagickBooleanType SequenceOperationImages(ImageInfo *image_info, -% const int argc, const char **argv,Image **images, -% ExceptionInfo *exception) +% void WandListOperatorImages(MagickWand *wand, +% const MagickBooleanType plus_alt_op, const char *option, +% const char *arg1, const char *arg2) % % A description of each parameter follows: % -% o image_info: the image info.. -% -% o argc: Specifies a pointer to an integer describing the number of -% elements in the argument vector. +% o wand: structure holding settings to be applied % -% o argv: Specifies a pointer to a text array containing the command line -% arguments. +% o plus_alt_op: request the 'plus' or alturnative form of the operation % -% o images: pointer to pointer of the first image in image list. +% o option: The option string for the operation % -% o exception: return any errors or warnings in this structure. +% o arg1, arg2: optional argument strings to the operation % */ -WandExport MagickBooleanType SequenceOperationImages(ImageInfo *image_info, - const int argc,const char **argv,Image **images,ExceptionInfo *exception) +WandExport void WandListOperatorImages(MagickWand *wand, + const MagickBooleanType plus_alt_op, const char *option, + const char *arg1, const char *arg2) { + Image + *new_images; - MagickStatusType - status; - - QuantizeInfo - *quantize_info; +#define image_info (wand->image_info) +#define draw_info (wand->draw_info) +#define quantize_info (wand->quantize_info) +#define images (wand->images) +#define exception (wand->exception) +#define normal_op (plus_alt_op?MagickFalse:MagickTrue) - assert(image_info != (ImageInfo *) NULL); + assert(image_info != (const ImageInfo *) NULL); assert(image_info->signature == MagickSignature); - assert(images != (Image **) NULL); - assert((*images)->previous == (Image *) NULL); - assert((*images)->signature == MagickSignature); - if ((*images)->debug != MagickFalse) - (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s", - (*images)->filename); - if ((argc <= 0) || (*argv == (char *) NULL)) - return(MagickTrue); - status=MagickTrue; + assert(draw_info != (DrawInfo *) NULL); /* ensure it is a CLI wand */ + assert(images != (Image *) NULL); /* there is an image */ + assert(images->signature == MagickSignature); /* and is a valid image */ - switch (*(argv[0]+1)) + if (wand->debug != MagickFalse) + (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name); + + (void) SyncImagesSettings(image_info,images,exception); + + new_images=NewImageList(); + + switch (*option) { case 'a': { - if (LocaleCompare("affinity",argv[0]+1) == 0) - { - (void) SyncImagesSettings(image_info,*images,exception); - if (*argv[0] == '+') - { - (void) RemapImages(quantize_info,*images,(Image *) NULL, - exception); - break; - } - break; - } - if (LocaleCompare("append",argv[0]+1) == 0) + if (LocaleCompare("append",option) == 0) { - Image - *append_image; - - (void) SyncImagesSettings(image_info,*images,exception); - append_image=AppendImages(*images,*argv[0] == '-' ? MagickTrue : - MagickFalse,exception); - if (append_image == (Image *) NULL) - { - status=MagickFalse; - break; - } - *images=DestroyImageList(*images); - *images=append_image; + new_images=AppendImages(images,normal_op,exception); break; } - if (LocaleCompare("average",argv[0]+1) == 0) + if (LocaleCompare("average",option) == 0) { - Image - *average_image; - - /* - Average an image sequence (deprecated). - */ - (void) SyncImagesSettings(image_info,*images,exception); - average_image=EvaluateImages(*images,MeanEvaluateOperator, - exception); - if (average_image == (Image *) NULL) - { - status=MagickFalse; - break; - } - *images=DestroyImageList(*images); - *images=average_image; + /* DEPRECIATED - use -evaluate-sequence Mean */ + WandListOperatorImages(wand,plus_alt_op,"evaluate-sequence","Mean", + NULL); break; } break; } case 'c': { - if (LocaleCompare("channel",argv[0]+1) == 0) - { - ChannelType - channel; - - if (*argv[0] == '+') - { - channel=DefaultChannels; - break; - } - channel=(ChannelType) ParseChannelOption(argv[1]); - SetPixelChannelMap(*images,channel); - break; - } - if (LocaleCompare("clut",argv[0]+1) == 0) + if (LocaleCompare("clut",option) == 0) { + /* FUTURE - make this a compose option (and thus layers compose ) + or perhaps compose last image over all other images. + */ Image - *clut_image, - *image; + *clut_image; - (void) SyncImagesSettings(image_info,*images,exception); - image=RemoveFirstImageFromList(images); - clut_image=RemoveFirstImageFromList(images); + new_images=RemoveFirstImageFromList(&images); + clut_image=RemoveLastImageFromList(&images); if (clut_image == (Image *) NULL) - { - status=MagickFalse; break; - } - (void) ClutImage(image,clut_image,(*image)->interpolate,exception); + (void) ClutImage(new_images,clut_image,images->interpolate,exception); clut_image=DestroyImage(clut_image); - *images=DestroyImageList(*images); - *images=image; break; } - if (LocaleCompare("coalesce",argv[0]+1) == 0) + if (LocaleCompare("coalesce",option) == 0) { - Image - *coalesce_image; - - (void) SyncImagesSettings(image_info,*images,exception); - coalesce_image=CoalesceImages(*images,exception); - if (coalesce_image == (Image *) NULL) - { - status=MagickFalse; - break; - } - *images=DestroyImageList(*images); - *images=coalesce_image; + new_images=CoalesceImages(images,exception); break; } - if (LocaleCompare("combine",argv[0]+1) == 0) + if (LocaleCompare("combine",option) == 0) { - Image - *combine_image; - - (void) SyncImagesSettings(image_info,*images,exception); - combine_image=CombineImages(*images,exception); - if (combine_image == (Image *) NULL) - { - status=MagickFalse; - break; - } - *images=DestroyImageList(*images); - *images=combine_image; + new_images=CombineImages(images,exception); break; } - if (LocaleCompare("composite",argv[0]+1) == 0) + if (LocaleCompare("composite",option) == 0) { Image *mask_image, - *composite_image, - *image; + *source_image; RectangleInfo geometry; - ComposeOperator + CompositeOperator compose; const char* @@ -3585,42 +3440,28 @@ WandExport MagickBooleanType SequenceOperationImages(ImageInfo *image_info, compose=(CompositeOperator) ParseCommandOption( MagickComposeOptions,MagickFalse,value); else - compose=OverCompositeOp; /* use Over not image->compose */ - - const char* - value=GetImageOption(image_info,"compose"); + compose=OverCompositeOp; /* use Over not source_image->compose */ - if (value != (const char *) NULL) - compose=(CompositeOperator) ParseCommandOption( - MagickComposeOptions,MagickFalse,value); - else - compose=OverCompositeOp; /* use Over not image->compose */ + new_images=RemoveFirstImageFromList(&images); + source_image=RemoveFirstImageFromList(&images); + if (source_image == (Image *) NULL) + break; + /* FUTURE - this should not be here! - should be part of -geometry */ + (void) TransformImage(&source_image,(char *) NULL, + source_image->geometry,exception); + SetGeometry(source_image,&geometry); + (void) ParseAbsoluteGeometry(source_image->geometry,&geometry); + GravityAdjustGeometry(new_images->columns,new_images->rows, + new_images->gravity, &geometry); - (void) SyncImagesSettings(image_info,*images,exception); - image=RemoveFirstImageFromList(images); - composite_image=RemoveFirstImageFromList(images); - if (composite_image == (Image *) NULL) - { - status=MagickFalse; - break; - } - (void) TransformImage(&composite_image,(char *) NULL, - composite_image->geometry,exception); - SetGeometry(composite_image,&geometry); - (void) ParseAbsoluteGeometry(composite_image->geometry,&geometry); - GravityAdjustGeometry(image->columns,image->rows,image->gravity, - &geometry); - mask_image=RemoveFirstImageFromList(images); + mask_image=RemoveFirstImageFromList(&images); if (mask_image != (Image *) NULL) - { + { /* handle a third write mask image */ if ((compose == DisplaceCompositeOp) || (compose == DistortCompositeOp)) - { - /* - Merge Y displacement into X displacement image. - */ - (void) CompositeImage(composite_image,CopyGreenCompositeOp, + { /* Merge Y displacement into X displace/distort map. */ + (void) CompositeImage(source_image,CopyGreenCompositeOp, mask_image,0,0,exception); mask_image=DestroyImage(mask_image); } @@ -3630,54 +3471,41 @@ WandExport MagickBooleanType SequenceOperationImages(ImageInfo *image_info, Set a blending mask for the composition. */ (void) NegateImage(mask_image,MagickFalse,exception); - (void) SetImageMask(image,mask_image,exception); + (void) SetImageMask(new_images,mask_image,exception); mask_image=DestroyImage(mask_image); } } - (void) CompositeImage(image,compose,composite_image, - geometry.x,geometry.y,exception); - (void) SetImageMask(image,(Image *) NULL,exception); - composite_image=DestroyImage(composite_image); - *images=DestroyImageList(*images); - *images=image; + (void) CompositeImage(new_images,compose,source_image,geometry.x, + geometry.y,exception); + (void) SetImageMask(new_images,(Image *) NULL,exception); + source_image=DestroyImage(source_image); break; } break; } case 'd': { - if (LocaleCompare("deconstruct",argv[0]+1) == 0) + if (LocaleCompare("deconstruct",option) == 0) { - Image - *deconstruct_image; - - (void) SyncImagesSettings(image_info,*images,exception); - deconstruct_image=CompareImagesLayers(*images,CompareAnyLayer, - exception); - if (deconstruct_image == (Image *) NULL) - { - status=MagickFalse; - break; - } - *images=DestroyImageList(*images); - *images=deconstruct_image; + /* DEPRECIATED - use -layers CompareAny */ + WandListOperatorImages(wand,plus_alt_op,"layer","CompareAny",NULL); break; } - if (LocaleCompare("delete",argv[0]+1) == 0) + if (LocaleCompare("delete",option) == 0) { - if (*argv[0] == '+') - DeleteImages(images,"-1",exception); + if (plus_alt_op != MagickFalse) + DeleteImages(&images,"-1",exception); else - DeleteImages(images,argv[1],exception); + DeleteImages(&images,arg1,exception); break; } - if (LocaleCompare("duplicate",argv[0]+1) == 0) + if (LocaleCompare("duplicate",option) == 0) { Image *duplicate_images; - if (*argv[0] == '+') - duplicate_images=DuplicateImages(*images,1,"-1",exception); + if (plus_alt_op != MagickFalse) + duplicate_images=DuplicateImages(images,1,"-1",exception); else { const char @@ -3686,209 +3514,140 @@ WandExport MagickBooleanType SequenceOperationImages(ImageInfo *image_info, size_t number_duplicates; - number_duplicates=(size_t) StringToLong(argv[1]); - p=strchr(argv[1],','); + number_duplicates=(size_t) StringToLong(arg1); + p=strchr(arg1,','); if (p == (const char *) NULL) - duplicate_images=DuplicateImages(*images,number_duplicates, + duplicate_images=DuplicateImages(images,number_duplicates, "-1",exception); else - duplicate_images=DuplicateImages(*images,number_duplicates,p, + duplicate_images=DuplicateImages(images,number_duplicates,p, exception); } - AppendImageToList(images, duplicate_images); - (void) SyncImagesSettings(image_info,*images,exception); + AppendImageToList(&images, duplicate_images); break; } break; } case 'e': { - if (LocaleCompare("evaluate-sequence",argv[0]+1) == 0) + if (LocaleCompare("evaluate-sequence",option) == 0) { - Image - *evaluate_image; - MagickEvaluateOperator - op; + method; - (void) SyncImageSettings(image_info,*images); - op=(MagickEvaluateOperator) ParseCommandOption( - MagickEvaluateOptions,MagickFalse,argv[1]); - evaluate_image=EvaluateImages(*images,op,exception); - if (evaluate_image == (Image *) NULL) - { - status=MagickFalse; - break; - } - *images=DestroyImageList(*images); - *images=evaluate_image; + method=(MagickEvaluateOperator) ParseCommandOption( + MagickEvaluateOptions,MagickFalse,arg1); + new_images=EvaluateImages(images,method,exception); break; } break; } case 'f': { - if (LocaleCompare("fft",argv[0]+1) == 0) + if (LocaleCompare("fft",option) == 0) { - Image - *fourier_image; - - /* - Implements the discrete Fourier transform (DFT). - */ - (void) SyncImageSettings(image_info,*images); - fourier_image=ForwardFourierTransformImage(*images,*argv[0] == '-' ? - MagickTrue : MagickFalse,exception); - if (fourier_image == (Image *) NULL) - break; - *images=DestroyImage(*images); - *images=fourier_image; + new_images=ForwardFourierTransformImage(images,normal_op,exception); break; } - if (LocaleCompare("flatten",argv[0]+1) == 0) + if (LocaleCompare("flatten",option) == 0) { - Image - *flatten_image; - - (void) SyncImagesSettings(image_info,*images,exception); - flatten_image=MergeImageLayers(*images,FlattenLayer,exception); - if (flatten_image == (Image *) NULL) - break; - *images=DestroyImageList(*images); - *images=flatten_image; + /* DEPRECIATED use -layers mosaic instead */ + WandListOperatorImages(wand,plus_alt_op,"layer",option,NULL); break; } - if (LocaleCompare("fx",argv[0]+1) == 0) + if (LocaleCompare("fx",option) == 0) { - Image - *fx_image; - - (void) SyncImagesSettings(image_info,*images,exception); - fx_image=FxImage(*images,argv[1],exception); - if (fx_image == (Image *) NULL) - { - status=MagickFalse; - break; - } - *images=DestroyImageList(*images); - *images=fx_image; + new_images=FxImage(images,arg1,exception); break; } break; } case 'h': { - if (LocaleCompare("hald-clut",argv[0]+1) == 0) + if (LocaleCompare("hald-clut",option) == 0) { + /* FUTURE - make this a compose option (and thus layers compose ) + or perhaps compose last image over all other images. + */ Image - *hald_image, - *image; + *hald_image; - (void) SyncImagesSettings(image_info,*images,exception); - image=RemoveFirstImageFromList(images); - hald_image=RemoveFirstImageFromList(images); + new_images=RemoveFirstImageFromList(&images); + hald_image=RemoveLastImageFromList(&images); if (hald_image == (Image *) NULL) - { - status=MagickFalse; - break; - } - (void) HaldClutImage(image,hald_image,exception); + break; + (void) HaldClutImage(new_images,hald_image,exception); hald_image=DestroyImage(hald_image); - if (*images != (Image *) NULL) - *images=DestroyImageList(*images); - *images=image; break; } break; } case 'i': { - if (LocaleCompare("ift",argv[0]+1) == 0) + if (LocaleCompare("ift",option) == 0) { Image - *fourier_image, *magnitude_image, *phase_image; - /* - Implements the inverse fourier discrete Fourier transform (DFT). - */ - (void) SyncImagesSettings(image_info,*images,exception); - magnitude_image=RemoveFirstImageFromList(images); - phase_image=RemoveFirstImageFromList(images); - if (phase_image == (Image *) NULL) - { - status=MagickFalse; - break; - } - fourier_image=InverseFourierTransformImage(magnitude_image, - phase_image,*argv[0] == '-' ? MagickTrue : MagickFalse,exception); - if (fourier_image == (Image *) NULL) - break; - if (*images != (Image *) NULL) - *images=DestroyImage(*images); - *images=fourier_image; + magnitude_image=RemoveFirstImageFromList(&images); + phase_image=RemoveFirstImageFromList(&images); + if (phase_image == (Image *) NULL) + break; + new_images=InverseFourierTransformImage(magnitude_image,phase_image, + normal_op,exception); + magnitude_image=DestroyImage(magnitude_image); + phase_image=DestroyImage(phase_image); break; } - if (LocaleCompare("insert",argv[0]+1) == 0) + if (LocaleCompare("insert",option) == 0) { Image - *p, - *q; + *insert_image, + *index_image; + + ssize_t + index; index=0; - if (*argv[0] != '+') - index=(ssize_t) StringToLong(argv[1]); - p=RemoveLastImageFromList(images); - if (p == (Image *) NULL) - { - (void) ThrowMagickException(exception,GetMagickModule(), - OptionError,"NoSuchImage","`%s'",argv[1]); - status=MagickFalse; - break; - } - q=p; + insert_image=RemoveLastImageFromList(&images); + if (plus_alt_op == MagickFalse) + index=(ssize_t) StringToLong(arg1); if (index == 0) - PrependImageToList(images,q); + PrependImageToList(&images,insert_image); else - if (index == (ssize_t) GetImageListLength(*images)) - AppendImageToList(images,q); + if (index == (ssize_t) GetImageListLength(images)) + AppendImageToList(&images,insert_image); else { - q=GetImageFromList(*images,index-1); - if (q == (Image *) NULL) + index_image=GetImageFromList(images,index-1); + if (index_image == (Image *) NULL) { (void) ThrowMagickException(exception,GetMagickModule(), - OptionError,"NoSuchImage","`%s'",argv[1]); - status=MagickFalse; + OptionError,"NoSuchImage","`%s'",arg1); break; } - InsertImageInList(&q,p); + InsertImageInList(&index_image,insert_image); } - *images=GetFirstImageInList(q); + images=GetFirstImageInList(index_image); break; } break; } case 'l': { - if (LocaleCompare("layers",argv[0]+1) == 0) + if (LocaleCompare("layers",option) == 0) { - Image - *layers; - ImageLayerMethod method; - (void) SyncImagesSettings(image_info,*images,exception); - layers=(Image *) NULL; method=(ImageLayerMethod) ParseCommandOption(MagickLayerOptions, - MagickFalse,argv[1]); + MagickFalse,arg1); switch (method) { case CoalesceLayer: { - layers=CoalesceImages(*images,exception); + new_images=CoalesceImages(images,exception); break; } case CompareAnyLayer: @@ -3896,7 +3655,7 @@ WandExport MagickBooleanType SequenceOperationImages(ImageInfo *image_info, case CompareOverlayLayer: default: { - layers=CompareImagesLayers(*images,method,exception); + new_images=CompareImagesLayers(images,method,exception); break; } case MergeLayer: @@ -3904,63 +3663,51 @@ WandExport MagickBooleanType SequenceOperationImages(ImageInfo *image_info, case MosaicLayer: case TrimBoundsLayer: { - layers=MergeImageLayers(*images,method,exception); + new_images=MergeImageLayers(images,method,exception); break; } case DisposeLayer: { - layers=DisposeImages(*images,exception); + new_images=DisposeImages(images,exception); break; } case OptimizeImageLayer: { - layers=OptimizeImageLayers(*images,exception); + new_images=OptimizeImageLayers(images,exception); break; } case OptimizePlusLayer: { - layers=OptimizePlusImageLayers(*images,exception); + new_images=OptimizePlusImageLayers(images,exception); break; } case OptimizeTransLayer: { - OptimizeImageTransparency(*images,exception); + OptimizeImageTransparency(images,exception); break; } case RemoveDupsLayer: { - RemoveDuplicateLayers(images,exception); + RemoveDuplicateLayers(&images,exception); break; } case RemoveZeroLayer: { - RemoveZeroDelayLayers(images,exception); + RemoveZeroDelayLayers(&images,exception); break; } case OptimizeLayer: - { - /* - General Purpose, GIF Animation Optimizer. - */ - layers=CoalesceImages(*images,exception); - if (layers == (Image *) NULL) - { - status=MagickFalse; - break; - } - *images=DestroyImageList(*images); - *images=layers; - layers=OptimizeImageLayers(*images,exception); - if (layers == (Image *) NULL) - { - status=MagickFalse; - break; - } - *images=DestroyImageList(*images); - *images=layers; - layers=(Image *) NULL; - OptimizeImageTransparency(*images,exception); - (void) RemapImages(quantize_info,*images,(Image *) NULL, + { /* General Purpose, GIF Animation Optimizer. */ + new_images=CoalesceImages(images,exception); + if (new_images == (Image *) NULL) + break; + images=DestroyImageList(images); + images=OptimizeImageLayers(new_images,exception); + if (images == (Image *) NULL) + break; + new_images=DestroyImageList(new_images); + OptimizeImageTransparency(images,exception); + (void) RemapImages(quantize_info,images,(Image *) NULL, exception); break; } @@ -3972,23 +3719,20 @@ WandExport MagickBooleanType SequenceOperationImages(ImageInfo *image_info, RectangleInfo geometry; - ComposeOperator + CompositeOperator compose; const char* value; value=GetImageOption(image_info,"compose"); + compose=OverCompositeOp; /* Default to Over */ if (value != (const char *) NULL) compose=(CompositeOperator) ParseCommandOption( MagickComposeOptions,MagickFalse,value); - else - compose=OverCompositeOp; /* use Over not image->compose */ - /* - Split image sequence at the first 'NULL:' image. - */ - source=(*images); + /* Split image sequence at the first 'NULL:' image. */ + source=images; while (source != (Image *) NULL) { source=GetNextImageInList(source); @@ -4002,10 +3746,7 @@ WandExport MagickBooleanType SequenceOperationImages(ImageInfo *image_info, (GetNextImageInList(source) == (Image *) NULL)) source=(Image *) NULL; else - { - /* - Separate the two lists, junk the null: image. - */ + { /* Separate the two lists, junk the null: image. */ source=SplitImageList(source->previous); DeleteImageFromList(&source); } @@ -4014,36 +3755,27 @@ WandExport MagickBooleanType SequenceOperationImages(ImageInfo *image_info, { (void) ThrowMagickException(exception,GetMagickModule(), OptionError,"MissingNullSeparator","layers Composite"); - status=MagickFalse; break; } - /* - Adjust offset with gravity and virtual canvas. - */ - SetGeometry(*images,&geometry); - (void) ParseAbsoluteGeometry((*images)->geometry,&geometry); + /* Adjust offset with gravity and virtual canvas. */ + SetGeometry(images,&geometry); + (void) ParseAbsoluteGeometry(images->geometry,&geometry); geometry.width=source->page.width != 0 ? source->page.width : source->columns; geometry.height=source->page.height != 0 ? source->page.height : source->rows; - GravityAdjustGeometry((*images)->page.width != 0 ? - (*images)->page.width : (*images)->columns, - (*images)->page.height != 0 ? (*images)->page.height : - (*images)->rows,(*images)->gravity,&geometry); + GravityAdjustGeometry(images->page.width != 0 ? + images->page.width : images->columns, + images->page.height != 0 ? images->page.height : + images->rows,images->gravity,&geometry); - /* - Compose the two image sequences together - */ - CompositeLayers(*images,compose,source,geometry.x,geometry.y, + /* Compose the two image sequences together */ + CompositeLayers(images,compose,source,geometry.x,geometry.y, exception); source=DestroyImageList(source); break; } } - if (layers == (Image *) NULL) - break; - *images=DestroyImageList(*images); - *images=layers; break; } if (LocaleCompare("limit",option) == 0) @@ -4054,14 +3786,11 @@ WandExport MagickBooleanType SequenceOperationImages(ImageInfo *image_info, ResourceType type; - if (!IfSetOption) - break; type=(ResourceType) ParseCommandOption(MagickResourceOptions, - MagickFalse,arg); + MagickFalse,arg1); limit=MagickResourceInfinity; - if (LocaleCompare("unlimited",arg[1]) != 0) - limit=(MagickSizeType) SiPrefixToDoubleInterval(argv[2], - 100.0); + if (LocaleCompare("unlimited",arg2) != 0) + limit=(MagickSizeType) SiPrefixToDoubleInterval(arg2,100.0); (void) SetMagickResourceLimit(type,limit); break; } @@ -4069,68 +3798,48 @@ WandExport MagickBooleanType SequenceOperationImages(ImageInfo *image_info, } case 'm': { - if (LocaleCompare("map",argv[0]+1) == 0) + if (LocaleCompare("map",option) == 0) { - (void) SyncImagesSettings(image_info,*images,exception); - if (*argv[0] == '+') - { - (void) RemapImages(quantize_info,*images,(Image *) NULL, - exception); - break; - } + /* DEPRECIATED use +remap */ + (void) RemapImages(quantize_info,images,(Image *) NULL,exception); break; } - if (LocaleCompare("morph",argv[0]+1) == 0) + if (LocaleCompare("morph",option) == 0) { Image *morph_image; - (void) SyncImagesSettings(image_info,*images,exception); - morph_image=MorphImages(*images,StringToUnsignedLong(argv[1]), + morph_image=MorphImages(images,StringToUnsignedLong(arg1), exception); if (morph_image == (Image *) NULL) - { - status=MagickFalse; - break; - } - *images=DestroyImageList(*images); - *images=morph_image; + break; + images=DestroyImageList(images); + images=morph_image; break; } - if (LocaleCompare("mosaic",argv[0]+1) == 0) + if (LocaleCompare("mosaic",option) == 0) { - Image - *mosaic_image; - - (void) SyncImagesSettings(image_info,*images,exception); - mosaic_image=MergeImageLayers(*images,MosaicLayer,exception); - if (mosaic_image == (Image *) NULL) - { - status=MagickFalse; - break; - } - *images=DestroyImageList(*images); - *images=mosaic_image; + /* DEPRECIATED use -layers mosaic instead */ + WandListOperatorImages(wand,plus_alt_op,"layer",option,NULL); break; } break; } case 'p': { - if (LocaleCompare("print",argv[0]+1) == 0) + if (LocaleCompare("print",option) == 0) { char *string; - (void) SyncImagesSettings(image_info,*images,exception); - string=InterpretImageProperties(image_info,*images,argv[1], + string=InterpretImageProperties(image_info,images,arg1, exception); if (string == (char *) NULL) break; (void) FormatLocaleFile(stdout,"%s",string); string=DestroyString(string); } - if (LocaleCompare("process",argv[0]+1) == 0) + if (LocaleCompare("process",option) == 0) { char **arguments; @@ -4139,11 +3848,10 @@ WandExport MagickBooleanType SequenceOperationImages(ImageInfo *image_info, j, number_arguments; - (void) SyncImagesSettings(image_info,*images,exception); - arguments=StringToArgv(argv[1],&number_arguments); + arguments=StringToArgv(arg1,&number_arguments); if (arguments == (char **) NULL) break; - if ((argc > 1) && (strchr(arguments[1],'=') != (char *) NULL)) + if (strchr(arguments[1],'=') != (char *) NULL) { char breaker, @@ -4166,7 +3874,7 @@ WandExport MagickBooleanType SequenceOperationImages(ImageInfo *image_info, /* Support old style syntax, filter="-option arg". */ - length=strlen(argv[1]); + length=strlen(arg1); token=(char *) NULL; if (~length >= (MaxTextExtent-1)) token=(char *) AcquireQuantumMemory(length+MaxTextExtent, @@ -4174,7 +3882,7 @@ WandExport MagickBooleanType SequenceOperationImages(ImageInfo *image_info, if (token == (char *) NULL) break; next=0; - arguments=argv[1]; + arguments=arg1; token_info=AcquireTokenInfo(); status=Tokenizer(token_info,0,token,length,arguments,"","=", "\"",'\0',&breaker,&next,"e); @@ -4185,14 +3893,14 @@ WandExport MagickBooleanType SequenceOperationImages(ImageInfo *image_info, *argv; argv=(&(arguments[next])); - (void) InvokeDynamicImageFilter(token,&(*images),1,&argv, + (void) InvokeDynamicImageFilter(token,&images,1,&argv, exception); } token=DestroyString(token); break; } (void) SubstituteString(&arguments[1],"-",""); - (void) InvokeDynamicImageFilter(arguments[1],&(*images), + (void) InvokeDynamicImageFilter(arguments[1],&images, number_arguments-2,(const char **) arguments+2,exception); for (j=0; j < number_arguments; j++) arguments[j]=DestroyString(arguments[j]); @@ -4203,16 +3911,22 @@ WandExport MagickBooleanType SequenceOperationImages(ImageInfo *image_info, } case 'r': { - if (LocaleCompare("reverse",argv[0]+1) == 0) + if (LocaleCompare("remap",option) == 0) + { + (void) RemapImages(quantize_info,images,(Image *) NULL,exception); + (void) RemapImages(quantize_info,images,(Image *) NULL,exception); + break; + } + if (LocaleCompare("reverse",option) == 0) { - ReverseImageList(images); + ReverseImageList(&images); break; } break; } case 's': { - if (LocaleCompare("smush",argv[0]+1) == 0) + if (LocaleCompare("smush",option) == 0) { Image *smush_image; @@ -4220,20 +3934,15 @@ WandExport MagickBooleanType SequenceOperationImages(ImageInfo *image_info, ssize_t offset; - (void) SyncImagesSettings(image_info,*images,exception); - offset=(ssize_t) StringToLong(argv[1]); - smush_image=SmushImages(*images,*argv[0] == '-' ? MagickTrue : - MagickFalse,offset,exception); + offset=(ssize_t) StringToLong(arg1); + smush_image=SmushImages(images,normal_op,offset,exception); if (smush_image == (Image *) NULL) - { - status=MagickFalse; - break; - } - *images=DestroyImageList(*images); - *images=smush_image; + break; + images=DestroyImageList(images); + images=smush_image; break; } - if (LocaleCompare("swap",argv[0]+1) == 0) + if (LocaleCompare("swap",option) == 0) { Image *p, @@ -4241,11 +3950,12 @@ WandExport MagickBooleanType SequenceOperationImages(ImageInfo *image_info, *swap; ssize_t + index, swap_index; - index=(-1); - swap_index=(-2); - if (*argv[0] != '+') + index=-1; + swap_index=-2; + if (plus_alt_op == MagickFalse) { GeometryInfo geometry_info; @@ -4254,18 +3964,17 @@ WandExport MagickBooleanType SequenceOperationImages(ImageInfo *image_info, flags; swap_index=(-1); - flags=ParseGeometry(argv[1],&geometry_info); + flags=ParseGeometry(arg1,&geometry_info); index=(ssize_t) geometry_info.rho; if ((flags & SigmaValue) != 0) swap_index=(ssize_t) geometry_info.sigma; } - p=GetImageFromList(*images,index); - q=GetImageFromList(*images,swap_index); + p=GetImageFromList(images,index); + q=GetImageFromList(images,swap_index); if ((p == (Image *) NULL) || (q == (Image *) NULL)) { (void) ThrowMagickException(exception,GetMagickModule(), - OptionError,"NoSuchImage","`%s'",(*images)->filename); - status=MagickFalse; + OptionError,"NoSuchImage","`%s'",images->filename); break; } if (p == q) @@ -4273,14 +3982,14 @@ WandExport MagickBooleanType SequenceOperationImages(ImageInfo *image_info, swap=CloneImage(p,0,0,MagickTrue,exception); ReplaceImageInList(&p,CloneImage(q,0,0,MagickTrue,exception)); ReplaceImageInList(&q,swap); - *images=GetFirstImageInList(q); + images=GetFirstImageInList(q); break; } break; } case 'w': { - if (LocaleCompare("write",argv[0]+1) == 0) + if (LocaleCompare("write",option) == 0) { char key[MaxTextExtent]; @@ -4291,16 +4000,15 @@ WandExport MagickBooleanType SequenceOperationImages(ImageInfo *image_info, ImageInfo *write_info; - (void) SyncImagesSettings(image_info,*images,exception); - (void) FormatLocaleString(key,MaxTextExtent,"cache:%s",argv[1]); + (void) FormatLocaleString(key,MaxTextExtent,"cache:%s",arg1); (void) DeleteImageRegistry(key); - write_images=(*images); - if (*argv[0] == '+') - write_images=CloneImageList(*images,exception); + write_images=images; + if (plus_alt_op != MagickFalse) + write_images=CloneImageList(images,exception); write_info=CloneImageInfo(image_info); - status&=WriteImages(write_info,write_images,argv[1],exception); + (void) WriteImages(write_info,write_images,arg1,exception); write_info=DestroyImageInfo(write_info); - if (*argv[0] == '+') + if (plus_alt_op != MagickFalse) write_images=DestroyImageList(write_images); break; } @@ -4309,9 +4017,18 @@ WandExport MagickBooleanType SequenceOperationImages(ImageInfo *image_info, default: break; } - quantize_info=DestroyQuantizeInfo(quantize_info); + if (new_images == (Image *) NULL) + return; + + if (images != (Image *) NULL) + images=DestroyImageList(images); + images=new_images; + return; - status=(MagickStatusType) (exception->severity == UndefinedException ? 1 : 0); - return(status != 0 ? MagickTrue : MagickFalse); +#undef image_info +#undef draw_info +#undef quantize_info +#undef images +#undef exception +#undef normal_op } -#endif diff --git a/MagickWand/operation.h b/MagickWand/operation.h index 2a8b3e16a..bffbf819e 100644 --- a/MagickWand/operation.h +++ b/MagickWand/operation.h @@ -23,13 +23,11 @@ extern "C" { #endif -extern WandExport MagickBooleanType +extern WandExport void WandSettingOptionInfo(MagickWand *,const char *,const char *), - WandSimpleOperationImage(MagickWand *,const int,const char *,const char *, + WandSimpleOperatorImages(MagickWand *,const MagickBooleanType,const char *,const char *, const char *), - WandSimpleOperationImages(MagickWand *,const int,const char *,const char *, - const char *), - WandListOperationImages(MagickWand *,const int,const char *,const char *, + WandListOperatorImages(MagickWand *,const MagickBooleanType,const char *,const char *, const char *); #if defined(__cplusplus) || defined(c_plusplus) diff --git a/MagickWand/studio.h b/MagickWand/studio.h index b1b571138..19cc76577 100644 --- a/MagickWand/studio.h +++ b/MagickWand/studio.h @@ -451,13 +451,13 @@ extern int vsnprintf(char *,size_t,const char *,va_list); #define ThrowWandFatalException(severity,tag,context) \ { \ ExceptionInfo \ - *exception; \ + *fatal_exception; \ \ - exception=AcquireExceptionInfo(); \ - (void) ThrowMagickException(exception,GetMagickModule(),severity,tag, \ - "`%s'",context); \ - CatchException(exception); \ - exception=DestroyExceptionInfo(exception); \ + fatal_exception=AcquireExceptionInfo(); \ + (void) ThrowMagickException(fatal_exception,GetMagickModule(),severity,tag, \ + "`%s'",(context)); \ + CatchException(fatal_exception); \ + fatal_exception=DestroyExceptionInfo(fatal_exception); \ } #if defined(__cplusplus) || defined(c_plusplus) -- 2.40.0