% September 2011 %
% %
% %
-% Copyright 1999-2012 ImageMagick Studio LLC, a non-profit organization %
+% Copyright 1999-2013 ImageMagick Studio LLC, a non-profit organization %
% dedicated to making software imaging solutions freely available. %
% %
% You may not use this file except in compliance with the License. You may %
/*
Define declarations.
*/
-#define USE_WAND_METHODS 0
+#define USE_WAND_METHODS 1
#define MAX_STACK_DEPTH 32
#define UNDEFINED_COMPRESSION_QUALITY 0UL
% arg2 is currently only used by "-limit"
%
*/
-WandExport void CLISettingOptionInfo(MagickCLI *cli_wand,
+WandPrivate void CLISettingOptionInfo(MagickCLI *cli_wand,
const char *option,const char *arg1, const char *arg2)
{
ssize_t
}
case 'i':
{
+ if (LocaleCompare("intensity",option+1) == 0)
+ {
+ arg1 = ArgOption("undefined");
+ parse = ParseCommandOption(MagickPixelIntensityOptions,MagickFalse,
+ arg1);
+ if (parse < 0)
+ CLIWandExceptArgBreak(OptionError,"UnrecognizedIntensityType",
+ option,arg1);
+ (void) SetImageOption(_image_info,option+1,arg1);
+ break;
+ }
if (LocaleCompare("intent",option+1) == 0)
{
/* Only used by coders: MIFF, MPC, BMP, PNG
and for image profile call to AcquireTransformThreadSet()
SyncImageSettings() used to set per-image attribute.
*/
- arg1 = ArgOption("indefined");
+ arg1 = ArgOption("undefined");
parse = ParseCommandOption(MagickIntentOptions,MagickFalse,arg1);
if (parse < 0)
CLIWandExceptArgBreak(OptionError,"UnrecognizedIntentType",
if (IfMagickFalse(IsGeometry(arg1)))
CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1);
SetRandomSecretKey(
- IfSetOption ? (const unsigned long) StringToUnsignedLong(arg1)
- : (const unsigned long) time((time_t *) NULL) );
+ IfSetOption ? (unsigned long) StringToUnsignedLong(arg1)
+ : (unsigned long) time((time_t *) NULL) );
break;
}
if (LocaleCompare("size",option+1) == 0)
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
-% WandSimpleOperatorImages() andSimpleOperatorImagespplys one simple image operation given to all
-% the images in the CLI wand, with the settings that was previously saved in
-% the CLI wand.
+% CLISimpleOperatorImages() applys one simple image operation given to all
+% the images in the CLI wand, using any per-image or global settings that was
+% previously saved in the CLI wand.
%
-% It is assumed that any per-image settings are up-to-date with respect to
-% extra settings that were already saved in the wand.
+% It is assumed that any such settings are up-to-date.
%
% The format of the WandSimpleOperatorImages method is:
%
*/
/*
- Internal subrountine to apply one simple image operation to the current
- image pointed to by the CLI wand.
+ CLISimpleOperatorImage() is an Internal subrountine to apply one simple
+ image operation to the current image pointed to by the CLI wand.
The image in the list may be modified in three different ways...
* directly modified (EG: -negate, -gamma, -level, -annotate, -draw),
also change. GetFirstImageInList() should be used by caller if they wish
return the Image pointer to the first image in list.
*/
-static void CLISimpleOperatorImage(MagickCLI *cli_wand,
+static MagickBooleanType CLISimpleOperatorImage(MagickCLI *cli_wand,
const char *option, const char *arg1n, const char *arg2n)
{
Image *
SetGeometryInfo(&geometry_info);
flags=ParseGeometry(arg1,&geometry_info);
- if ((flags & RhoValue) == 0)
+ if (flags == 0)
CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1);
if ((flags & SigmaValue) == 0)
geometry_info.sigma=geometry_info.rho;
}
if (LocaleCompare("auto-orient",option+1) == 0)
{
- /* This should probably be a MagickCore function */
- switch (_image->orientation)
- {
- case TopRightOrientation:
- {
- new_image=FlopImage(_image,_exception);
- break;
- }
- case BottomRightOrientation:
- {
- new_image=RotateImage(_image,180.0,_exception);
- break;
- }
- case BottomLeftOrientation:
- {
- new_image=FlipImage(_image,_exception);
- break;
- }
- case LeftTopOrientation:
- {
- new_image=TransposeImage(_image,_exception);
- break;
- }
- case RightTopOrientation:
- {
- new_image=RotateImage(_image,90.0,_exception);
- break;
- }
- case RightBottomOrientation:
- {
- new_image=TransverseImage(_image,_exception);
- break;
- }
- case LeftBottomOrientation:
- {
- new_image=RotateImage(_image,270.0,_exception);
- break;
- }
- default:
- break;
- }
- if (new_image != (Image *) NULL)
- new_image->orientation=TopLeftOrientation;
+ new_image=AutoOrientImage(_image,_image->orientation,_exception);
break;
}
CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option);
geometry_info.sigma=1.0;
if ((flags & XiValue) == 0)
geometry_info.xi=1.0;
- new_image=CharcoalImage(_image,geometry_info.rho,
- geometry_info.sigma,_exception);
+ new_image=CharcoalImage(_image,geometry_info.rho,geometry_info.sigma,
+ _exception);
break;
}
if (LocaleCompare("chop",option+1) == 0)
break;
for (x=0; x < (ssize_t) mask_image->columns; x++)
{
- if (IfMagickFalse(mask_image->alpha_trait))
+ if (mask_image->alpha_trait != BlendPixelTrait)
SetPixelAlpha(mask_image,GetPixelIntensity(mask_image,q),q);
SetPixelRed(mask_image,GetPixelAlpha(mask_image,q),q);
SetPixelGreen(mask_image,GetPixelAlpha(mask_image,q),q);
That seems to be a little strange!
*/
(void) TransformImageColorspace(_image,
- IfNormalOp ? _image_info->colorspace : RGBColorspace,
+ IfNormalOp ? _image_info->colorspace : sRGBColorspace,
_exception);
break;
}
flags=ParseGeometry(arg1,&geometry_info);
if ((flags & (RhoValue|SigmaValue)) == 0)
CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1);
- if ((flags & SigmaValue) == 0)
- geometry_info.sigma=1.0;
- new_image=EdgeImage(_image,geometry_info.rho,geometry_info.sigma,
- _exception);
+ new_image=EdgeImage(_image,geometry_info.rho,_exception);
break;
}
if (LocaleCompare("emboss",option+1) == 0)
_image->filter,_exception);
break;
}
+ if (LocaleCompare("distort",option+1) == 0)
+ {
+ parse = ParseCommandOption(MagickPixelIntensityOptions,
+ MagickFalse,arg1);
+ if ( parse < 0 )
+ CLIWandExceptArgBreak(OptionError,"UnrecognizedIntensityMethod",
+ option,arg1);
+ _image->intensity = (PixelIntensityMethod) parse;
+ (void) TransformImageColorspace(_image,
+ IfNormalOp ? _image_info->colorspace : GRAYColorspace,
+ _exception);
+ break;
+ }
CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option);
}
case 'i':
_exception);
break;
}
+ if (LocaleCompare("perceptible",option+1) == 0)
+ {
+ (void) PerceptibleImage(_image,StringToDouble(arg1,(char **) NULL),
+ _exception);
+ break;
+ }
if (LocaleCompare("polaroid",option+1) == 0)
{
const char
(double) QuantumRange+1.0),_exception);
break;
}
- if (LocaleCompare("set",option+1) == 0)
- {
- /* Note: arguments do not have percent escapes expanded */
- char
- *value;
-
- if (IfPlusOp) {
- if (LocaleNCompare(arg1,"registry:",9) == 0)
- (void) DeleteImageRegistry(arg1+9);
- else
- if (LocaleNCompare(arg1,"option:",7) == 0)
- {
- (void) DeleteImageOption(_image_info,arg1+7);
- (void) DeleteImageArtifact(_image,arg1+7);
- }
- else
- (void) DeleteImageProperty(_image,arg1);
- break;
- }
- value=InterpretImageProperties(_image_info,_image,arg2,_exception);
- if (value == (char *) NULL)
- CLIWandExceptionBreak(OptionWarning,"InterpretPropertyFailure",
- option);
- if (LocaleNCompare(arg1,"registry:",9) == 0)
- (void) SetImageRegistry(StringRegistryType,arg1+9,value,_exception);
- else
- if (LocaleNCompare(arg1,"option:",7) == 0)
- {
- (void) SetImageOption(_image_info,arg1+7,value);
- (void) SetImageArtifact(_image,arg1+7,value);
- }
- else
- (void) SetImageProperty(_image,arg1,value,_exception);
- value=DestroyString(value);
- break;
- }
if (LocaleCompare("shade",option+1) == 0)
{
flags=ParseGeometry(arg1,&geometry_info);
if (new_image != (Image *) NULL)
ReplaceImageInListReturnLast(&_image,new_image);
- return;
+ return(MagickTrue);
#undef _image_info
#undef _draw_info
#undef _quantize_info
#undef plus_alt_op
}
-WandExport void CLISimpleOperatorImages(MagickCLI *cli_wand,
- const char *option, const char *arg1, const char *arg2)
+WandPrivate MagickBooleanType CLISimpleOperatorImages(MagickCLI *cli_wand,
+ const char *option,const char *arg1,const char *arg2)
{
+#if !USE_WAND_METHODS
size_t
n,
i;
+#endif
assert(cli_wand != (MagickCLI *) NULL);
assert(cli_wand->signature == WandSignature);
CLISimpleOperatorImage(cli_wand, option, arg1, arg2);
MagickResetIterator(&cli_wand->wand);
#endif
- return;
+ return(MagickTrue);
}
\f
/*
%
% CLIListOperatorImages() 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.
+% of the image list with a completely new list, or with just a single image
+% result.
%
% The format of the MogrifyImage method is:
%
-% void CLIListOperatorImages(MagickCLI *cli_wand,
-% const char *option, const char *arg1, const char *arg2)
+% MagickBooleanType CLIListOperatorImages(MagickCLI *cli_wand,
+% const char *option,const char *arg1,const char *arg2)
%
% A description of each parameter follows:
%
% arg2 is currently not used
%
*/
-WandExport void CLIListOperatorImages(MagickCLI *cli_wand,
- const char *option,const char *arg1n, const char *arg2n)
+WandPrivate MagickBooleanType CLIListOperatorImages(MagickCLI *cli_wand,
+ const char *option,const char *arg1n,const char *arg2n)
{
- ssize_t
- parse;
+ const char /* For percent escape interpretImageProperties() */
+ *arg1,
+ *arg2;
Image
*new_images;
- const char /* For percent escape interpretImageProperties() */
- *arg1,
- *arg2;
+ MagickStatusType
+ status;
+
+ ssize_t
+ parse;
#define _image_info (cli_wand->wand.image_info)
#define _images (cli_wand->wand.images)
"CLIListOperatorImages: \"%s\" \"%s\" \"%s\"\n",option,arg1,arg2);
#endif
-
+ status=MagickTrue;
new_images=NewImageList();
switch (*(option+1))
{
/* FUTURE - this may be replaced by a 'channel' method */
parse = ParseCommandOption(MagickColorspaceOptions,MagickFalse,arg1);
+ if (parse < 0)
+ CLIWandExceptArgBreak(OptionError,"UnrecognizedColorspace",option,
+ arg1);
new_images=CombineImages(_images,(ColorspaceType) parse,_exception);
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);
-
+ new_images->gravity, &geometry);
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 displace/distort map. */
- (void) CompositeImage(source_image,mask_image,
+ (compose == DistortCompositeOp))
+ status&=CompositeImage(source_image,mask_image,
CopyGreenCompositeOp,MagickTrue,0,0,_exception);
- mask_image=DestroyImage(mask_image);
- }
- else {
- /* Set a blending mask for the composition. */
- (void) NegateImage(mask_image,MagickFalse,_exception);
- (void) SetImageMask(source_image,mask_image,_exception);
- mask_image=DestroyImage(mask_image);
- }
+ else
+ {
+ Image
+ *image;
+
+ RectangleInfo
+ source_geometry;
+
+ source_geometry.width=mask_image->columns;
+ source_geometry.height=mask_image->rows;
+ source_geometry.x=(-geometry.x);
+ source_geometry.y=(-geometry.y);
+ geometry.x=0;
+ geometry.y=0;
+ image=ExtentImage(source_image,&source_geometry,_exception);
+ if (image != (Image *) NULL)
+ {
+ source_image=DestroyImage(source_image);
+ source_image=image;
+ }
+ status&=CompositeImage(source_image,mask_image,
+ IntensityCompositeOp,MagickTrue,0,0,_exception);
+ }
+ mask_image=DestroyImage(mask_image);
}
- (void) CompositeImage(new_images,source_image,compose,clip_to_self,
+ status&=CompositeImage(new_images,source_image,compose,clip_to_self,
geometry.x,geometry.y,_exception);
- (void) SetImageMask(new_images,(Image *) NULL,_exception);
source_image=DestroyImage(source_image);
break;
}
}
case 'p':
{
+ if (LocaleCompare("poly",option+1) == 0)
+ {
+ double
+ *args;
+
+ ssize_t
+ count;
+
+ /* convert argument string into an array of doubles */
+ args = StringToArrayOfDoubles(arg2,&count,_exception);
+ if (args == (double *)NULL )
+ CLIWandExceptArgBreak(OptionError,"InvalidNumberList",option,arg2);
+ new_images=PolynomialImage(_images,count >> 1,args,_exception);
+ args=(double *) RelinquishMagickMemory(args);
+ break;
+ }
if (LocaleCompare("print",option+1) == 0)
{
(void) FormatLocaleFile(stdout,"%s",arg1);
metric=(MetricType) ParseCommandOption(MagickMetricOptions,
MagickFalse,value);
- new_images=SimilarityImage(base_image,compare_image,metric,
+ new_images=SimilarityImage(base_image,compare_image,metric,0.0,
&offset,&similarity,_exception);
if ( new_images != (Image *)NULL ) {
index,
swap_index;
- index=-1;
- swap_index=-2;
+ index=(-1);
+ swap_index=(-2);
if (IfNormalOp) {
GeometryInfo
geometry_info;
swap_index=(-1);
flags=ParseGeometry(arg1,&geometry_info);
- if ((flags & RhoValue) != 0)
+ if ((flags & RhoValue) == 0)
CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1);
index=(ssize_t) geometry_info.rho;
if ((flags & SigmaValue) != 0)
/* if new image list generated, replace existing image list */
if (new_images == (Image *) NULL)
- return;
+ return(status);
_images=DestroyImageList(_images);
_images=GetFirstImageInList(new_images);
- return;
+ return(status);
#undef _image_info
#undef _images
%
% A description of each parameter follows:
%
-% o cli_wand: the main CLI Wand to use.
+% o cli_wand: the main CLI Wand to use. (sometimes not required)
%
% o option: The special option (with any switch char) to process
%
% Currently arg2 is not used.
%
*/
-WandExport void CLINoImageOperator(MagickCLI *cli_wand,
- const char *option, const char *arg1, const char *magick_unused(arg2))
+WandPrivate void CLINoImageOperator(MagickCLI *cli_wand,
+ const char *option,const char *arg1,const char *arg2)
{
#if 0
const char /* For percent escape interpretImageProperties() */
/*
No-op options (ignore these)
*/
- if (LocaleCompare("noop",option+1) == 0) /* no argument */
+ if (LocaleCompare("noop",option+1) == 0) /* zero argument */
break;
if (LocaleCompare("sans",option+1) == 0) /* one argument */
break;
- if (LocaleCompare("sans0",option+1) == 0) /* no argument */
+ if (LocaleCompare("sans0",option+1) == 0) /* zero argument */
+ break;
+ if (LocaleCompare("sans1",option+1) == 0) /* one argument */
break;
if (LocaleCompare("sans2",option+1) == 0) /* two arguments */
break;
break;
}
+ if (LocaleCompare("set",option+1) == 0)
+ {
+ /* Note: arguments are not percent escapes expanded yet */
+ /* Some settings are applied to each image in memory in turn.
+ While others only need to be applied once globally.
+ */
+ char
+ *value;
+
+ if (LocaleNCompare(arg1,"registry:",9) == 0)
+ {
+ if (IfPlusOp)
+ {
+ (void) DeleteImageRegistry(arg1+9);
+ break;
+ }
+ value=InterpretImageProperties(_image_info,_images,arg2,_exception);
+ if (value == (char *) NULL)
+ CLIWandExceptionBreak(OptionWarning,"InterpretPropertyFailure",
+ option);
+ (void) SetImageRegistry(StringRegistryType,arg1+9,value,_exception);
+ value=DestroyString(value);
+ break;
+ }
+ if (LocaleNCompare(arg1,"option:",7) == 0)
+ {
+ /* delete equivelent artifact from all images (if any) */
+ MagickResetIterator(&cli_wand->wand);
+ while ( IfMagickTrue(MagickNextImage(&cli_wand->wand)) )
+ (void) DeleteImageArtifact(_images,arg1+7);
+ MagickResetIterator(&cli_wand->wand);
+ /* now set/delete the global option as needed */
+ if (IfPlusOp) {
+ (void) DeleteImageOption(_image_info,arg1+7);
+ break;
+ }
+ value=InterpretImageProperties(_image_info,_images,arg2,_exception);
+ if (value == (char *) NULL)
+ CLIWandExceptionBreak(OptionWarning,"InterpretPropertyFailure",
+ option);
+ (void) SetImageOption(_image_info,arg1+7,value);
+ value=DestroyString(value);
+ break;
+ }
+ if ( cli_wand->wand.images == (Image *) NULL )
+ CLIWandExceptArgBreak(OptionError,"NoImagesFound",option,arg1);
+ MagickResetIterator(&cli_wand->wand);
+ while ( IfMagickTrue(MagickNextImage(&cli_wand->wand)) )
+ {
+ Image
+ *next;
+
+ if (IfPlusOp) {
+ if (LocaleNCompare(arg1,"artifact:",9) == 0)
+ (void) DeleteImageArtifact(_images,arg1+9);
+ else if (LocaleNCompare(arg1,"property:",9) == 0)
+ (void) DeleteImageProperty(_images,arg1+9);
+ else
+ (void) DeleteImageProperty(_images,arg1);
+ break;
+ }
+ next=_images;
+ for ( ; next != (Image *) NULL; next=GetNextImageInList(next))
+ {
+ value=InterpretImageProperties(_image_info,next,arg2,_exception);
+ if (value == (char *) NULL)
+ CLIWandExceptionBreak(OptionWarning,"InterpretPropertyFailure",
+ option);
+ if (LocaleNCompare(arg1,"artifact:",9) == 0)
+ (void) SetImageArtifact(next,arg1+9,value);
+ else
+ if (LocaleNCompare(arg1,"property:",9) == 0)
+ (void) SetImageProperty(next,arg1+9,value,_exception);
+ else
+ (void) SetImageProperty(next,arg1,value,_exception);
+ value=DestroyString(value);
+ }
+ break;
+ }
+ MagickResetIterator(&cli_wand->wand);
+ break;
+ }
if (LocaleCompare("clone",option+1) == 0) {
Image
*new_images;
break;
}
/*
- Informational Operations
+ Informational Operations.
- Note that these do not require either cli-wand or images!
+ Note that these do not require either a cli-wand or images!
+ Though currently a cli-wand much be provided regardless.
*/
- if (LocaleCompare("version",option+1) == 0) {
- (void) FormatLocaleFile(stdout,"Version: %s\n",
- GetMagickVersion((size_t *) NULL));
- (void) FormatLocaleFile(stdout,"Copyright: %s\n",
- GetMagickCopyright());
- (void) FormatLocaleFile(stdout,"Features: %s\n\n",
- GetMagickFeatures());
- break;
- }
+ if (LocaleCompare("version",option+1) == 0)
+ {
+ ListMagickVersion(stdout);
+ break;
+ }
if (LocaleCompare("list",option+1) == 0) {
/*
- FUTURE: This 'switch' should really be built into the MagickCore
+ FUTURE: This 'switch' should really be part of MagickCore
*/
ssize_t
list;