]> granicus.if.org Git - imagemagick/blob - MagickCore/identify.c
(no commit message)
[imagemagick] / MagickCore / identify.c
1 /*
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3 %                                                                             %
4 %                                                                             %
5 %                                                                             %
6 %           IIIII  DDDD   EEEEE  N   N  TTTTT  IIIII  FFFFF  Y   Y            %
7 %             I    D   D  E      NN  N    T      I    F       Y Y             %
8 %             I    D   D  EEE    N N N    T      I    FFF      Y              %
9 %             I    D   D  E      N  NN    T      I    F        Y              %
10 %           IIIII  DDDD   EEEEE  N   N    T    IIIII  F        Y              %
11 %                                                                             %
12 %                                                                             %
13 %               Identify an Image Format and Characteristics.                 %
14 %                                                                             %
15 %                           Software Design                                   %
16 %                             John Cristy                                     %
17 %                            September 1994                                   %
18 %                                                                             %
19 %                                                                             %
20 %  Copyright 1999-2014 ImageMagick Studio LLC, a non-profit organization      %
21 %  dedicated to making software imaging solutions freely available.           %
22 %                                                                             %
23 %  You may not use this file except in compliance with the License.  You may  %
24 %  obtain a copy of the License at                                            %
25 %                                                                             %
26 %    http://www.imagemagick.org/script/license.php                            %
27 %                                                                             %
28 %  Unless required by applicable law or agreed to in writing, software        %
29 %  distributed under the License is distributed on an "AS IS" BASIS,          %
30 %  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   %
31 %  See the License for the specific language governing permissions and        %
32 %  limitations under the License.                                             %
33 %                                                                             %
34 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
35 %
36 %  Identify describes the format and characteristics of one or more image
37 %  files.  It will also report if an image is incomplete or corrupt.
38 %
39 %
40 */
41 \f
42 /*
43   Include declarations.
44 */
45 #include "MagickCore/studio.h"
46 #include "MagickCore/annotate.h"
47 #include "MagickCore/artifact.h"
48 #include "MagickCore/attribute.h"
49 #include "MagickCore/blob.h"
50 #include "MagickCore/cache.h"
51 #include "MagickCore/client.h"
52 #include "MagickCore/coder.h"
53 #include "MagickCore/color.h"
54 #include "MagickCore/configure.h"
55 #include "MagickCore/constitute.h"
56 #include "MagickCore/decorate.h"
57 #include "MagickCore/delegate.h"
58 #include "MagickCore/draw.h"
59 #include "MagickCore/effect.h"
60 #include "MagickCore/exception.h"
61 #include "MagickCore/exception-private.h"
62 #include "MagickCore/feature.h"
63 #include "MagickCore/gem.h"
64 #include "MagickCore/geometry.h"
65 #include "MagickCore/histogram.h"
66 #include "MagickCore/identify.h"
67 #include "MagickCore/image.h"
68 #include "MagickCore/image-private.h"
69 #include "MagickCore/list.h"
70 #include "MagickCore/locale_.h"
71 #include "MagickCore/log.h"
72 #include "MagickCore/magic.h"
73 #include "MagickCore/magick.h"
74 #include "MagickCore/memory_.h"
75 #include "MagickCore/module.h"
76 #include "MagickCore/monitor.h"
77 #include "MagickCore/montage.h"
78 #include "MagickCore/option.h"
79 #include "MagickCore/pixel-accessor.h"
80 #include "MagickCore/prepress.h"
81 #include "MagickCore/profile.h"
82 #include "MagickCore/property.h"
83 #include "MagickCore/quantize.h"
84 #include "MagickCore/quantum.h"
85 #include "MagickCore/random_.h"
86 #include "MagickCore/registry.h"
87 #include "MagickCore/resize.h"
88 #include "MagickCore/resource_.h"
89 #include "MagickCore/signature.h"
90 #include "MagickCore/statistic.h"
91 #include "MagickCore/string_.h"
92 #include "MagickCore/string-private.h"
93 #include "MagickCore/timer.h"
94 #include "MagickCore/token.h"
95 #include "MagickCore/utility.h"
96 #include "MagickCore/utility-private.h"
97 #include "MagickCore/version.h"
98 #if defined(MAGICKCORE_LCMS_DELEGATE)
99 #if defined(MAGICKCORE_HAVE_LCMS_LCMS2_H)
100 #include <lcms/lcms2.h>
101 #elif defined(MAGICKCORE_HAVE_LCMS2_H)
102 #include "lcms2.h"
103 #elif defined(MAGICKCORE_HAVE_LCMS_LCMS_H)
104 #include <lcms/lcms.h>
105 #else
106 #include "lcms.h"
107 #endif
108 #endif
109 \f
110 /*
111   Define declarations.
112 */
113 #if defined(MAGICKCORE_LCMS_DELEGATE)
114 #if defined(LCMS_VERSION) && (LCMS_VERSION < 2000)
115 #define cmsUInt32Number  DWORD
116 #endif
117 #endif
118 \f
119 /*
120 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
121 %                                                                             %
122 %                                                                             %
123 %                                                                             %
124 %   I d e n t i f y I m a g e                                                 %
125 %                                                                             %
126 %                                                                             %
127 %                                                                             %
128 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
129 %
130 %  IdentifyImage() identifies an image by printing its attributes to the file.
131 %  Attributes include the image width, height, size, and others.
132 %
133 %  The format of the IdentifyImage method is:
134 %
135 %      MagickBooleanType IdentifyImage(Image *image,FILE *file,
136 %        const MagickBooleanType verbose,ExceptionInfo *exception)
137 %
138 %  A description of each parameter follows:
139 %
140 %    o image: the image.
141 %
142 %    o file: the file, typically stdout.
143 %
144 %    o verbose: A value other than zero prints more detailed information
145 %      about the image.
146 %
147 %    o exception: return any errors or warnings in this structure.
148 %
149 */
150
151 static ChannelStatistics *GetLocationStatistics(const Image *image,
152   const StatisticType type,ExceptionInfo *exception)
153 {
154   ChannelStatistics
155     *channel_statistics;
156
157   register ssize_t
158     i;
159
160   ssize_t
161     y;
162
163   assert(image != (Image *) NULL);
164   assert(image->signature == MagickSignature);
165   if (image->debug != MagickFalse)
166     (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
167   channel_statistics=(ChannelStatistics *) AcquireQuantumMemory(
168     MaxPixelChannels+1,sizeof(*channel_statistics));
169   if (channel_statistics == (ChannelStatistics *) NULL)
170     ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed");
171   (void) ResetMagickMemory(channel_statistics,0,(MaxPixelChannels+1)*
172     sizeof(*channel_statistics));
173   for (i=0; i <= (ssize_t) MaxPixelChannels; i++)
174   {
175     switch (type)
176     {
177       case MaximumStatistic:
178       default:
179       {
180         channel_statistics[i].maxima=(-MagickHuge);
181         break;
182       }
183       case MinimumStatistic:
184       {
185         channel_statistics[i].minima=MagickHuge;
186         break;
187       }
188     }
189   }
190   for (y=0; y < (ssize_t) image->rows; y++)
191   {
192     register const Quantum
193       *restrict p;
194
195     register ssize_t
196       x;
197
198     p=GetVirtualPixels(image,0,y,image->columns,1,exception);
199     if (p == (const Quantum *) NULL)
200       break;
201     for (x=0; x < (ssize_t) image->columns; x++)
202     {
203       register ssize_t
204         i;
205
206       if (GetPixelReadMask(image,p) == 0)
207         {
208           p+=GetPixelChannels(image);
209           continue;
210         }
211       for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
212       {
213         PixelChannel channel=GetPixelChannelChannel(image,i);
214         PixelTrait traits=GetPixelChannelTraits(image,channel);
215         if (traits == UndefinedPixelTrait)
216           continue;
217         switch (type)
218         {
219           case MaximumStatistic:
220           default:
221           {
222             if ((double) p[i] > channel_statistics[channel].maxima)
223               channel_statistics[channel].maxima=(double) p[i];
224             break;
225           }
226           case MinimumStatistic:
227           {
228             if ((double) p[i] < channel_statistics[channel].minima)
229               channel_statistics[channel].minima=(double) p[i];
230             break;
231           }
232         }
233       }
234       p+=GetPixelChannels(image);
235     }
236   }
237   return(channel_statistics);
238 }
239
240 static ssize_t PrintChannelFeatures(FILE *file,const PixelChannel channel,
241   const char *name,const ChannelFeatures *channel_features)
242 {
243 #define PrintFeature(feature) \
244   GetMagickPrecision(),(feature)[0], \
245   GetMagickPrecision(),(feature)[1], \
246   GetMagickPrecision(),(feature)[2], \
247   GetMagickPrecision(),(feature)[3], \
248   GetMagickPrecision(),((feature)[0]+(feature)[1]+(feature)[2]+(feature)[3])/4.0 \
249
250 #define FeaturesFormat "    %s:\n" \
251   "      Angular Second Moment:\n" \
252   "        %.*g, %.*g, %.*g, %.*g, %.*g\n" \
253   "      Contrast:\n" \
254   "        %.*g, %.*g, %.*g, %.*g, %.*g\n" \
255   "      Correlation:\n" \
256   "        %.*g, %.*g, %.*g, %.*g, %.*g\n" \
257   "      Sum of Squares: Variance:\n" \
258   "        %.*g, %.*g, %.*g, %.*g, %.*g\n" \
259   "      Inverse Difference Moment:\n" \
260   "        %.*g, %.*g, %.*g, %.*g, %.*g\n" \
261   "      Sum Average:\n" \
262   "        %.*g, %.*g, %.*g, %.*g, %.*g\n" \
263   "      Sum Variance:\n" \
264   "        %.*g, %.*g, %.*g, %.*g, %.*g\n" \
265   "      Sum Entropy:\n" \
266   "        %.*g, %.*g, %.*g, %.*g, %.*g\n" \
267   "      Entropy:\n" \
268   "        %.*g, %.*g, %.*g, %.*g, %.*g\n" \
269   "      Difference Variance:\n" \
270   "        %.*g, %.*g, %.*g, %.*g, %.*g\n" \
271   "      Difference Entropy:\n" \
272   "        %.*g, %.*g, %.*g, %.*g, %.*g\n" \
273   "      Information Measure of Correlation 1:\n" \
274   "        %.*g, %.*g, %.*g, %.*g, %.*g\n" \
275   "      Information Measure of Correlation 2:\n" \
276   "        %.*g, %.*g, %.*g, %.*g, %.*g\n" \
277   "      Maximum Correlation Coefficient:\n" \
278   "        %.*g, %.*g, %.*g, %.*g, %.*g\n"
279
280   ssize_t
281     n;
282
283   n=FormatLocaleFile(file,FeaturesFormat,name,
284     PrintFeature(channel_features[channel].angular_second_moment),
285     PrintFeature(channel_features[channel].contrast),
286     PrintFeature(channel_features[channel].correlation),
287     PrintFeature(channel_features[channel].variance_sum_of_squares),
288     PrintFeature(channel_features[channel].inverse_difference_moment),
289     PrintFeature(channel_features[channel].sum_average),
290     PrintFeature(channel_features[channel].sum_variance),
291     PrintFeature(channel_features[channel].sum_entropy),
292     PrintFeature(channel_features[channel].entropy),
293     PrintFeature(channel_features[channel].difference_variance),
294     PrintFeature(channel_features[channel].difference_entropy),
295     PrintFeature(channel_features[channel].measure_of_correlation_1),
296     PrintFeature(channel_features[channel].measure_of_correlation_2),
297     PrintFeature(channel_features[channel].maximum_correlation_coefficient));
298   return(n);
299 }
300
301 static ssize_t PrintChannelLocations(FILE *file,const Image *image,
302   const PixelChannel channel,const char *name,const StatisticType type,
303   const size_t max_locations,const ChannelStatistics *channel_statistics)
304 {
305   double
306     target;
307
308   ExceptionInfo
309     *exception;
310
311   ssize_t
312     n,
313     y;
314
315   switch (type)
316   {
317     case MaximumStatistic:
318     default:
319     {
320       target=channel_statistics[channel].maxima;
321       break;
322     }
323     case MinimumStatistic:
324     {
325       target=channel_statistics[channel].minima;
326       break;
327     }
328   }
329   (void) FormatLocaleFile(file,"  %s: %.*g (%.*g)",name,GetMagickPrecision(),
330     target,GetMagickPrecision(),QuantumScale*target);
331   exception=AcquireExceptionInfo();
332   n=0;
333   for (y=0; y < (ssize_t) image->rows; y++)
334   {
335     register const Quantum
336       *p;
337
338     ssize_t
339       offset,
340       x;
341
342     p=GetVirtualPixels(image,0,y,image->columns,1,exception);
343     if (p == (const Quantum *) NULL)
344       break;
345     for (x=0; x < (ssize_t) image->columns; x++)
346     {
347       MagickBooleanType
348         match;
349
350       PixelTrait traits=GetPixelChannelTraits(image,channel);
351       if (traits == UndefinedPixelTrait)
352         continue;
353       offset=GetPixelChannelOffset(image,channel);
354       match=fabs((double) p[offset]-target) < 0.5 ? MagickTrue : MagickFalse;
355       if (match != MagickFalse)
356         {
357           if ((max_locations != 0) && (n >= max_locations))
358             break;
359           (void) FormatLocaleFile(file," %.20g,%.20g",(double) x,(double) y);
360           n++;
361         }
362       p+=GetPixelChannels(image);
363     }
364     if (x < (ssize_t) image->columns)
365       break;
366   }
367   (void) FormatLocaleFile(file,"\n");
368   return(n);
369 }
370
371 static ssize_t PrintChannelStatistics(FILE *file,const PixelChannel channel,
372   const char *name,const double scale,
373   const ChannelStatistics *channel_statistics)
374 {
375 #define StatisticsFormat "    %s:\n      min: " QuantumFormat  \
376   " (%g)\n      max: " QuantumFormat " (%g)\n"  \
377   "      mean: %g (%g)\n      standard deviation: %g (%g)\n"  \
378   "      kurtosis: %g\n      skewness: %g\n"
379
380   ssize_t
381     n;
382
383   n=FormatLocaleFile(file,StatisticsFormat,name,ClampToQuantum(scale*
384     channel_statistics[channel].minima),channel_statistics[channel].minima/
385     (double) QuantumRange,ClampToQuantum(scale*
386     channel_statistics[channel].maxima),channel_statistics[channel].maxima/
387     (double) QuantumRange,scale*channel_statistics[channel].mean,
388     channel_statistics[channel].mean/(double) QuantumRange,scale*
389     channel_statistics[channel].standard_deviation,
390     channel_statistics[channel].standard_deviation/(double) QuantumRange,
391     channel_statistics[channel].kurtosis,channel_statistics[channel].skewness);
392   return(n);
393 }
394
395 MagickExport MagickBooleanType IdentifyImage(Image *image,FILE *file,
396   const MagickBooleanType verbose,ExceptionInfo *exception)
397 {
398   char
399     color[MaxTextExtent],
400     format[MaxTextExtent],
401     key[MaxTextExtent];
402
403   ChannelFeatures
404     *channel_features;
405
406   ChannelStatistics
407     *channel_statistics;
408
409   ColorspaceType
410     colorspace;
411
412   const char
413     *artifact,
414     *locate,
415     *name,
416     *property,
417     *registry,
418     *value;
419
420   const MagickInfo
421     *magick_info;
422
423   double
424     elapsed_time,
425     user_time;
426
427   ImageType
428     type;
429
430   MagickBooleanType
431     ping;
432
433   register const Quantum
434     *p;
435
436   register ssize_t
437     i,
438     x;
439
440   size_t
441     distance,
442     scale;
443
444   ssize_t
445     y;
446
447   assert(image != (Image *) NULL);
448   assert(image->signature == MagickSignature);
449   if (image->debug != MagickFalse)
450     (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
451   if (file == (FILE *) NULL)
452     file=stdout;
453   locate=GetImageArtifact(image,"identify:locate");
454   if (locate != (const char *) NULL)
455     {
456       const char
457         *limit;
458
459       size_t
460         max_locations;
461
462       StatisticType
463         type;
464
465       /*
466         Display minimum, maximum, or mean pixel locations.
467       */
468       type=(StatisticType) ParseCommandOption(MagickStatisticOptions,
469         MagickFalse,locate);
470       limit=GetImageArtifact(image,"identify:limit");
471       max_locations=0;
472       if (limit != (const char *) NULL)
473         max_locations=StringToUnsignedLong(limit);
474       channel_statistics=GetLocationStatistics(image,type,exception);
475       if (channel_statistics == (ChannelStatistics *) NULL)
476         return(MagickFalse);
477       colorspace=image->colorspace;
478       if (IsImageGray(image,exception) != MagickFalse)
479         colorspace=GRAYColorspace;
480       (void) FormatLocaleFile(file,"Channel %s locations:\n",locate);
481       switch (colorspace)
482       {
483         case RGBColorspace:
484         default:
485         {
486           (void) PrintChannelLocations(file,image,RedPixelChannel,"Red",
487             type,max_locations,channel_statistics);
488           (void) PrintChannelLocations(file,image,GreenPixelChannel,"Green",
489             type,max_locations,channel_statistics);
490           (void) PrintChannelLocations(file,image,BluePixelChannel,"Blue",
491             type,max_locations,channel_statistics);
492           break;
493         }
494         case CMYKColorspace:
495         {
496           (void) PrintChannelLocations(file,image,CyanPixelChannel,"Cyan",
497             type,max_locations,channel_statistics);
498           (void) PrintChannelLocations(file,image,MagentaPixelChannel,"Magenta",
499             type,max_locations,channel_statistics);
500           (void) PrintChannelLocations(file,image,YellowPixelChannel,"Yellow",
501             type,max_locations,channel_statistics);
502           (void) PrintChannelLocations(file,image,BlackPixelChannel,"Black",
503             type,max_locations,channel_statistics);
504           break;
505         }
506         case GRAYColorspace:
507         {
508           (void) PrintChannelLocations(file,image,GrayPixelChannel,"Gray",
509             type,max_locations,channel_statistics);
510           break;
511         }
512       }
513       if (image->alpha_trait == BlendPixelTrait)
514         (void) PrintChannelLocations(file,image,AlphaPixelChannel,"Alpha",
515           type,max_locations,channel_statistics);
516       channel_statistics=(ChannelStatistics *) RelinquishMagickMemory(
517         channel_statistics);
518       return(ferror(file) != 0 ? MagickFalse : MagickTrue);
519     }
520   *format='\0';
521   elapsed_time=GetElapsedTime(&image->timer);
522   user_time=GetUserTime(&image->timer);
523   GetTimerInfo(&image->timer);
524   if (verbose == MagickFalse)
525     {
526       /*
527         Display summary info about the image.
528       */
529       if (*image->magick_filename != '\0')
530         if (LocaleCompare(image->magick_filename,image->filename) != 0)
531           (void) FormatLocaleFile(file,"%s=>",image->magick_filename);
532        if ((GetPreviousImageInList(image) == (Image *) NULL) &&
533            (GetNextImageInList(image) == (Image *) NULL) &&
534            (image->scene == 0))
535         (void) FormatLocaleFile(file,"%s ",image->filename);
536       else
537         (void) FormatLocaleFile(file,"%s[%.20g] ",image->filename,(double)
538           image->scene);
539       (void) FormatLocaleFile(file,"%s ",image->magick);
540       if ((image->magick_columns != 0) || (image->magick_rows != 0))
541         if ((image->magick_columns != image->columns) ||
542             (image->magick_rows != image->rows))
543           (void) FormatLocaleFile(file,"%.20gx%.20g=>",(double)
544             image->magick_columns,(double) image->magick_rows);
545       (void) FormatLocaleFile(file,"%.20gx%.20g ",(double) image->columns,
546         (double) image->rows);
547       if ((image->page.width != 0) || (image->page.height != 0) ||
548           (image->page.x != 0) || (image->page.y != 0))
549         (void) FormatLocaleFile(file,"%.20gx%.20g%+.20g%+.20g ",(double)
550           image->page.width,(double) image->page.height,(double) image->page.x,
551           (double) image->page.y);
552       (void) FormatLocaleFile(file,"%.20g-bit ",(double) image->depth);
553       if (image->type != UndefinedType)
554         (void) FormatLocaleFile(file,"%s ",CommandOptionToMnemonic(
555           MagickTypeOptions,(ssize_t) image->type));
556       if (image->colorspace != UndefinedColorspace)
557         (void) FormatLocaleFile(file,"%s ",CommandOptionToMnemonic(
558           MagickColorspaceOptions,(ssize_t) image->colorspace));
559       if (image->storage_class == DirectClass)
560         {
561           if (image->total_colors != 0)
562             {
563               (void) FormatMagickSize(image->total_colors,MagickFalse,format);
564               (void) FormatLocaleFile(file,"%s ",format);
565             }
566         }
567       else
568         if (image->total_colors <= image->colors)
569           (void) FormatLocaleFile(file,"%.20gc ",(double)
570             image->colors);
571         else
572           (void) FormatLocaleFile(file,"%.20g=>%.20gc ",(double)
573             image->total_colors,(double) image->colors);
574       if (image->error.mean_error_per_pixel != 0.0)
575         (void) FormatLocaleFile(file,"%.20g/%f/%fdb ",(double)
576           (image->error.mean_error_per_pixel+0.5),
577           image->error.normalized_mean_error,
578           image->error.normalized_maximum_error);
579       if (GetBlobSize(image) != 0)
580         {
581           (void) FormatMagickSize(GetBlobSize(image),MagickFalse,format);
582           (void) FormatLocaleFile(file,"%s ",format);
583         }
584       (void) FormatLocaleFile(file,"%0.3fu %lu:%02lu.%03lu",user_time,
585         (unsigned long) (elapsed_time/60.0),(unsigned long) floor(fmod(
586         elapsed_time,60.0)),(unsigned long) (1000.0*(elapsed_time-
587         floor(elapsed_time))));
588       (void) FormatLocaleFile(file,"\n");
589       (void) fflush(file);
590       return(ferror(file) != 0 ? MagickFalse : MagickTrue);
591     }
592   /*
593     Display verbose info about the image.
594   */
595   p=GetVirtualPixels(image,0,0,1,1,exception);
596   ping=p == (const Quantum *) NULL ? MagickTrue : MagickFalse;
597   type=GetImageType(image,exception);
598   (void) SignatureImage(image,exception);
599   (void) FormatLocaleFile(file,"Image: %s\n",image->filename);
600   if (*image->magick_filename != '\0')
601     if (LocaleCompare(image->magick_filename,image->filename) != 0)
602       {
603         char
604           filename[MaxTextExtent];
605
606         GetPathComponent(image->magick_filename,TailPath,filename);
607         (void) FormatLocaleFile(file,"  Base filename: %s\n",filename);
608       }
609   magick_info=GetMagickInfo(image->magick,exception);
610   if ((magick_info == (const MagickInfo *) NULL) ||
611       (GetMagickDescription(magick_info) == (const char *) NULL))
612     (void) FormatLocaleFile(file,"  Format: %s\n",image->magick);
613   else
614     (void) FormatLocaleFile(file,"  Format: %s (%s)\n",image->magick,
615       GetMagickDescription(magick_info));
616   if ((magick_info == (const MagickInfo *) NULL) ||
617       (GetMagickMimeType(magick_info) != (const char *) NULL))
618     (void) FormatLocaleFile(file,"  Mime type: %s\n",GetMagickMimeType(
619       magick_info));
620   (void) FormatLocaleFile(file,"  Class: %s\n",CommandOptionToMnemonic(
621     MagickClassOptions,(ssize_t) image->storage_class));
622   (void) FormatLocaleFile(file,"  Geometry: %.20gx%.20g%+.20g%+.20g\n",(double)
623     image->columns,(double) image->rows,(double) image->tile_offset.x,(double)
624     image->tile_offset.y);
625   if ((image->magick_columns != 0) || (image->magick_rows != 0))
626     if ((image->magick_columns != image->columns) ||
627         (image->magick_rows != image->rows))
628       (void) FormatLocaleFile(file,"  Base geometry: %.20gx%.20g\n",(double)
629         image->magick_columns,(double) image->magick_rows);
630   if ((image->resolution.x != 0.0) && (image->resolution.y != 0.0))
631     {
632       (void) FormatLocaleFile(file,"  Resolution: %gx%g\n",image->resolution.x,
633         image->resolution.y);
634       (void) FormatLocaleFile(file,"  Print size: %gx%g\n",(double)
635         image->columns/image->resolution.x,(double) image->rows/
636         image->resolution.y);
637     }
638   (void) FormatLocaleFile(file,"  Units: %s\n",CommandOptionToMnemonic(
639     MagickResolutionOptions,(ssize_t) image->units));
640   (void) FormatLocaleFile(file,"  Type: %s\n",CommandOptionToMnemonic(
641     MagickTypeOptions,(ssize_t) type));
642   if (image->type != UndefinedType)
643     (void) FormatLocaleFile(file,"  Base type: %s\n",CommandOptionToMnemonic(
644       MagickTypeOptions,(ssize_t) image->type));
645   (void) FormatLocaleFile(file,"  Endianess: %s\n",CommandOptionToMnemonic(
646     MagickEndianOptions,(ssize_t) image->endian));
647   /*
648     Detail channel depth and extrema.
649   */
650   (void) FormatLocaleFile(file,"  Colorspace: %s\n",CommandOptionToMnemonic(
651     MagickColorspaceOptions,(ssize_t) image->colorspace));
652   channel_statistics=(ChannelStatistics *) NULL;
653   channel_features=(ChannelFeatures *) NULL;
654   colorspace=image->colorspace;
655   scale=1;
656   if (ping == MagickFalse)
657     {
658       size_t
659         depth;
660
661       channel_statistics=GetImageStatistics(image,exception);
662       if (channel_statistics == (ChannelStatistics *) NULL)
663         return(MagickFalse);
664       artifact=GetImageArtifact(image,"identify:features");
665       if (artifact != (const char *) NULL)
666         {
667           distance=StringToUnsignedLong(artifact);
668           channel_features=GetImageFeatures(image,distance,exception);
669         }
670       depth=GetImageDepth(image,exception);
671       if (image->depth == depth)
672         (void) FormatLocaleFile(file,"  Depth: %.20g-bit\n",(double)
673           image->depth);
674       else
675         (void) FormatLocaleFile(file,"  Depth: %.20g/%.20g-bit\n",(double)
676           image->depth,(double) depth);
677       (void) FormatLocaleFile(file,"  Channel depth:\n");
678       if (IsImageGray(image,exception) != MagickFalse)
679         colorspace=GRAYColorspace;
680       switch (colorspace)
681       {
682         case RGBColorspace:
683         default:
684         {
685           (void) FormatLocaleFile(file,"    Red: %.20g-bit\n",(double)
686             channel_statistics[RedPixelChannel].depth);
687           (void) FormatLocaleFile(file,"    Green: %.20g-bit\n",(double)
688             channel_statistics[GreenPixelChannel].depth);
689           (void) FormatLocaleFile(file,"    Blue: %.20g-bit\n",(double)
690             channel_statistics[BluePixelChannel].depth);
691           break;
692         }
693         case CMYKColorspace:
694         {
695           (void) FormatLocaleFile(file,"    Cyan: %.20g-bit\n",(double)
696             channel_statistics[CyanPixelChannel].depth);
697           (void) FormatLocaleFile(file,"    Magenta: %.20g-bit\n",(double)
698             channel_statistics[MagentaPixelChannel].depth);
699           (void) FormatLocaleFile(file,"    Yellow: %.20g-bit\n",(double)
700             channel_statistics[YellowPixelChannel].depth);
701           (void) FormatLocaleFile(file,"    Black: %.20g-bit\n",(double)
702             channel_statistics[BlackPixelChannel].depth);
703           break;
704         }
705         case GRAYColorspace:
706         {
707           (void) FormatLocaleFile(file,"    Gray: %.20g-bit\n",(double)
708             channel_statistics[GrayPixelChannel].depth);
709           break;
710         }
711       }
712       if (image->alpha_trait == BlendPixelTrait)
713         (void) FormatLocaleFile(file,"    alpha: %.20g-bit\n",(double)
714           channel_statistics[AlphaPixelChannel].depth);
715       scale=1;
716       if (image->depth <= MAGICKCORE_QUANTUM_DEPTH)
717         scale=QuantumRange/((size_t) QuantumRange >> ((size_t)
718           MAGICKCORE_QUANTUM_DEPTH-image->depth));
719     }
720   if (channel_statistics != (ChannelStatistics *) NULL)
721     {
722       (void) FormatLocaleFile(file,"  Channel statistics:\n");
723       (void) FormatLocaleFile(file,"    Pixels: %.20g\n",
724         channel_statistics[CompositePixelChannel].area);
725       switch (colorspace)
726       {
727         case RGBColorspace:
728         default:
729         {
730           (void) PrintChannelStatistics(file,RedPixelChannel,"Red",1.0/
731             scale,channel_statistics);
732           (void) PrintChannelStatistics(file,GreenPixelChannel,"Green",1.0/
733             scale,channel_statistics);
734           (void) PrintChannelStatistics(file,BluePixelChannel,"Blue",1.0/
735             scale,channel_statistics);
736           break;
737         }
738         case CMYKColorspace:
739         {
740           (void) PrintChannelStatistics(file,CyanPixelChannel,"Cyan",1.0/
741             scale,channel_statistics);
742           (void) PrintChannelStatistics(file,MagentaPixelChannel,"Magenta",1.0/
743             scale,channel_statistics);
744           (void) PrintChannelStatistics(file,YellowPixelChannel,"Yellow",1.0/
745             scale,channel_statistics);
746           (void) PrintChannelStatistics(file,BlackPixelChannel,"Black",1.0/
747             scale,channel_statistics);
748           break;
749         }
750         case GRAYColorspace:
751         {
752           (void) PrintChannelStatistics(file,GrayPixelChannel,"Gray",1.0/
753             scale,channel_statistics);
754           break;
755         }
756       }
757       if (image->alpha_trait == BlendPixelTrait)
758         (void) PrintChannelStatistics(file,AlphaPixelChannel,"Alpha",1.0/
759           scale,channel_statistics);
760       if (colorspace != GRAYColorspace)
761         {
762           (void) FormatLocaleFile(file,"  Image statistics:\n");
763           (void) PrintChannelStatistics(file,(PixelChannel) MaxPixelChannels,
764             "Overall",1.0/scale,channel_statistics);
765         }
766       channel_statistics=(ChannelStatistics *) RelinquishMagickMemory(
767         channel_statistics);
768     }
769   if (channel_features != (ChannelFeatures *) NULL)
770     {
771       (void) FormatLocaleFile(file,"  Channel features (horizontal, vertical, "
772         "left and right diagonals, average):\n");
773       switch (colorspace)
774       {
775         case RGBColorspace:
776         default:
777         {
778           (void) PrintChannelFeatures(file,RedPixelChannel,"Red",
779             channel_features);
780           (void) PrintChannelFeatures(file,GreenPixelChannel,"Green",
781             channel_features);
782           (void) PrintChannelFeatures(file,BluePixelChannel,"Blue",
783             channel_features);
784           break;
785         }
786         case CMYKColorspace:
787         {
788           (void) PrintChannelFeatures(file,CyanPixelChannel,"Cyan",
789             channel_features);
790           (void) PrintChannelFeatures(file,MagentaPixelChannel,"Magenta",
791             channel_features);
792           (void) PrintChannelFeatures(file,YellowPixelChannel,"Yellow",
793             channel_features);
794           (void) PrintChannelFeatures(file,BlackPixelChannel,"Black",
795             channel_features);
796           break;
797         }
798         case GRAYColorspace:
799         {
800           (void) PrintChannelFeatures(file,GrayPixelChannel,"Gray",
801             channel_features);
802           break;
803         }
804       }
805       if (image->alpha_trait == BlendPixelTrait)
806         (void) PrintChannelFeatures(file,AlphaPixelChannel,"Alpha",
807           channel_features);
808       channel_features=(ChannelFeatures *) RelinquishMagickMemory(
809         channel_features);
810     }
811   if (ping == MagickFalse)
812     {
813       if (image->colorspace == CMYKColorspace)
814         (void) FormatLocaleFile(file,"  Total ink density: %.0f%%\n",100.0*
815           GetImageTotalInkDensity(image,exception)/(double) QuantumRange);
816       x=0;
817       if (image->alpha_trait == BlendPixelTrait)
818         {
819           register const Quantum
820             *p;
821
822           p=(const Quantum *) NULL;
823           for (y=0; y < (ssize_t) image->rows; y++)
824           {
825             p=GetVirtualPixels(image,0,y,image->columns,1,exception);
826             if (p == (const Quantum *) NULL)
827               break;
828             for (x=0; x < (ssize_t) image->columns; x++)
829             {
830               if (GetPixelAlpha(image,p) == (Quantum) TransparentAlpha)
831                 break;
832               p+=GetPixelChannels(image);
833             }
834             if (x < (ssize_t) image->columns)
835               break;
836           }
837           if ((x < (ssize_t) image->columns) || (y < (ssize_t) image->rows))
838             {
839               char
840                 tuple[MaxTextExtent];
841
842               PixelInfo
843                 pixel;
844
845               GetPixelInfo(image,&pixel);
846               GetPixelInfoPixel(image,p,&pixel);
847               (void) QueryColorname(image,&pixel,SVGCompliance,tuple,
848                 exception);
849               (void) FormatLocaleFile(file,"  Alpha: %s ",tuple);
850               GetColorTuple(&pixel,MagickTrue,tuple);
851               (void) FormatLocaleFile(file,"  %s\n",tuple);
852             }
853         }
854       if (IsHistogramImage(image,exception) != MagickFalse)
855         {
856           (void) FormatLocaleFile(file,"  Colors: %.20g\n",(double)
857             GetNumberColors(image,(FILE *) NULL,exception));
858           (void) FormatLocaleFile(file,"  Histogram:\n");
859           (void) GetNumberColors(image,file,exception);
860         }
861       else
862         {
863           artifact=GetImageArtifact(image,"identify:unique-colors");
864           if (IfMagickTrue(IsStringTrue(artifact)))
865             (void) FormatLocaleFile(file,"  Colors: %.20g\n",(double)
866               GetNumberColors(image,(FILE *) NULL,exception));
867         }
868     }
869   if (image->storage_class == PseudoClass)
870     {
871       (void) FormatLocaleFile(file,"  Colormap entries: %.20g\n",(double)
872         image->colors);
873       (void) FormatLocaleFile(file,"  Colormap:\n");
874       if (image->colors <= 1024)
875         {
876           char
877             color[MaxTextExtent],
878             hex[MaxTextExtent],
879             tuple[MaxTextExtent];
880
881           PixelInfo
882             pixel;
883
884           register PixelInfo
885             *restrict p;
886
887           GetPixelInfo(image,&pixel);
888           p=image->colormap;
889           for (i=0; i < (ssize_t) image->colors; i++)
890           {
891             pixel=(*p);
892             (void) CopyMagickString(tuple,"(",MaxTextExtent);
893             ConcatenateColorComponent(&pixel,RedPixelChannel,X11Compliance,
894               tuple);
895             (void) ConcatenateMagickString(tuple,",",MaxTextExtent);
896             ConcatenateColorComponent(&pixel,GreenPixelChannel,X11Compliance,
897               tuple);
898             (void) ConcatenateMagickString(tuple,",",MaxTextExtent);
899             ConcatenateColorComponent(&pixel,BluePixelChannel,X11Compliance,
900               tuple);
901             if (pixel.colorspace == CMYKColorspace)
902               {
903                 (void) ConcatenateMagickString(tuple,",",MaxTextExtent);
904                 ConcatenateColorComponent(&pixel,BlackPixelChannel,
905                   X11Compliance,tuple);
906               }
907             if (pixel.alpha_trait == BlendPixelTrait)
908               {
909                 (void) ConcatenateMagickString(tuple,",",MaxTextExtent);
910                 ConcatenateColorComponent(&pixel,AlphaPixelChannel,
911                   X11Compliance,tuple);
912               }
913             (void) ConcatenateMagickString(tuple,")",MaxTextExtent);
914             (void) QueryColorname(image,&pixel,SVGCompliance,color,
915               exception);
916             GetColorTuple(&pixel,MagickTrue,hex);
917             (void) FormatLocaleFile(file,"  %8ld: %s %s %s\n",(long) i,tuple,
918               hex,color);
919             p++;
920           }
921         }
922     }
923   if (image->error.mean_error_per_pixel != 0.0)
924     (void) FormatLocaleFile(file,"  Mean error per pixel: %g\n",
925       image->error.mean_error_per_pixel);
926   if (image->error.normalized_mean_error != 0.0)
927     (void) FormatLocaleFile(file,"  Normalized mean error: %g\n",
928       image->error.normalized_mean_error);
929   if (image->error.normalized_maximum_error != 0.0)
930     (void) FormatLocaleFile(file,"  Normalized maximum error: %g\n",
931       image->error.normalized_maximum_error);
932   (void) FormatLocaleFile(file,"  Rendering intent: %s\n",
933     CommandOptionToMnemonic(MagickIntentOptions,(ssize_t)
934     image->rendering_intent));
935   if (image->gamma != 0.0)
936     (void) FormatLocaleFile(file,"  Gamma: %g\n",image->gamma);
937   if ((image->chromaticity.red_primary.x != 0.0) ||
938       (image->chromaticity.green_primary.x != 0.0) ||
939       (image->chromaticity.blue_primary.x != 0.0) ||
940       (image->chromaticity.white_point.x != 0.0))
941     {
942       /*
943         Display image chromaticity.
944       */
945       (void) FormatLocaleFile(file,"  Chromaticity:\n");
946       (void) FormatLocaleFile(file,"    red primary: (%g,%g)\n",
947         image->chromaticity.red_primary.x,image->chromaticity.red_primary.y);
948       (void) FormatLocaleFile(file,"    green primary: (%g,%g)\n",
949         image->chromaticity.green_primary.x,
950         image->chromaticity.green_primary.y);
951       (void) FormatLocaleFile(file,"    blue primary: (%g,%g)\n",
952         image->chromaticity.blue_primary.x,image->chromaticity.blue_primary.y);
953       (void) FormatLocaleFile(file,"    white point: (%g,%g)\n",
954         image->chromaticity.white_point.x,image->chromaticity.white_point.y);
955     }
956   if ((image->extract_info.width*image->extract_info.height) != 0)
957     (void) FormatLocaleFile(file,"  Tile geometry: %.20gx%.20g%+.20g%+.20g\n",
958       (double) image->extract_info.width,(double) image->extract_info.height,
959       (double) image->extract_info.x,(double) image->extract_info.y);
960   (void) QueryColorname(image,&image->background_color,SVGCompliance,color,
961     exception);
962   (void) FormatLocaleFile(file,"  Background color: %s\n",color);
963   (void) QueryColorname(image,&image->border_color,SVGCompliance,color,
964     exception);
965   (void) FormatLocaleFile(file,"  Border color: %s\n",color);
966   (void) QueryColorname(image,&image->matte_color,SVGCompliance,color,
967     exception);
968   (void) FormatLocaleFile(file,"  Matte color: %s\n",color);
969   (void) QueryColorname(image,&image->transparent_color,SVGCompliance,color,
970     exception);
971   (void) FormatLocaleFile(file,"  Transparent color: %s\n",color);
972   (void) FormatLocaleFile(file,"  Interlace: %s\n",CommandOptionToMnemonic(
973     MagickInterlaceOptions,(ssize_t) image->interlace));
974   (void) FormatLocaleFile(file,"  Intensity: %s\n",CommandOptionToMnemonic(
975     MagickPixelIntensityOptions,(ssize_t) image->intensity));
976   (void) FormatLocaleFile(file,"  Compose: %s\n",CommandOptionToMnemonic(
977     MagickComposeOptions,(ssize_t) image->compose));
978   if ((image->page.width != 0) || (image->page.height != 0) ||
979       (image->page.x != 0) || (image->page.y != 0))
980     (void) FormatLocaleFile(file,"  Page geometry: %.20gx%.20g%+.20g%+.20g\n",
981       (double) image->page.width,(double) image->page.height,(double)
982       image->page.x,(double) image->page.y);
983   if ((image->page.x != 0) || (image->page.y != 0))
984     (void) FormatLocaleFile(file,"  Origin geometry: %+.20g%+.20g\n",(double)
985       image->page.x,(double) image->page.y);
986   (void) FormatLocaleFile(file,"  Dispose: %s\n",CommandOptionToMnemonic(
987     MagickDisposeOptions,(ssize_t) image->dispose));
988   if (image->delay != 0)
989     (void) FormatLocaleFile(file,"  Delay: %.20gx%.20g\n",(double) image->delay,
990       (double) image->ticks_per_second);
991   if (image->iterations != 1)
992     (void) FormatLocaleFile(file,"  Iterations: %.20g\n",(double)
993       image->iterations);
994   if ((image->next != (Image *) NULL) || (image->previous != (Image *) NULL))
995     (void) FormatLocaleFile(file,"  Scene: %.20g of %.20g\n",(double)
996       image->scene,(double) GetImageListLength(image));
997   else
998     if (image->scene != 0)
999       (void) FormatLocaleFile(file,"  Scene: %.20g\n",(double) image->scene);
1000   (void) FormatLocaleFile(file,"  Compression: %s\n",CommandOptionToMnemonic(
1001     MagickCompressOptions,(ssize_t) image->compression));
1002   if (image->quality != UndefinedCompressionQuality)
1003     (void) FormatLocaleFile(file,"  Quality: %.20g\n",(double) image->quality);
1004   (void) FormatLocaleFile(file,"  Orientation: %s\n",CommandOptionToMnemonic(
1005     MagickOrientationOptions,(ssize_t) image->orientation));
1006   if (image->montage != (char *) NULL)
1007     (void) FormatLocaleFile(file,"  Montage: %s\n",image->montage);
1008   if (image->directory != (char *) NULL)
1009     {
1010       Image
1011         *tile;
1012
1013       ImageInfo
1014         *image_info;
1015
1016       register char
1017         *p,
1018         *q;
1019
1020       WarningHandler
1021         handler;
1022
1023       /*
1024         Display visual image directory.
1025       */
1026       image_info=AcquireImageInfo();
1027       (void) CloneString(&image_info->size,"64x64");
1028       (void) FormatLocaleFile(file,"  Directory:\n");
1029       for (p=image->directory; *p != '\0'; p++)
1030       {
1031         q=p;
1032         while ((*q != '\n') && (*q != '\0'))
1033           q++;
1034         (void) CopyMagickString(image_info->filename,p,(size_t) (q-p+1));
1035         p=q;
1036         (void) FormatLocaleFile(file,"    %s",image_info->filename);
1037         handler=SetWarningHandler((WarningHandler) NULL);
1038         tile=ReadImage(image_info,exception);
1039         (void) SetWarningHandler(handler);
1040         if (tile == (Image *) NULL)
1041           {
1042             (void) FormatLocaleFile(file,"\n");
1043             continue;
1044           }
1045         (void) FormatLocaleFile(file," %.20gx%.20g %s\n",(double)
1046           tile->magick_columns,(double) tile->magick_rows,tile->magick);
1047         (void) SignatureImage(tile,exception);
1048         ResetImagePropertyIterator(tile);
1049         property=GetNextImageProperty(tile);
1050         while (property != (const char *) NULL)
1051         {
1052           (void) FormatLocaleFile(file,"  %s:\n",property);
1053           value=GetImageProperty(tile,property,exception);
1054           if (value != (const char *) NULL)
1055             (void) FormatLocaleFile(file,"%s\n",value);
1056           property=GetNextImageProperty(tile);
1057         }
1058         tile=DestroyImage(tile);
1059       }
1060       image_info=DestroyImageInfo(image_info);
1061     }
1062   (void) GetImageProperty(image,"exif:*",exception);
1063   ResetImagePropertyIterator(image);
1064   property=GetNextImageProperty(image);
1065   if (property != (const char *) NULL)
1066     {
1067       /*
1068         Display image properties.
1069       */
1070       (void) FormatLocaleFile(file,"  Properties:\n");
1071       while (property != (const char *) NULL)
1072       {
1073         (void) FormatLocaleFile(file,"    %s: ",property);
1074         value=GetImageProperty(image,property,exception);
1075         if (value != (const char *) NULL)
1076           (void) FormatLocaleFile(file,"%s\n",value);
1077         property=GetNextImageProperty(image);
1078       }
1079     }
1080   (void) FormatLocaleString(key,MaxTextExtent,"8BIM:1999,2998:#1");
1081   value=GetImageProperty(image,key,exception);
1082   if (value != (const char *) NULL)
1083     {
1084       /*
1085         Display clipping path.
1086       */
1087       (void) FormatLocaleFile(file,"  Clipping path: ");
1088       if (strlen(value) > 80)
1089         (void) fputc('\n',file);
1090       (void) FormatLocaleFile(file,"%s\n",value);
1091     }
1092   ResetImageProfileIterator(image);
1093   name=GetNextImageProfile(image);
1094   if (name != (char *) NULL)
1095     {
1096       const StringInfo
1097         *profile;
1098
1099       /*
1100         Identify image profiles.
1101       */
1102       (void) FormatLocaleFile(file,"  Profiles:\n");
1103       while (name != (char *) NULL)
1104       {
1105         profile=GetImageProfile(image,name);
1106         if (profile == (StringInfo *) NULL)
1107           continue;
1108         (void) FormatLocaleFile(file,"    Profile-%s: %.20g bytes\n",name,
1109           (double) GetStringInfoLength(profile));
1110 #if defined(MAGICKCORE_LCMS_DELEGATE)
1111         if ((LocaleCompare(name,"icc") == 0) ||
1112             (LocaleCompare(name,"icm") == 0))
1113           {
1114             cmsHPROFILE
1115               icc_profile;
1116
1117             icc_profile=cmsOpenProfileFromMem(GetStringInfoDatum(profile),
1118               (cmsUInt32Number) GetStringInfoLength(profile));
1119             if (icc_profile != (cmsHPROFILE *) NULL)
1120               {
1121 #if defined(LCMS_VERSION) && (LCMS_VERSION < 2000)
1122                 const char
1123                   *name;
1124
1125                 name=cmsTakeProductName(icc_profile);
1126                 if (name != (const char *) NULL)
1127                   (void) FormatLocaleFile(file,"      %s\n",name);
1128 #else
1129                 char
1130                   info[MaxTextExtent];
1131
1132                 (void) cmsGetProfileInfoASCII(icc_profile,cmsInfoDescription,
1133                   "en","US",info,MaxTextExtent);
1134                 (void) FormatLocaleFile(file,"      Description: %s\n",info);
1135                 (void) cmsGetProfileInfoASCII(icc_profile,cmsInfoManufacturer,
1136                   "en","US",info,MaxTextExtent);
1137                 (void) FormatLocaleFile(file,"      Manufacturer: %s\n",info);
1138                 (void) cmsGetProfileInfoASCII(icc_profile,cmsInfoModel,"en",
1139                   "US",info,MaxTextExtent);
1140                 (void) FormatLocaleFile(file,"      Model: %s\n",info);
1141                 (void) cmsGetProfileInfoASCII(icc_profile,cmsInfoCopyright,
1142                   "en","US",info,MaxTextExtent);
1143                 (void) FormatLocaleFile(file,"      Copyright: %s\n",info);
1144 #endif
1145                 (void) cmsCloseProfile(icc_profile);
1146               }
1147           }
1148 #endif
1149         if (LocaleCompare(name,"iptc") == 0)
1150           {
1151             char
1152               *attribute,
1153               **attribute_list;
1154
1155             const char
1156               *tag;
1157
1158             long
1159               dataset,
1160               record,
1161               sentinel;
1162
1163             register ssize_t
1164               j;
1165
1166             size_t
1167               length,
1168               profile_length;
1169
1170             profile_length=GetStringInfoLength(profile);
1171             for (i=0; i < (ssize_t) profile_length; i+=(ssize_t) length)
1172             {
1173               length=1;
1174               sentinel=GetStringInfoDatum(profile)[i++];
1175               if (sentinel != 0x1c)
1176                 continue;
1177               dataset=GetStringInfoDatum(profile)[i++];
1178               record=GetStringInfoDatum(profile)[i++];
1179               switch (record)
1180               {
1181                 case 5: tag="Image Name"; break;
1182                 case 7: tag="Edit Status"; break;
1183                 case 10: tag="Priority"; break;
1184                 case 15: tag="Category"; break;
1185                 case 20: tag="Supplemental Category"; break;
1186                 case 22: tag="Fixture Identifier"; break;
1187                 case 25: tag="Keyword"; break;
1188                 case 30: tag="Release Date"; break;
1189                 case 35: tag="Release Time"; break;
1190                 case 40: tag="Special Instructions"; break;
1191                 case 45: tag="Reference Service"; break;
1192                 case 47: tag="Reference Date"; break;
1193                 case 50: tag="Reference Number"; break;
1194                 case 55: tag="Created Date"; break;
1195                 case 60: tag="Created Time"; break;
1196                 case 65: tag="Originating Program"; break;
1197                 case 70: tag="Program Version"; break;
1198                 case 75: tag="Object Cycle"; break;
1199                 case 80: tag="Byline"; break;
1200                 case 85: tag="Byline Title"; break;
1201                 case 90: tag="City"; break;
1202                 case 95: tag="Province State"; break;
1203                 case 100: tag="Country Code"; break;
1204                 case 101: tag="Country"; break;
1205                 case 103: tag="Original Transmission Reference"; break;
1206                 case 105: tag="Headline"; break;
1207                 case 110: tag="Credit"; break;
1208                 case 115: tag="Src"; break;
1209                 case 116: tag="Copyright String"; break;
1210                 case 120: tag="Caption"; break;
1211                 case 121: tag="Local Caption"; break;
1212                 case 122: tag="Caption Writer"; break;
1213                 case 200: tag="Custom Field 1"; break;
1214                 case 201: tag="Custom Field 2"; break;
1215                 case 202: tag="Custom Field 3"; break;
1216                 case 203: tag="Custom Field 4"; break;
1217                 case 204: tag="Custom Field 5"; break;
1218                 case 205: tag="Custom Field 6"; break;
1219                 case 206: tag="Custom Field 7"; break;
1220                 case 207: tag="Custom Field 8"; break;
1221                 case 208: tag="Custom Field 9"; break;
1222                 case 209: tag="Custom Field 10"; break;
1223                 case 210: tag="Custom Field 11"; break;
1224                 case 211: tag="Custom Field 12"; break;
1225                 case 212: tag="Custom Field 13"; break;
1226                 case 213: tag="Custom Field 14"; break;
1227                 case 214: tag="Custom Field 15"; break;
1228                 case 215: tag="Custom Field 16"; break;
1229                 case 216: tag="Custom Field 17"; break;
1230                 case 217: tag="Custom Field 18"; break;
1231                 case 218: tag="Custom Field 19"; break;
1232                 case 219: tag="Custom Field 20"; break;
1233                 default: tag="unknown"; break;
1234               }
1235               (void) FormatLocaleFile(file,"      %s[%.20g,%.20g]: ",tag,
1236                 (double) dataset,(double) record);
1237               length=(size_t) (GetStringInfoDatum(profile)[i++] << 8);
1238               length|=GetStringInfoDatum(profile)[i++];
1239               attribute=(char *) NULL;
1240               if (~length >= (MaxTextExtent-1))
1241                 attribute=(char *) AcquireQuantumMemory(length+MaxTextExtent,
1242                   sizeof(*attribute));
1243               if (attribute != (char *) NULL)
1244                 {
1245                   (void) CopyMagickString(attribute,(char *)
1246                     GetStringInfoDatum(profile)+i,length+1);
1247                   attribute_list=StringToList(attribute);
1248                   if (attribute_list != (char **) NULL)
1249                     {
1250                       for (j=0; attribute_list[j] != (char *) NULL; j++)
1251                       {
1252                         (void) fputs(attribute_list[j],file);
1253                         (void) fputs("\n",file);
1254                         attribute_list[j]=(char *) RelinquishMagickMemory(
1255                           attribute_list[j]);
1256                       }
1257                       attribute_list=(char **) RelinquishMagickMemory(
1258                         attribute_list);
1259                     }
1260                   attribute=DestroyString(attribute);
1261                 }
1262             }
1263           }
1264         if (image->debug != MagickFalse)
1265           PrintStringInfo(file,name,profile);
1266         name=GetNextImageProfile(image);
1267       }
1268     }
1269   ResetImageArtifactIterator(image);
1270   artifact=GetNextImageArtifact(image);
1271   if (artifact != (const char *) NULL)
1272     {
1273       /*
1274         Display image artifacts.
1275       */
1276       (void) FormatLocaleFile(file,"  Artifacts:\n");
1277       while (artifact != (const char *) NULL)
1278       {
1279         (void) FormatLocaleFile(file,"    %s: ",artifact);
1280         value=GetImageArtifact(image,artifact);
1281         if (value != (const char *) NULL)
1282           (void) FormatLocaleFile(file,"%s\n",value);
1283         artifact=GetNextImageArtifact(image);
1284       }
1285     }
1286   ResetImageRegistryIterator();
1287   registry=GetNextImageRegistry();
1288   if (registry != (const char *) NULL)
1289     {
1290       /*
1291         Display image registry.
1292       */
1293       (void) FormatLocaleFile(file,"  Registry:\n");
1294       while (registry != (const char *) NULL)
1295       {
1296         (void) FormatLocaleFile(file,"    %s: ",registry);
1297         value=(const char *) GetImageRegistry(StringRegistryType,registry,
1298           exception);
1299         if (value != (const char *) NULL)
1300           (void) FormatLocaleFile(file,"%s\n",value);
1301         registry=GetNextImageRegistry();
1302       }
1303     }
1304   (void) FormatLocaleFile(file,"  Tainted: %s\n",CommandOptionToMnemonic(
1305     MagickBooleanOptions,(ssize_t) image->taint));
1306   (void) FormatMagickSize(GetBlobSize(image),MagickFalse,format);
1307   (void) FormatLocaleFile(file,"  Filesize: %s\n",format);
1308   (void) FormatMagickSize((MagickSizeType) image->columns*image->rows,
1309     MagickFalse,format);
1310   if (strlen(format) > 1)
1311     format[strlen(format)-1]='\0';
1312   (void) FormatLocaleFile(file,"  Number pixels: %s\n",format);
1313   (void) FormatMagickSize((MagickSizeType) ((double) image->columns*image->rows/
1314     elapsed_time+0.5),MagickFalse,format);
1315   (void) FormatLocaleFile(file,"  Pixels per second: %s\n",format);
1316   (void) FormatLocaleFile(file,"  User time: %0.3fu\n",user_time);
1317   (void) FormatLocaleFile(file,"  Elapsed time: %lu:%02lu.%03lu\n",
1318     (unsigned long) (elapsed_time/60.0),(unsigned long) ceil(fmod(elapsed_time,
1319     60.0)),(unsigned long) (1000.0*(elapsed_time-floor(elapsed_time))));
1320   (void) FormatLocaleFile(file,"  Version: %s\n",GetMagickVersion((size_t *)
1321     NULL));
1322   (void) fflush(file);
1323   return(ferror(file) != 0 ? MagickFalse : MagickTrue);
1324 }