]> granicus.if.org Git - imagemagick/blobdiff - MagickCore/identify.c
(no commit message)
[imagemagick] / MagickCore / identify.c
index 5b60422f46cd9765c3226447ca6bf652658f9727..a1b609de7ccb43385bac80e86ce5711cdca08941 100644 (file)
@@ -91,6 +91,7 @@
 #include "MagickCore/string_.h"
 #include "MagickCore/string-private.h"
 #include "MagickCore/timer.h"
+#include "MagickCore/token.h"
 #include "MagickCore/utility.h"
 #include "MagickCore/utility-private.h"
 #include "MagickCore/version.h"
@@ -325,9 +326,11 @@ MagickExport MagickBooleanType IdentifyImage(Image *image,FILE *file,
       if (image->type != UndefinedType)
         (void) FormatLocaleFile(file,"%s ",CommandOptionToMnemonic(
           MagickTypeOptions,(ssize_t) image->type));
+     if (image->colorspace != UndefinedColorspace)
+        (void) FormatLocaleFile(file,"%s ",CommandOptionToMnemonic(
+          MagickColorspaceOptions,(ssize_t) image->colorspace));
       if (image->storage_class == DirectClass)
         {
-          (void) FormatLocaleFile(file,"DirectClass ");
           if (image->total_colors != 0)
             {
               (void) FormatMagickSize(image->total_colors,MagickFalse,format);
@@ -336,10 +339,10 @@ MagickExport MagickBooleanType IdentifyImage(Image *image,FILE *file,
         }
       else
         if (image->total_colors <= image->colors)
-          (void) FormatLocaleFile(file,"PseudoClass %.20gc ",(double)
+          (void) FormatLocaleFile(file,"%.20gc ",(double)
             image->colors);
         else
-          (void) FormatLocaleFile(file,"PseudoClass %.20g=>%.20gc ",(double)
+          (void) FormatLocaleFile(file,"%.20g=>%.20gc ",(double)
             image->total_colors,(double) image->colors);
       if (image->error.mean_error_per_pixel != 0.0)
         (void) FormatLocaleFile(file,"%.20g/%f/%fdb ",(double)
@@ -393,13 +396,13 @@ MagickExport MagickBooleanType IdentifyImage(Image *image,FILE *file,
         (image->magick_rows != image->rows))
       (void) FormatLocaleFile(file,"  Base geometry: %.20gx%.20g\n",(double)
         image->magick_columns,(double) image->magick_rows);
-  if ((image->x_resolution != 0.0) && (image->y_resolution != 0.0))
+  if ((image->resolution.x != 0.0) && (image->resolution.y != 0.0))
     {
-      (void) FormatLocaleFile(file,"  Resolution: %gx%g\n",image->x_resolution,
-        image->y_resolution);
+      (void) FormatLocaleFile(file,"  Resolution: %gx%g\n",image->resolution.x,
+        image->resolution.y);
       (void) FormatLocaleFile(file,"  Print size: %gx%g\n",(double)
-        image->columns/image->x_resolution,(double) image->rows/
-        image->y_resolution);
+        image->columns/image->resolution.x,(double) image->rows/
+        image->resolution.y);
     }
   (void) FormatLocaleFile(file,"  Units: %s\n",CommandOptionToMnemonic(
     MagickResolutionOptions,(ssize_t) image->units));
@@ -418,6 +421,7 @@ MagickExport MagickBooleanType IdentifyImage(Image *image,FILE *file,
   channel_statistics=(ChannelStatistics *) NULL;
   channel_features=(ChannelFeatures *) NULL;
   colorspace=image->colorspace;
+  scale=1;
   if (ping == MagickFalse)
     {
       size_t
@@ -472,7 +476,7 @@ MagickExport MagickBooleanType IdentifyImage(Image *image,FILE *file,
           break;
         }
       }
-      if (image->matte != MagickFalse)
+      if (image->alpha_trait == BlendPixelTrait)
         (void) FormatLocaleFile(file,"    alpha: %.20g-bit\n",(double)
           channel_statistics[AlphaPixelChannel].depth);
       scale=1;
@@ -515,14 +519,14 @@ MagickExport MagickBooleanType IdentifyImage(Image *image,FILE *file,
           break;
         }
       }
-      if (image->matte != MagickFalse)
+      if (image->alpha_trait == BlendPixelTrait)
         (void) PrintChannelStatistics(file,AlphaPixelChannel,"Alpha",1.0/
           scale,channel_statistics);
       if (colorspace != GRAYColorspace)
         {
           (void) FormatLocaleFile(file,"  Image statistics:\n");
-          (void) PrintChannelStatistics(file,MaxPixelChannels,"Overall",
-            1.0/scale,channel_statistics);
+          (void) PrintChannelStatistics(file,(PixelChannel) MaxPixelChannels,
+            "Overall",1.0/scale,channel_statistics);
         }
       channel_statistics=(ChannelStatistics *) RelinquishMagickMemory(
         channel_statistics);
@@ -563,7 +567,7 @@ MagickExport MagickBooleanType IdentifyImage(Image *image,FILE *file,
           break;
         }
       }
-      if (image->matte != MagickFalse)
+      if (image->alpha_trait == BlendPixelTrait)
         (void) PrintChannelFeatures(file,AlphaPixelChannel,"Alpha",
           channel_features);
       channel_features=(ChannelFeatures *) RelinquishMagickMemory(
@@ -573,9 +577,9 @@ MagickExport MagickBooleanType IdentifyImage(Image *image,FILE *file,
     {
       if (image->colorspace == CMYKColorspace)
         (void) FormatLocaleFile(file,"  Total ink density: %.0f%%\n",100.0*
-          GetImageTotalInkDensity(image)/(double) QuantumRange);
+          GetImageTotalInkDensity(image,exception)/(double) QuantumRange);
       x=0;
-      if (image->matte != MagickFalse)
+      if (image->alpha_trait == BlendPixelTrait)
         {
           register const Quantum
             *p;
@@ -604,15 +608,14 @@ MagickExport MagickBooleanType IdentifyImage(Image *image,FILE *file,
                 pixel;
 
               GetPixelInfo(image,&pixel);
-              SetPixelInfo(image,p,&pixel);
-              (void) QueryMagickColorname(image,&pixel,SVGCompliance,tuple,
+              GetPixelInfoPixel(image,p,&pixel);
+              (void) QueryColorname(image,&pixel,SVGCompliance,tuple,
                 exception);
               (void) FormatLocaleFile(file,"  Alpha: %s ",tuple);
               GetColorTuple(&pixel,MagickTrue,tuple);
               (void) FormatLocaleFile(file,"  %s\n",tuple);
             }
         }
-      artifact=GetImageArtifact(image,"identify:unique-colors");
       if (IsHistogramImage(image,exception) != MagickFalse)
         {
           (void) FormatLocaleFile(file,"  Colors: %.20g\n",(double)
@@ -620,11 +623,12 @@ MagickExport MagickBooleanType IdentifyImage(Image *image,FILE *file,
           (void) FormatLocaleFile(file,"  Histogram:\n");
           (void) GetNumberColors(image,file,exception);
         }
-      else
-        if ((artifact != (const char *) NULL) &&
-            (IsMagickTrue(artifact) != MagickFalse))
-          (void) FormatLocaleFile(file,"  Colors: %.20g\n",(double)
-            GetNumberColors(image,(FILE *) NULL,exception));
+      else {
+          artifact=GetImageArtifact(image,"identify:unique-colors");
+          if (IfMagickTrue(IsStringTrue(artifact)))
+            (void) FormatLocaleFile(file,"  Colors: %.20g\n",(double)
+              GetNumberColors(image,(FILE *) NULL,exception));
+        }
     }
   if (image->storage_class == PseudoClass)
     {
@@ -647,7 +651,7 @@ MagickExport MagickBooleanType IdentifyImage(Image *image,FILE *file,
           p=image->colormap;
           for (i=0; i < (ssize_t) image->colors; i++)
           {
-            SetPixelInfoPacket(image,p,&pixel);
+            pixel=(*p);
             (void) CopyMagickString(tuple,"(",MaxTextExtent);
             ConcatenateColorComponent(&pixel,RedPixelChannel,X11Compliance,
               tuple);
@@ -663,14 +667,14 @@ MagickExport MagickBooleanType IdentifyImage(Image *image,FILE *file,
                 ConcatenateColorComponent(&pixel,BlackPixelChannel,
                   X11Compliance,tuple);
               }
-            if (pixel.matte != MagickFalse)
+            if (pixel.alpha_trait == BlendPixelTrait)
               {
                 (void) ConcatenateMagickString(tuple,",",MaxTextExtent);
                 ConcatenateColorComponent(&pixel,AlphaPixelChannel,
                   X11Compliance,tuple);
               }
             (void) ConcatenateMagickString(tuple,")",MaxTextExtent);
-            (void) QueryMagickColorname(image,&pixel,SVGCompliance,color,
+            (void) QueryColorname(image,&pixel,SVGCompliance,color,
               exception);
             GetColorTuple(&pixel,MagickTrue,hex);
             (void) FormatLocaleFile(file,"  %8ld: %s %s %s\n",(long) i,tuple,
@@ -807,7 +811,7 @@ MagickExport MagickBooleanType IdentifyImage(Image *image,FILE *file,
         while (property != (const char *) NULL)
         {
           (void) FormatLocaleFile(file,"  %s:\n",property);
-          value=GetImageProperty(tile,property);
+          value=GetImageProperty(tile,property,exception);
           if (value != (const char *) NULL)
             (void) FormatLocaleFile(file,"%s\n",value);
           property=GetNextImageProperty(tile);
@@ -816,7 +820,7 @@ MagickExport MagickBooleanType IdentifyImage(Image *image,FILE *file,
       }
       image_info=DestroyImageInfo(image_info);
     }
-  (void) GetImageProperty(image,"exif:*");
+  (void) GetImageProperty(image,"exif:*",exception);
   ResetImagePropertyIterator(image);
   property=GetNextImageProperty(image);
   if (property != (const char *) NULL)
@@ -828,14 +832,14 @@ MagickExport MagickBooleanType IdentifyImage(Image *image,FILE *file,
       while (property != (const char *) NULL)
       {
         (void) FormatLocaleFile(file,"    %s: ",property);
-        value=GetImageProperty(image,property);
+        value=GetImageProperty(image,property,exception);
         if (value != (const char *) NULL)
           (void) FormatLocaleFile(file,"%s\n",value);
         property=GetNextImageProperty(image);
       }
     }
   (void) FormatLocaleString(key,MaxTextExtent,"8BIM:1999,2998:#1");
-  value=GetImageProperty(image,key);
+  value=GetImageProperty(image,key,exception);
   if (value != (const char *) NULL)
     {
       /*
@@ -1061,9 +1065,11 @@ MagickExport MagickBooleanType IdentifyImage(Image *image,FILE *file,
   (void) FormatLocaleFile(file,"  Tainted: %s\n",CommandOptionToMnemonic(
     MagickBooleanOptions,(ssize_t) image->taint));
   (void) FormatMagickSize(GetBlobSize(image),MagickFalse,format);
-  (void) FormatLocaleFile(file,"  Filesize: %sB\n",format);
+  (void) FormatLocaleFile(file,"  Filesize: %s\n",format);
   (void) FormatMagickSize((MagickSizeType) image->columns*image->rows,
-     MagickFalse,format);
+    MagickFalse,format);
+  if (strlen(format) > 1)
+    format[strlen(format)-1]='\0';
   (void) FormatLocaleFile(file,"  Number pixels: %s\n",format);
   (void) FormatMagickSize((MagickSizeType) ((double) image->columns*image->rows/
     elapsed_time+0.5),MagickFalse,format);