]> granicus.if.org Git - imagemagick/blobdiff - MagickWand/identify.c
...
[imagemagick] / MagickWand / identify.c
index f294c9a936c121c872426edd72be60b6585973ad..7ade5c672387a208a06b96ed75c3a9d0f42a20fe 100644 (file)
 %               Identify an Image Format and Characteristics.                 %
 %                                                                             %
 %                           Software Design                                   %
-%                             John Cristy                                     %
+%                                Cristy                                       %
 %                            September 1994                                   %
 %                                                                             %
 %                                                                             %
-%  Copyright 1999-2012 ImageMagick Studio LLC, a non-profit organization      %
+%  Copyright 1999-2017 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  %
@@ -107,6 +107,8 @@ static MagickBooleanType IdentifyUsage(void)
     },
     *operators[]=
     {
+      "-channel mask        set the image channel mask",
+      "-grayscale method    convert image to grayscale",
       "-negate              replace every pixel with its complementary color ",
       (char *) NULL
     },
@@ -117,13 +119,16 @@ static MagickBooleanType IdentifyUsage(void)
       "-antialias           remove pixel-aliasing",
       "-authenticate password",
       "                     decipher image with this password",
-      "-channel type        apply option to select image channels",
+      "-clip                clip along the first path from the 8BIM profile",
+      "-clip-mask filename  associate a clip mask with the image",
+      "-clip-path id        clip along a named path from the 8BIM profile",
       "-colorspace type     alternate image colorspace",
       "-crop geometry       cut out a rectangular region of the image",
       "-define format:option",
       "                     define one or more image format options",
       "-density geometry    horizontal and vertical density of the image",
       "-depth value         image depth",
+      "-endian type         endianness (MSB or LSB) of the image",
       "-extract geometry    extract area from image",
       "-features distance   analyze image features (e.g. contrast, correlation)",
       "-format \"string\"     output formatted image characteristics",
@@ -132,9 +137,13 @@ static MagickBooleanType IdentifyUsage(void)
       "-interlace type      type of image interlacing scheme",
       "-interpolate method  pixel color interpolation method",
       "-limit type value    pixel cache resource limit",
+      "-matte               store matte channel if the image has one",
+      "-moments             report image moments",
       "-monitor             monitor progress",
       "-ping                efficiently determine image attributes",
+      "-precision value     maximum number of significant digits to print",
       "-quiet               suppress all warning messages",
+      "-read-mask filename  associate a read mask with the image",
       "-regard-warnings     pay attention to warning messages",
       "-respect-parentheses settings remain in effect until parenthesis boundary",
       "-sampling-factor geometry",
@@ -151,9 +160,7 @@ static MagickBooleanType IdentifyUsage(void)
       (char *) NULL
     };
 
-  (void) printf("Version: %s\n",GetMagickVersion((size_t *) NULL));
-  (void) printf("Copyright: %s\n",GetMagickCopyright());
-  (void) printf("Features: %s\n\n",GetMagickFeatures());
+  ListMagickVersion(stdout);
   (void) printf("Usage: %s [options ...] file [ [options ...] "
     "file ... ]\n",GetClientName());
   (void) printf("\nImage Settings:\n");
@@ -189,7 +196,7 @@ WandExport MagickBooleanType IdentifyImageCommand(ImageInfo *image_info,
 }
 #define ThrowIdentifyException(asperity,tag,option) \
 { \
-  (void) ThrowMagickException(exception,GetMagickModule(),asperity,tag,"'%s'", \
+  (void) ThrowMagickException(exception,GetMagickModule(),asperity,tag,"`%s'", \
     option); \
   DestroyIdentify(); \
   return(MagickFalse); \
@@ -234,7 +241,7 @@ WandExport MagickBooleanType IdentifyImageCommand(ImageInfo *image_info,
     Set defaults.
   */
   assert(image_info != (ImageInfo *) NULL);
-  assert(image_info->signature == MagickSignature);
+  assert(image_info->signature == MagickCoreSignature);
   if (image_info->debug != MagickFalse)
     (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
   assert(exception != (ExceptionInfo *) NULL);
@@ -244,13 +251,8 @@ WandExport MagickBooleanType IdentifyImageCommand(ImageInfo *image_info,
       if ((LocaleCompare("version",option+1) == 0) ||
           (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());
-          return(MagickFalse);
+          ListMagickVersion(stdout);
+          return(MagickTrue);
         }
     }
   if (argc < 2)
@@ -324,6 +326,7 @@ WandExport MagickBooleanType IdentifyImageCommand(ImageInfo *image_info,
           continue;
         AppendImageStack(images);
         FinalizeImageSettings(image_info,image,MagickFalse);
+        count=0;
         for ( ; image != (Image *) NULL; image=GetNextImageInList(image))
         {
           if (image->scene == 0)
@@ -344,8 +347,6 @@ WandExport MagickBooleanType IdentifyImageCommand(ImageInfo *image_info,
                   "MemoryAllocationFailed",GetExceptionMessage(errno));
               (void) ConcatenateString(&(*metadata),text);
               text=DestroyString(text);
-              if (LocaleCompare(format,"%n") == 0)
-                break;
             }
         }
         RemoveAllImageStack();
@@ -366,10 +367,11 @@ WandExport MagickBooleanType IdentifyImageCommand(ImageInfo *image_info,
             i++;
             if (i == (ssize_t) argc)
               ThrowIdentifyException(OptionError,"MissingArgument",option);
-            type=ParseCommandOption(MagickAlphaOptions,MagickFalse,argv[i]);
+            type=ParseCommandOption(MagickAlphaChannelOptions,MagickFalse,
+              argv[i]);
             if (type < 0)
-              ThrowIdentifyException(OptionError,"UnrecognizedAlphaChannelType",
-                argv[i]);
+              ThrowIdentifyException(OptionError,
+                "UnrecognizedAlphaChannelOption",argv[i]);
             break;
           }
         if (LocaleCompare("antialias",option+1) == 0)
@@ -379,7 +381,7 @@ WandExport MagickBooleanType IdentifyImageCommand(ImageInfo *image_info,
             if (*option == '+')
               break;
             i++;
-            if (i == (ssize_t) (argc-1))
+            if (i == (ssize_t) argc)
               ThrowIdentifyException(OptionError,"MissingArgument",option);
             break;
           }
@@ -406,7 +408,7 @@ WandExport MagickBooleanType IdentifyImageCommand(ImageInfo *image_info,
             if (*option == '+')
               break;
             i++;
-            if (i == (ssize_t) (argc-1))
+            if (i == (ssize_t) argc)
               ThrowIdentifyException(OptionError,"MissingArgument",option);
             channel=ParseChannelOption(argv[i]);
             if (channel < 0)
@@ -414,6 +416,24 @@ WandExport MagickBooleanType IdentifyImageCommand(ImageInfo *image_info,
                 argv[i]);
             break;
           }
+        if (LocaleCompare("clip",option+1) == 0)
+          break;
+        if (LocaleCompare("clip-mask",option+1) == 0)
+          {
+            if (*option == '+')
+              break;
+            i++;
+            if (i == (ssize_t) argc)
+              ThrowIdentifyException(OptionError,"MissingArgument",option);
+            break;
+          }
+        if (LocaleCompare("clip-path",option+1) == 0)
+          {
+            i++;
+            if (i == (ssize_t) argc)
+              ThrowIdentifyException(OptionError,"MissingArgument",option);
+            break;
+          }
         if (LocaleCompare("colorspace",option+1) == 0)
           {
             ssize_t
@@ -422,7 +442,7 @@ WandExport MagickBooleanType IdentifyImageCommand(ImageInfo *image_info,
             if (*option == '+')
               break;
             i++;
-            if (i == (ssize_t) (argc-1))
+            if (i == (ssize_t) argc)
               ThrowIdentifyException(OptionError,"MissingArgument",option);
             colorspace=ParseCommandOption(MagickColorspaceOptions,
               MagickFalse,argv[i]);
@@ -436,7 +456,7 @@ WandExport MagickBooleanType IdentifyImageCommand(ImageInfo *image_info,
             if (*option == '+')
               break;
             i++;
-            if (i == (ssize_t) (argc-1))
+            if (i == (ssize_t) argc)
               ThrowIdentifyException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowIdentifyInvalidArgumentException(option,argv[i]);
@@ -481,6 +501,8 @@ WandExport MagickBooleanType IdentifyImageCommand(ImageInfo *image_info,
                   ThrowIdentifyException(OptionError,"NoSuchOption",argv[i]);
                 break;
               }
+            if (LocaleNCompare("identify:locate",argv[i],15) == 0)
+              image_info->ping=MagickFalse;
             break;
           }
         if (LocaleCompare("density",option+1) == 0)
@@ -510,7 +532,7 @@ WandExport MagickBooleanType IdentifyImageCommand(ImageInfo *image_info,
             if (*option == '+')
               break;
             i++;
-            if (i == (ssize_t) (argc-1))
+            if (i == (ssize_t) argc)
               ThrowIdentifyException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowIdentifyInvalidArgumentException(option,argv[i]);
@@ -518,6 +540,27 @@ WandExport MagickBooleanType IdentifyImageCommand(ImageInfo *image_info,
           }
         ThrowIdentifyException(OptionError,"UnrecognizedOption",option)
       }
+      case 'e':
+      {
+        if (LocaleCompare("endian",option+1) == 0)
+          {
+            ssize_t
+              endian;
+
+            if (*option == '+')
+              break;
+            i++;
+            if (i == (ssize_t) argc)
+              ThrowIdentifyException(OptionError,"MissingArgument",option);
+            endian=ParseCommandOption(MagickEndianOptions,MagickFalse,
+              argv[i]);
+            if (endian < 0)
+              ThrowIdentifyException(OptionError,"UnrecognizedEndianType",
+                argv[i]);
+            break;
+          }
+        ThrowIdentifyException(OptionError,"UnrecognizedOption",option)
+      }
       case 'f':
       {
         if (LocaleCompare("features",option+1) == 0)
@@ -525,7 +568,7 @@ WandExport MagickBooleanType IdentifyImageCommand(ImageInfo *image_info,
             if (*option == '+')
               break;
             i++;
-            if (i == (ssize_t) (argc-1))
+            if (i == (ssize_t) argc)
               ThrowIdentifyException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowIdentifyInvalidArgumentException(option,argv[i]);
@@ -547,7 +590,7 @@ WandExport MagickBooleanType IdentifyImageCommand(ImageInfo *image_info,
             if (*option == '+')
               break;
             i++;
-            if (i == (ssize_t) (argc-1))
+            if (i == (ssize_t) argc)
               ThrowIdentifyException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowIdentifyInvalidArgumentException(option,argv[i]);
@@ -560,7 +603,35 @@ WandExport MagickBooleanType IdentifyImageCommand(ImageInfo *image_info,
         if (LocaleCompare("gamma",option+1) == 0)
           {
             i++;
-            if (i == (ssize_t) (argc-1))
+            if (i == (ssize_t) argc)
+              ThrowIdentifyException(OptionError,"MissingArgument",option);
+            if (IsGeometry(argv[i]) == MagickFalse)
+              ThrowIdentifyInvalidArgumentException(option,argv[i]);
+            break;
+          }
+        if (LocaleCompare("grayscale",option+1) == 0)
+          {
+            ssize_t
+              method;
+
+            if (*option == '+')
+              break;
+            i++;
+            if (i == (ssize_t) argc)
+              ThrowIdentifyException(OptionError,"MissingArgument",option);
+            method=ParseCommandOption(MagickPixelIntensityOptions,MagickFalse,
+              argv[i]);
+            if (method < 0)
+              ThrowIdentifyException(OptionError,"UnrecognizedIntensityMethod",
+                argv[i]);
+            break;
+          }
+        if (LocaleCompare("green-primary",option+1) == 0)
+          {
+            if (*option == '+')
+              break;
+            i++;
+            if (i == (ssize_t) argc)
               ThrowIdentifyException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowIdentifyInvalidArgumentException(option,argv[i]);
@@ -662,7 +733,7 @@ WandExport MagickBooleanType IdentifyImageCommand(ImageInfo *image_info,
             status=MogrifyImageInfo(image_info,(int) (i-j+1),(const char **)
               argv+j,exception);
             DestroyIdentify();
-            return(status != 0 ? MagickFalse : MagickTrue);
+            return(status == 0 ? MagickTrue : MagickFalse);
           }
         if (LocaleCompare("log",option+1) == 0)
           {
@@ -678,8 +749,19 @@ WandExport MagickBooleanType IdentifyImageCommand(ImageInfo *image_info,
       }
       case 'm':
       {
+        if (LocaleCompare("mask",option+1) == 0)
+          {
+            if (*option == '+')
+              break;
+            i++;
+            if (i == (ssize_t) argc)
+              ThrowIdentifyException(OptionError,"MissingArgument",option);
+            break;
+          }
         if (LocaleCompare("matte",option+1) == 0)
           break;
+        if (LocaleCompare("moments",option+1) == 0)
+          break;
         if (LocaleCompare("monitor",option+1) == 0)
           break;
         ThrowIdentifyException(OptionError,"UnrecognizedOption",option)
@@ -694,6 +776,17 @@ WandExport MagickBooleanType IdentifyImageCommand(ImageInfo *image_info,
       {
         if (LocaleCompare("ping",option+1) == 0)
           break;
+        if (LocaleCompare("precision",option+1) == 0)
+          {
+            if (*option == '+')
+              break;
+            i++;
+            if (i == (ssize_t) argc)
+              ThrowIdentifyException(OptionError,"MissingArgument",option);
+            if (IsGeometry(argv[i]) == MagickFalse)
+              ThrowIdentifyInvalidArgumentException(option,argv[i]);
+            break;
+          }
         ThrowIdentifyException(OptionError,"UnrecognizedOption",option)
       }
       case 'q':
@@ -731,7 +824,7 @@ WandExport MagickBooleanType IdentifyImageCommand(ImageInfo *image_info,
             if (*option == '+')
               break;
             i++;
-            if (i == (ssize_t) (argc-1))
+            if (i == (ssize_t) argc)
               ThrowIdentifyException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowIdentifyInvalidArgumentException(option,argv[i]);
@@ -787,7 +880,7 @@ WandExport MagickBooleanType IdentifyImageCommand(ImageInfo *image_info,
             if (*option == '+')
               break;
             i++;
-            if (i == (ssize_t) (argc-1))
+            if (i == (ssize_t) argc)
               ThrowIdentifyException(OptionError,"MissingArgument",option);
             units=ParseCommandOption(MagickResolutionOptions,MagickFalse,
               argv[i]);
@@ -810,7 +903,7 @@ WandExport MagickBooleanType IdentifyImageCommand(ImageInfo *image_info,
             if (*option == '+')
               break;
             i++;
-            if (i == (ssize_t) (argc-1))
+            if (i == (ssize_t) argc)
               ThrowIdentifyException(OptionError,"MissingArgument",option);
             method=ParseCommandOption(MagickVirtualPixelOptions,MagickFalse,
               argv[i]);