%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% GetImageArtifact() gets a value associated with an image artifact.
+% If the requested artifact is NULL return the first artifact.
%
-% Note, the artifact is a constant. Do not attempt to free it.
+% Note, returned string is a constant in the tree and should NOT be freed.
%
% The format of the GetImageArtifact method is:
%
if (image->artifacts == (void *) NULL)
image->artifacts=NewSplayTree(CompareSplayTreeString,
RelinquishMagickMemory,RelinquishMagickMemory);
- /* Delete artifact if NULL or empty */
- if ((value == (const char *) NULL) || (*value == '\0'))
+
+ /* Delete artifact if NULL -- empty string values are valid! */
+ if (value == (const char *) NULL)
return(DeleteImageArtifact(image,artifact));
- /* add option to tree */
+
+ /* add artifact to splay-tree */
status=AddValueToSplayTree((SplayTreeInfo *) image->artifacts,
ConstantString(artifact),ConstantString(value));
return(status);
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
image_info->filename);
- /* This should not be here! - but others might */
+ /* FUTURE: This should not be here! - but others might */
if (LocaleCompare(option,"size") == 0)
(void) CloneString(&image_info->size,value);
if (value == (const char *) NULL)
return(DeleteImageOption(image_info,option));
- /* add option and return */
+ /* add option to splay-tree */
return(AddValueToSplayTree((SplayTreeInfo *) image_info->options,
ConstantString(option),ConstantString(value)));
}
image->properties);
return(p);
}
- if (LocaleNCompare("fx:",property,3) != 0)
+ if (LocaleNCompare("fx:",property,3) != 0) /* NOT fx: !!!! */
{
p=(const char *) GetValueFromSplayTree((SplayTreeInfo *)
image->properties,property);
ConcatenateMagickString(value,"B",MaxTextExtent);
break;
}
- case 'c': /* image comment property */
+ case 'c': /* image comment property - empty string by default */
{
string=GetImageProperty(image,"comment",exception);
+ if ( string == (const char *)NULL)
+ string="";
break;
}
case 'd': /* Directory component of filename */
GetNumberColors(image,(FILE *) NULL,exception));
break;
}
- case 'l': /* Image label */
+ case 'l': /* Image label properity - empty string by default */
{
string=GetImageProperty(image,"label",exception);
+ if ( string == (const char *)NULL)
+ string="";
break;
}
case 'm': /* Image format (file magick) */
if (*value != '\0')
string=value;
if (string != (char *)NULL) {
- (void) SetImageArtifact(image, "get-properity", value);
+ (void) SetImageArtifact(image, "get-properity", string);
return(GetImageArtifact(image, "get-properity"));
}
return((char *)NULL);
{
if (LocaleCompare("channels",property) == 0)
{
- /*
- Image channels.
- */
+ /* FUTURE: return actual image channels */
(void) FormatLocaleString(value,MaxTextExtent,"%s",
CommandOptionToMnemonic(MagickColorspaceOptions,(ssize_t)
image->colorspace));
ColorspaceType
colorspace;
- /*
- Image storage class and colorspace.
- */
+ /* FUTURE: return actual colorspace - no 'gray' stuff */
colorspace=image->colorspace;
if( IfMagickTrue(IsImageGray(image,exception)) )
colorspace=GRAYColorspace;
if (*value != '\0')
string=value;
if (string != (char *)NULL) {
- (void) SetImageArtifact(image, "get-properity", value);
+ (void) SetImageArtifact(image, "get-properity", string);
return(GetImageArtifact(image, "get-properity"));
}
return((char *)NULL);
if( IfMagickTrue(image->debug) )
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
+ /* Create splay-tree */
if (image->properties == (void *) NULL)
image->properties=NewSplayTree(CompareSplayTreeString,
RelinquishMagickMemory,RelinquishMagickMemory);
- if ((value == (const char *) NULL) || (*value == '\0'))
+
+ /* Delete properity if NULL -- empty string values are valid! */
+ if ((value == (const char *) NULL))
return(DeleteImageProperty(image,property));
status=MagickTrue;
+ /* Do not 'set' single letter properties - read only shorthand */
if (strlen(property) <= 1)
{
(void) ThrowMagickException(exception,GetMagickModule(),
OptionError,"SetReadOnlyProperty","'%s'",property);
return(MagickFalse);
}
+
/* FUTURE: These should produce 'illegal settings'
- + test for binary chars in name,
- + first letter must be a alphabetic
- + special prefix
+ + binary chars in p[roperty key
+ + single letter property keys (read only)
+ + known special prefix (read only, they don't get saved!)
*/
switch (*property)