% return free-form properity strings, unless referenced by a single letter
% properity name.
%
-% The returned string should be freed using DestoryString() when finished.
+% The returned string is stored as the image artifact 'get-property' (not as
+% another property), and as such should not be freed. Later calls however
+% will overwrite this value so if needed for a longer period a copy should be
+% made. This artifact can be deleted when no longer required.
%
% The format of the GetMagickProperty method is:
%
Image *image,const char letter,ExceptionInfo *exception)
{
char
- value[MaxTextExtent],
- *clone;
+ value[MaxTextExtent];
- if (image != (Image *) NULL && image->debug != MagickFalse)
- (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
- image->filename);
+ const char
+ *string;
- *value='\0';
- clone=(char *)NULL;
+ if (image != (Image *) NULL && IfMagickTrue(image->debug))
+ (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
+ image->filename);
+ *value='\0'; /* formated string */
+ string=(char *)NULL; /* constant string reference */
switch (letter)
{
}
case 'c': /* image comment property */
{
- clone=ConstantString(GetImageProperty(image,"comment",exception));
+ string=GetImageProperty(image,"comment",exception);
break;
}
case 'd': /* Directory component of filename */
}
case 'i': /* Filename last used for image (read or write) */
{
- clone=ConstantString(image->filename);
+ string=image->filename;
break;
}
case 'k': /* Number of unique colors */
}
case 'l': /* Image label */
{
- clone=ConstantString(GetImageProperty(image,"label",exception));
+ string=GetImageProperty(image,"label",exception);
break;
}
case 'm': /* Image format (file magick) */
{
- clone=ConstantString(image->magick);
+ string=image->magick;
break;
}
case 'n': /* Number of images in the list. */
}
case 'o': /* Output Filename - for delegate use only */
{
- clone=ConstantString(image_info->filename);
+ string=image_info->filename;
break;
}
case 'p': /* Image index in current image list -- As 'n' OBSOLETE */
}
case 'u': /* Unique filename */
{
- clone=ConstantString(image_info->unique);
+ string=image_info->unique;
break;
}
case 'w': /* Image width (current) */
}
case 'M': /* Magick filename - filename given incl. coder & read mods */
{
- clone=ConstantString(image->magick_filename);
+ string=image->magick_filename;
break;
}
case 'O': /* layer canvas offset with sign = "+%X+%Y" */
case 'S': /* Image scenes ???? */
{
if (image_info->number_scenes == 0)
- clone=ConstantString("2147483647");
+ string="2147483647";
else
(void) FormatLocaleString(value,MaxTextExtent,"%.20g",(double)
image_info->scene+image_info->number_scenes);
}
case 'Z': /* Zero filename ??? */
{
- clone=ConstantString(image_info->zero);
+ string=image_info->zero;
break;
}
case '@': /* Trim bounding box, without Trimming! */
case '#': /* Image signature */
{
(void) SignatureImage(image,exception);
- clone=ConstantString(GetImageProperty(image,"signature",exception));
+ string=GetImageProperty(image,"signature",exception);
break;
}
case '%': /* percent escaped */
{
- clone=ConstantString("%");
+ string="%";
break;
}
}
- /* FUTURE: save it as a 'special' property - for return */
if (*value != '\0')
- clone=ConstantString(value);
- return(clone);
+ string=value;
+ if (string != (char *)NULL) {
+ (void) SetImageArtifact(image, "get-properity", value);
+ return(GetImageArtifact(image, "get-properity"));
+ }
+ return((char *)NULL);
}
MagickExport const char *GetMagickProperty(const ImageInfo *image_info,
char
value[MaxTextExtent];
+ const char
+ *string;
+
assert(property[0] != '\0');
if ( property[1] == '\0') /* single letter properity request */
return( GetMagickPropertyLetter(image_info,image,*property,exception) );
- *value='\0';
+ if (image != (Image *) NULL && IfMagickTrue(image->debug))
+ (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
+ image->filename);
+
+ *value='\0'; /* formated string */
+ string=(char *)NULL; /* constant string reference */
switch (*property)
{
case 'b':
{
- if ((LocaleNCompare("base",property,4) == 0) ||
- (LocaleNCompare("basename",property,8) == 0) )
+ if ((LocaleCompare("base",property) == 0) ||
+ (LocaleCompare("basename",property) == 0) )
{
GetPathComponent(image->magick_filename,BasePath,value);
break;
}
case 'c':
{
- if (LocaleNCompare("channels",property,8) == 0)
+ if (LocaleCompare("channels",property) == 0)
{
/*
Image channels.
(void) ConcatenateMagickString(value,"a",MaxTextExtent);
break;
}
- if (LocaleNCompare("colorspace",property,10) == 0)
+ if (LocaleCompare("colorspace",property) == 0)
{
ColorspaceType
colorspace;
colorspace=image->colorspace;
if( IfMagickTrue(IsImageGray(image,exception)) )
colorspace=GRAYColorspace;
- (void) FormatLocaleString(value,MaxTextExtent,"%s",
- CommandOptionToMnemonic(MagickColorspaceOptions,(ssize_t)
- colorspace));
+ string=CommandOptionToMnemonic(MagickColorspaceOptions,(ssize_t)
+ colorspace);
break;
}
- if (LocaleNCompare("copyright",property,9) == 0)
+ if (LocaleCompare("copyright",property) == 0)
{
(void) CopyMagickString(value,GetMagickCopyright(),MaxTextExtent);
break;
}
case 'd':
{
- if (LocaleNCompare("depth",property,5) == 0)
+ if (LocaleCompare("depth",property) == 0)
{
(void) FormatLocaleString(value,MaxTextExtent,"%.20g",(double)
image->depth);
break;
}
- if (LocaleNCompare("directory",property,9) == 0)
+ if (LocaleCompare("directory",property) == 0)
{
GetPathComponent(image->magick_filename,HeadPath,value);
break;
}
case 'e':
{
- if (LocaleNCompare("extension",property,9) == 0)
+ if (LocaleCompare("extension",property) == 0)
{
GetPathComponent(image->magick_filename,ExtensionPath,value);
break;
case 'g':
{
if ( (image_info != (ImageInfo *) NULL) &&
- (LocaleNCompare("group",property,5) == 0) )
+ (LocaleCompare("group",property) == 0) )
{
(void) FormatLocaleString(value,MaxTextExtent,"0x%lx",
(unsigned long) image_info->group);
}
case 'h':
{
- if (LocaleNCompare("height",property,6) == 0)
+ if (LocaleCompare("height",property) == 0)
{
(void) FormatLocaleString(value,MaxTextExtent,"%.20g",
image->magick_rows != 0 ? (double) image->magick_rows : 256.0);
}
case 'i':
{
- if (LocaleNCompare("input",property,5) == 0)
+ if (LocaleCompare("input",property) == 0)
{
- (void) CopyMagickString(value,image->filename,MaxTextExtent);
+ string=image->filename;
break;
}
break;
}
case 'k':
{
- if (LocaleNCompare("kurtosis",property,8) == 0)
+ if (LocaleCompare("kurtosis",property) == 0)
{
double
kurtosis,
}
case 'm':
{
- if (LocaleNCompare("magick",property,6) == 0)
+ if (LocaleCompare("magick",property) == 0)
{
- (void) CopyMagickString(value,image->magick,MaxTextExtent);
+ string=image->magick;
break;
}
- if (LocaleNCompare("max",property,3) == 0)
+ if (LocaleCompare("max",property) == 0)
{
double
maximum,
GetMagickPrecision(),maximum);
break;
}
- if (LocaleNCompare("mean",property,4) == 0)
+ if (LocaleCompare("mean",property) == 0)
{
double
mean,
GetMagickPrecision(),mean);
break;
}
- if (LocaleNCompare("min",property,3) == 0)
+ if (LocaleCompare("min",property) == 0)
{
double
maximum,
}
case 'o':
{
- if (LocaleNCompare("opaque",property,6) == 0)
+ if (LocaleCompare("opaque",property) == 0)
{
MagickBooleanType
opaque;
MaxTextExtent);
break;
}
- if (LocaleNCompare("orientation",property,11) == 0)
+ if (LocaleCompare("orientation",property) == 0)
{
- (void) FormatLocaleString(value,MaxTextExtent,"%s",
- CommandOptionToMnemonic(MagickOrientationOptions,(ssize_t)
- image->orientation));
+ string=CommandOptionToMnemonic(MagickOrientationOptions,(ssize_t)
+ image->orientation);
break;
}
if ( (image_info != (ImageInfo *) NULL) &&
- (LocaleNCompare("output",property,6) == 0) )
+ (LocaleCompare("output",property) == 0) )
{
(void) CopyMagickString(value,image_info->filename,MaxTextExtent);
break;
}
case 'p':
{
- if (LocaleNCompare("page",property,4) == 0)
+ if (LocaleCompare("page",property) == 0)
{
(void) FormatLocaleString(value,MaxTextExtent,"%.20g",(double)
GetImageIndexInList(image)+1);
case 'r':
{
/* FUTURE: Obsolete */
- if (LocaleNCompare("resolution.x",property,11) == 0)
+ if (LocaleCompare("resolution.x",property) == 0)
{
(void) FormatLocaleString(value,MaxTextExtent,"%g",
image->resolution.x);
break;
}
/* FUTURE: Obsolete */
- if (LocaleNCompare("resolution.y",property,11) == 0)
+ if (LocaleCompare("resolution.y",property) == 0)
{
(void) FormatLocaleString(value,MaxTextExtent,"%g",
image->resolution.y);
}
case 's':
{
- if (LocaleNCompare("scene",property,5) == 0)
+ if (LocaleCompare("scene",property) == 0)
{
if ( (image_info != (ImageInfo *) NULL) &&
(image_info->number_scenes != 0) )
image->scene);
break;
}
- if (LocaleNCompare("scenes",property,6) == 0)
+ if (LocaleCompare("scenes",property) == 0)
{
(void) FormatLocaleString(value,MaxTextExtent,"%.20g",(double)
GetImageListLength(image));
break;
}
- if (LocaleNCompare("size",property,4) == 0)
+ if (LocaleCompare("size",property) == 0)
{
char
format[MaxTextExtent];
(void) FormatLocaleString(value,MaxTextExtent,"%sB",format);
break;
}
- if (LocaleNCompare("skewness",property,8) == 0)
+ if (LocaleCompare("skewness",property) == 0)
{
double
kurtosis,
GetMagickPrecision(),skewness);
break;
}
- if (LocaleNCompare("standard-deviation",property,18) == 0)
+ if (LocaleCompare("standard-deviation",property) == 0)
{
double
mean,
case 'u':
{
if ( (image_info != (ImageInfo *) NULL) &&
- (LocaleNCompare("unique",property,6) == 0) )
+ (LocaleCompare("unique",property) == 0) )
{
- (void) CopyMagickString(value,image_info->unique,MaxTextExtent);
+ string=image_info->unique;
break;
}
break;
}
case 'v':
{
- if (LocaleNCompare("version",property,7) == 0)
+ if (LocaleCompare("version",property) == 0)
{
- (void) CopyMagickString(value,GetMagickVersion((size_t *) NULL),
- MaxTextExtent);
+ string=GetMagickVersion((size_t *) NULL);
break;
}
break;
}
case 'w':
{
- if (LocaleNCompare("width",property,5) == 0)
+ if (LocaleCompare("width",property) == 0)
{
(void) FormatLocaleString(value,MaxTextExtent,"%.20g",(double)
(image->magick_columns != 0 ? image->magick_columns : 256));
}
case 'x': /* ( X resolution, (with units) */
{
- if ((LocaleNCompare("xresolution",property,11) == 0) ||
- (LocaleNCompare("x-resolution",property,12) == 0) )
+ if ((LocaleCompare("xresolution",property) == 0) ||
+ (LocaleCompare("x-resolution",property) == 0) )
{
(void) FormatLocaleString(value,MaxTextExtent,"%.20g",
image->resolution.x);
}
case 'y': /* ( Y resolution, (with units) */
{
- if ((LocaleNCompare("yresolution",property,11) == 0) ||
- (LocaleNCompare("y-resolution",property,12) == 0) )
+ if ((LocaleCompare("yresolution",property) == 0) ||
+ (LocaleCompare("y-resolution",property) == 0) )
{
(void) FormatLocaleString(value,MaxTextExtent,"%.20g",
image->resolution.y);
case 'z':
{
if ( (image_info != (ImageInfo *) NULL) &&
- (LocaleNCompare("zero",property,4) == 0) )
+ (LocaleCompare("zero",property) == 0) )
{
- (void) CopyMagickString(value,image_info->zero,MaxTextExtent);
+ string=image_info->zero;
break;
}
break;
}
}
- /* FUTURE: save it as a 'special' property entry - for return */
- if (*value == '\0')
- return(NULL);
- return(ConstantString(value));
+ if (*value != '\0')
+ string=value;
+ if (string != (char *)NULL) {
+ (void) SetImageArtifact(image, "get-properity", value);
+ return(GetImageArtifact(image, "get-properity"));
+ }
+ return((char *)NULL);
}
\f
/*
}
(void) CopyMagickString(q,value,extent);
q+=length;
- value=DestroyString((char *)value); /* must be destoryed */
- }
- else {
- (void) ThrowMagickException(exception,GetMagickModule(),
- OptionWarning,"UnknownImageProperty","\"%%%c\"",*p);
+ continue;
}
+ (void) ThrowMagickException(exception,GetMagickModule(),
+ OptionWarning,"UnknownImageProperty","\"%%%c\"",*p);
continue;
}
/*
Special Properity Prefixes
such as: %[exif:...] %[fx:...] %[pixel:...]
+ Otherwise a free-form properity string
*/
value=GetImageProperty(image,pattern,exception);
if (value != (const char *) NULL)
}
(void) CopyMagickString(q,value,extent);
q+=length;
- value=DestroyString((char *)value); /* must be destoryed */
continue;
}
/*
- Look for a per-image Artifact (escaped option)
+ Look for a per-image Artifact (user option, post-interpreted)
*/
value=GetImageArtifact(image,pattern);
if (value != (char *) NULL)
continue;
}
/*
- Look for option of this name (should never match in CLI usage)
+ Look for user option of this name (should never match in CLI usage)
*/
if (image_info != (ImageInfo *) NULL) {
value=GetImageOption(image_info,pattern);