]> granicus.if.org Git - imagemagick/blobdiff - MagickWand/magick-property.c
(no commit message)
[imagemagick] / MagickWand / magick-property.c
index 994b27c1f12edaf91b1aea921df4cfcb7ce46fb8..291d67b64528d5fe2d1994ec7f2df27094566a5f 100644 (file)
 %            Set or Get MagickWand Properties, Options, or Profiles           %
 %                                                                             %
 %                               Software Design                               %
-%                                 John Cristy                                 %
+%                                    Cristy                                   %
 %                                 August 2003                                 %
 %                                                                             %
 %                                                                             %
-%  Copyright 1999-2012 ImageMagick Studio LLC, a non-profit organization      %
+%  Copyright 1999-2015 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  %
 #include "MagickWand/wand.h"
 #include "MagickCore/string-private.h"
 \f
-/*
-  Define declarations.
-*/
-#define ThrowWandException(severity,tag,context) \
-{ \
-  (void) ThrowMagickException(wand->exception,GetMagickModule(),severity, \
-    tag,"'%s'",context); \
-  return(MagickFalse); \
-}
-\f
 /*
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %                                                                             %
@@ -98,7 +88,7 @@ WandExport MagickBooleanType MagickDeleteImageArtifact(MagickWand *wand,
   if (wand->images == (Image *) NULL)
     {
       (void) ThrowMagickException(wand->exception,GetMagickModule(),WandError,
-        "ContainsNoImages","'%s'",wand->name);
+        "ContainsNoImages","`%s'",wand->name);
       return(MagickFalse);
     }
   return(DeleteImageArtifact(wand->images,artifact));
@@ -140,7 +130,7 @@ WandExport MagickBooleanType MagickDeleteImageProperty(MagickWand *wand,
   if (wand->images == (Image *) NULL)
     {
       (void) ThrowMagickException(wand->exception,GetMagickModule(),WandError,
-        "ContainsNoImages","'%s'",wand->name);
+        "ContainsNoImages","`%s'",wand->name);
       return(MagickFalse);
     }
   return(DeleteImageProperty(wand->images,property));
@@ -574,7 +564,7 @@ WandExport char *MagickGetImageArtifact(MagickWand *wand,const char *artifact)
   if (wand->images == (Image *) NULL)
     {
       (void) ThrowMagickException(wand->exception,GetMagickModule(),WandError,
-        "ContainsNoImages","'%s'",wand->name);
+        "ContainsNoImages","`%s'",wand->name);
       return((char *) NULL);
     }
   value=GetImageArtifact(wand->images,artifact);
@@ -636,7 +626,7 @@ WandExport char **MagickGetImageArtifacts(MagickWand *wand,
   if (wand->images == (Image *) NULL)
     {
       (void) ThrowMagickException(wand->exception,GetMagickModule(),WandError,
-        "ContainsNoImages","'%s'",wand->name);
+        "ContainsNoImages","`%s'",wand->name);
       return((char **) NULL);
     }
   (void) GetImageProperty(wand->images,"exif:*",wand->exception);
@@ -659,7 +649,7 @@ WandExport char **MagickGetImageArtifacts(MagickWand *wand,
             if (artifacts == (char **) NULL)
               {
                 (void) ThrowMagickException(wand->exception,GetMagickModule(),
-                  ResourceLimitError,"MemoryAllocationFailed","'%s'",
+                  ResourceLimitError,"MemoryAllocationFailed","`%s'",
                   wand->name);
                 return((char **) NULL);
               }
@@ -718,7 +708,7 @@ WandExport unsigned char *MagickGetImageProfile(MagickWand *wand,
   if (wand->images == (Image *) NULL)
     {
       (void) ThrowMagickException(wand->exception,GetMagickModule(),WandError,
-        "ContainsNoImages","'%s'",wand->name);
+        "ContainsNoImages","`%s'",wand->name);
       return((unsigned char *) NULL);
     }
   *length=0;
@@ -790,7 +780,7 @@ WandExport char **MagickGetImageProfiles(MagickWand *wand,const char *pattern,
   if (wand->images == (Image *) NULL)
     {
       (void) ThrowMagickException(wand->exception,GetMagickModule(),WandError,
-        "ContainsNoImages","'%s'",wand->name);
+        "ContainsNoImages","`%s'",wand->name);
       return((char **) NULL);
     }
   (void) GetImageProfile(wand->images,"exif:*");
@@ -813,7 +803,7 @@ WandExport char **MagickGetImageProfiles(MagickWand *wand,const char *pattern,
             if (profiles == (char **) NULL)
               {
                 (void) ThrowMagickException(wand->exception,GetMagickModule(),
-                  ResourceLimitError,"MemoryAllocationFailed","'%s'",
+                  ResourceLimitError,"MemoryAllocationFailed","`%s'",
                   wand->name);
                 return((char **) NULL);
               }
@@ -867,7 +857,7 @@ WandExport char *MagickGetImageProperty(MagickWand *wand,const char *property)
   if (wand->images == (Image *) NULL)
     {
       (void) ThrowMagickException(wand->exception,GetMagickModule(),WandError,
-        "ContainsNoImages","'%s'",wand->name);
+        "ContainsNoImages","`%s'",wand->name);
       return((char *) NULL);
     }
   value=GetImageProperty(wand->images,property,wand->exception);
@@ -929,7 +919,7 @@ WandExport char **MagickGetImageProperties(MagickWand *wand,
   if (wand->images == (Image *) NULL)
     {
       (void) ThrowMagickException(wand->exception,GetMagickModule(),WandError,
-        "ContainsNoImages","'%s'",wand->name);
+        "ContainsNoImages","`%s'",wand->name);
       return((char **) NULL);
     }
   (void) GetImageProperty(wand->images,"exif:*",wand->exception);
@@ -952,7 +942,7 @@ WandExport char **MagickGetImageProperties(MagickWand *wand,
             if (properties == (char **) NULL)
               {
                 (void) ThrowMagickException(wand->exception,GetMagickModule(),
-                  ResourceLimitError,"MemoryAllocationFailed","'%s'",
+                  ResourceLimitError,"MemoryAllocationFailed","`%s'",
                   wand->name);
                 return((char **) NULL);
               }
@@ -1087,7 +1077,7 @@ WandExport char *MagickGetOption(MagickWand *wand,const char *key)
 %                                                                             %
 %                                                                             %
 %                                                                             %
-%   M a g i c k G e t O p t i o n                                             %
+%   M a g i c k G e t O p t i o n s                                           %
 %                                                                             %
 %                                                                             %
 %                                                                             %
@@ -1100,7 +1090,8 @@ WandExport char *MagickGetOption(MagickWand *wand,const char *key)
 %
 %  The format of the MagickGetOptions method is:
 %
-%      char *MagickGetOptions(MagickWand *wand,size_t *number_options)
+%      char *MagickGetOptions(MagickWand *wand,const char *pattern,
+%        size_t *number_options)
 %
 %  A description of each parameter follows:
 %
@@ -1134,7 +1125,7 @@ WandExport char **MagickGetOptions(MagickWand *wand,const char *pattern,
   if (wand->images == (Image *) NULL)
     {
       (void) ThrowMagickException(wand->exception,GetMagickModule(),WandError,
-        "ContainsNoImages","'%s'",wand->name);
+        "ContainsNoImages","`%s'",wand->name);
       return((char **) NULL);
     }
   length=1024;
@@ -1156,7 +1147,7 @@ WandExport char **MagickGetOptions(MagickWand *wand,const char *pattern,
             if (options == (char **) NULL)
               {
                 (void) ThrowMagickException(wand->exception,GetMagickModule(),
-                  ResourceLimitError,"MemoryAllocationFailed","'%s'",
+                  ResourceLimitError,"MemoryAllocationFailed","`%s'",
                   wand->name);
                 return((char **) NULL);
               }
@@ -1554,7 +1545,7 @@ WandExport double *MagickGetSamplingFactors(MagickWand *wand,
       p++;
     i++;
   }
-  sampling_factors=(double *) AcquireQuantumMemory((size_t) i,
+  sampling_factors=(double *) AcquireQuantumMemory((size_t) i+1,
     sizeof(*sampling_factors));
   if (sampling_factors == (double *) NULL)
     ThrowWandFatalException(ResourceLimitFatalError,"MemoryAllocationFailed",
@@ -1809,7 +1800,7 @@ WandExport unsigned char *MagickRemoveImageProfile(MagickWand *wand,
   if (wand->images == (Image *) NULL)
     {
       (void) ThrowMagickException(wand->exception,GetMagickModule(),WandError,
-        "ContainsNoImages","'%s'",wand->name);
+        "ContainsNoImages","`%s'",wand->name);
       return((unsigned char *) NULL);
     }
   *length=0;
@@ -2081,11 +2072,12 @@ WandExport MagickBooleanType MagickSetExtract(MagickWand *wand,
 {
   assert(wand != (MagickWand *) NULL);
   assert(wand->signature == WandSignature);
-  if( IfMagickTrue(wand->debug) )
+  if (wand->debug != MagickFalse)
     (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
-
+  if (wand->image_info->extract != (char *) NULL)
+    wand->image_info->extract=DestroyString(wand->image_info->extract);
   if (geometry != (const char *) NULL)
-    (void) CopyMagickString(wand->image_info->extract,geometry,MaxTextExtent);
+    (void) CloneString(&wand->image_info->extract,geometry);
   return(MagickTrue);
 }
 \f
@@ -2123,7 +2115,7 @@ WandExport MagickBooleanType MagickSetFilename(MagickWand *wand,
     (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
 
   if (filename != (const char *) NULL)
-    (void) CopyMagickString(wand->image_info->filename,filename,MaxTextExtent);
+    (void) CopyMagickString(wand->image_info->filename,filename,MagickPathExtent);
   return(MagickTrue);
 }
 \f
@@ -2208,7 +2200,7 @@ WandExport MagickBooleanType MagickSetFormat(MagickWand *wand,
   if (magick_info == (const MagickInfo *) NULL)
     return(MagickFalse);
   ClearMagickException(wand->exception);
-  (void) CopyMagickString(wand->image_info->magick,format,MaxTextExtent);
+  (void) CopyMagickString(wand->image_info->magick,format,MagickPathExtent);
   return(MagickTrue);
 }
 \f
@@ -2584,14 +2576,14 @@ WandExport MagickBooleanType MagickSetPage(MagickWand *wand,
   const ssize_t y)
 {
   char
-    geometry[MaxTextExtent];
+    geometry[MagickPathExtent];
 
   assert(wand != (MagickWand *) NULL);
   assert(wand->signature == WandSignature);
   if( IfMagickTrue(wand->debug) )
     (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
 
-  (void) FormatLocaleString(geometry,MaxTextExtent,"%.20gx%.20g%+.20g%+.20g",
+  (void) FormatLocaleString(geometry,MagickPathExtent,"%.20gx%.20g%+.20g%+.20g",
     (double) width,(double) height,(double) x,(double) y);
   (void) CloneString(&wand->image_info->page,geometry);
   return(MagickTrue);
@@ -2773,7 +2765,7 @@ WandExport MagickBooleanType MagickSetResourceLimit(const ResourceType type,
 %  The format of the MagickSetResolution method is:
 %
 %      MagickBooleanType MagickSetResolution(MagickWand *wand,
-%        const double x_resolution,const doubtl y_resolution)
+%        const double x_resolution,const double y_resolution)
 %
 %  A description of each parameter follows:
 %
@@ -2788,14 +2780,14 @@ WandExport MagickBooleanType MagickSetResolution(MagickWand *wand,
   const double x_resolution,const double y_resolution)
 {
   char
-    density[MaxTextExtent];
+    density[MagickPathExtent];
 
   assert(wand != (MagickWand *) NULL);
   assert(wand->signature == WandSignature);
   if( IfMagickTrue(wand->debug) )
     (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
 
-  (void) FormatLocaleString(density,MaxTextExtent,"%gx%g",x_resolution,
+  (void) FormatLocaleString(density,MagickPathExtent,"%gx%g",x_resolution,
     y_resolution);
   (void) CloneString(&wand->image_info->density,density);
   return(MagickTrue);
@@ -2833,7 +2825,7 @@ WandExport MagickBooleanType MagickSetSamplingFactors(MagickWand *wand,
   const size_t number_factors,const double *sampling_factors)
 {
   char
-    sampling_factor[MaxTextExtent];
+    sampling_factor[MagickPathExtent];
 
   register ssize_t
     i;
@@ -2850,12 +2842,12 @@ WandExport MagickBooleanType MagickSetSamplingFactors(MagickWand *wand,
     return(MagickTrue);
   for (i=0; i < (ssize_t) (number_factors-1); i++)
   {
-    (void) FormatLocaleString(sampling_factor,MaxTextExtent,"%g,",
+    (void) FormatLocaleString(sampling_factor,MagickPathExtent,"%g,",
       sampling_factors[i]);
     (void) ConcatenateString(&wand->image_info->sampling_factor,
       sampling_factor);
   }
-  (void) FormatLocaleString(sampling_factor,MaxTextExtent,"%g",
+  (void) FormatLocaleString(sampling_factor,MagickPathExtent,"%g",
     sampling_factors[i]);
   (void) ConcatenateString(&wand->image_info->sampling_factor,sampling_factor);
   return(MagickTrue);
@@ -2893,14 +2885,14 @@ WandExport MagickBooleanType MagickSetSize(MagickWand *wand,
   const size_t columns,const size_t rows)
 {
   char
-    geometry[MaxTextExtent];
+    geometry[MagickPathExtent];
 
   assert(wand != (MagickWand *) NULL);
   assert(wand->signature == WandSignature);
   if( IfMagickTrue(wand->debug) )
     (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
 
-  (void) FormatLocaleString(geometry,MaxTextExtent,"%.20gx%.20g",(double)
+  (void) FormatLocaleString(geometry,MagickPathExtent,"%.20gx%.20g",(double)
     columns,(double) rows);
   (void) CloneString(&wand->image_info->size,geometry);
   return(MagickTrue);
@@ -2941,14 +2933,14 @@ WandExport MagickBooleanType MagickSetSizeOffset(MagickWand *wand,
   const size_t columns,const size_t rows,const ssize_t offset)
 {
   char
-    geometry[MaxTextExtent];
+    geometry[MagickPathExtent];
 
   assert(wand != (MagickWand *) NULL);
   assert(wand->signature == WandSignature);
   if( IfMagickTrue(wand->debug) )
     (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
 
-  (void) FormatLocaleString(geometry,MaxTextExtent,"%.20gx%.20g%+.20g",
+  (void) FormatLocaleString(geometry,MagickPathExtent,"%.20gx%.20g%+.20g",
     (double) columns,(double) rows,(double) offset);
   (void) CloneString(&wand->image_info->size,geometry);
   return(MagickTrue);
@@ -2977,8 +2969,8 @@ WandExport MagickBooleanType MagickSetSizeOffset(MagickWand *wand,
 %    o wand: the magick wand.
 %
 %    o image_type: the image type:   UndefinedType, BilevelType, GrayscaleType,
-%      GrayscaleMatteType, PaletteType, PaletteMatteType, TrueColorType,
-%      TrueColorMatteType, ColorSeparationType, ColorSeparationMatteType,
+%      GrayscaleAlphaType, PaletteType, PaletteAlphaType, TrueColorType,
+%      TrueColorAlphaType, ColorSeparationType, ColorSeparationAlphaType,
 %      or OptimizeType.
 %
 */