% MagickCore Artifact Methods %
% %
% Software Design %
-% John Cristy %
+% Cristy %
% March 2000 %
% %
% %
-% Copyright 1999-2011 ImageMagick Studio LLC, a non-profit organization %
+% Copyright 1999-2014 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 %
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
-% CloneImageArtifacts() clones one or more image artifacts.
+% CloneImageArtifacts() clones all image artifacts to another image.
+%
+% This will not delete any existing artifacts that may be present!
%
% The format of the CloneImageArtifacts method is:
%
%
% A description of each parameter follows:
%
-% o image: the image.
+% o image: the image, to recieve the cloned artifacts.
%
-% o clone_image: the clone image.
+% o clone_image: the source image for artifacts to clone.
%
*/
MagickExport MagickBooleanType CloneImageArtifacts(Image *image,
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
clone_image->filename);
if (clone_image->artifacts != (void *) NULL)
- image->artifacts=CloneSplayTree((SplayTreeInfo *) clone_image->artifacts,
- (void *(*)(void *)) ConstantString,(void *(*)(void *)) ConstantString);
+ {
+ if (image->artifacts != (void *) NULL)
+ DestroyImageArtifacts(image);
+ image->artifacts=CloneSplayTree((SplayTreeInfo *) clone_image->artifacts,
+ (void *(*)(void *)) ConstantString,(void *(*)(void *)) ConstantString);
+ }
return(MagickTrue);
}
\f
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
-% DefineImageArtifact() associates a key/value pair with an image artifact.
+% DefineImageArtifact() associates an assignment string of the form
+% "key=value" with per-image artifact. It is equivelent to
+% SetImageArtifact().
%
% The format of the DefineImageArtifact method is:
%
assert(image != (Image *) NULL);
assert(image->signature == MagickSignature);
if (image->debug != MagickFalse)
- (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
- image->filename);
+ (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
if (image->artifacts == (void *) NULL)
return(MagickFalse);
return(DeleteNodeFromSplayTree((SplayTreeInfo *) image->artifacts,artifact));
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
-% DestroyImageArtifacts() releases memory associated with image artifact
-% values.
+% DestroyImageArtifacts() destroys all artifacts and associated memory
+% attached to the given image.
%
-% The format of the DestroyDefines method is:
+% The format of the DestroyImageArtifacts method is:
%
% void DestroyImageArtifacts(Image *image)
%
assert(image != (Image *) NULL);
assert(image->signature == MagickSignature);
if (image->debug != MagickFalse)
- (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
- image->filename);
+ (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
if (image->artifacts != (void *) NULL)
image->artifacts=(void *) DestroySplayTree((SplayTreeInfo *)
image->artifacts);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% GetImageArtifact() gets a value associated with an image artifact.
+% If the requested artifact is NULL return the first artifact, to
+% prepare to iterate over all artifacts.
%
-% Note, the artifact is a constant. Do not attempt to free it.
+% The returned string is a constant string in the tree and should NOT be
+% freed by the caller.
%
% The format of the GetImageArtifact method is:
%
}
if (image->artifacts != (void *) NULL)
{
- p=(const char *) GetValueFromSplayTree((SplayTreeInfo *)
- image->artifacts,artifact);
+ p=(const char *) GetValueFromSplayTree((SplayTreeInfo *) image->artifacts,
+ artifact);
if (p != (const char *) NULL)
return(p);
}
+ if ((image->image_info != (ImageInfo *) NULL) &&
+ (image->image_info->options != (void *) NULL))
+ p=(const char *) GetValueFromSplayTree((SplayTreeInfo *)
+ image->image_info->options,artifact);
return(p);
}
\f
assert(image != (Image *) NULL);
assert(image->signature == MagickSignature);
if (image->debug != MagickFalse)
- (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
- image->filename);
+ (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
if (image->artifacts == (void *) NULL)
return((char *) NULL);
return((char *) GetNextKeyInSplayTree((SplayTreeInfo *) image->artifacts));
% RemoveImageArtifact() removes an artifact from the image and returns its
% value.
%
+% In this case the ConstantString() value returned should be freed by the
+% caller when finished.
+%
% The format of the RemoveImageArtifact method is:
%
% char *RemoveImageArtifact(Image *image,const char *artifact)
assert(image != (Image *) NULL);
assert(image->signature == MagickSignature);
if (image->debug != MagickFalse)
- (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
- image->filename);
+ (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
if (image->artifacts == (void *) NULL)
return((char *) NULL);
value=(char *) RemoveNodeFromSplayTree((SplayTreeInfo *) image->artifacts,
% in conjunction with GetNextImageArtifact() to iterate over all the values
% associated with an image artifact.
%
+% Alternatively you can use GetImageArtifact() with a NULL artifact field to
+% reset the iterator and return the first artifact.
+%
% The format of the ResetImageArtifactIterator method is:
%
% ResetImageArtifactIterator(Image *image)
assert(image != (Image *) NULL);
assert(image->signature == MagickSignature);
if (image->debug != MagickFalse)
- (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
- image->filename);
+ (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
if (image->artifacts == (void *) NULL)
return;
ResetSplayTreeIterator((SplayTreeInfo *) image->artifacts);
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
-% SetImageArtifact() associates a value with an image artifact.
+% SetImageArtifact() associates makes a copy of the given string arguments
+% and inserts it into the artifact tree of the given image.
%
% The format of the SetImageArtifact method is:
%
%
% o image: the image.
%
-% o artifact: the image artifact.
+% o artifact: the image artifact key.
%
-% o values: the image artifact values.
+% o value: the image artifact value.
%
*/
MagickExport MagickBooleanType SetImageArtifact(Image *image,
assert(image != (Image *) NULL);
assert(image->signature == MagickSignature);
if (image->debug != MagickFalse)
- (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
- image->filename);
+ (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
+ /*
+ Create tree if needed - specify how key,values are to be freed.
+ */
if (image->artifacts == (void *) NULL)
- image->artifacts=NewSplayTree(CompareSplayTreeString,
- RelinquishMagickMemory,RelinquishMagickMemory);
- if ((value == (const char *) NULL) || (*value == '\0'))
+ image->artifacts=NewSplayTree(CompareSplayTreeString,RelinquishMagickMemory,
+ RelinquishMagickMemory);
+ /*
+ Delete artifact if NULL -- empty string values are valid!,
+ */
+ if (value == (const char *) NULL)
return(DeleteImageArtifact(image,artifact));
+ /*
+ Add artifact to splay-tree.
+ */
status=AddValueToSplayTree((SplayTreeInfo *) image->artifacts,
ConstantString(artifact),ConstantString(value));
return(status);