MagickCore  6.9.13-51
Convert, Edit, Or Compose Bitmap Images
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 % Cristy %
17 % September 1994 %
18 % %
19 % %
20 % Copyright 1999 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 % https://imagemagick.org/license/ %
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 
42 
43 /*
44  Include declarations.
45 */
46 #include "magick/studio.h"
47 #include "magick/annotate.h"
48 #include "magick/artifact.h"
49 #include "magick/attribute.h"
50 #include "magick/blob.h"
51 #include "magick/blob-private.h"
52 #include "magick/cache.h"
53 #include "magick/client.h"
54 #include "magick/coder.h"
55 #include "magick/color.h"
56 #include "magick/configure.h"
57 #include "magick/constitute.h"
58 #include "magick/constitute-private.h"
59 #include "magick/decorate.h"
60 #include "magick/delegate.h"
61 #include "magick/draw.h"
62 #include "magick/effect.h"
63 #include "magick/exception.h"
64 #include "magick/exception-private.h"
65 #include "magick/feature.h"
66 #include "magick/gem.h"
67 #include "magick/geometry.h"
68 #include "magick/histogram.h"
69 #include "magick/identify.h"
70 #include "magick/image.h"
71 #include "magick/image-private.h"
72 #include "magick/list.h"
73 #include "magick/locale_.h"
74 #include "magick/log.h"
75 #include "magick/magic.h"
76 #include "magick/magick.h"
77 #include "magick/memory_.h"
78 #include "magick/module.h"
79 #include "magick/monitor.h"
80 #include "magick/montage.h"
81 #include "magick/option.h"
82 #include "magick/pixel-private.h"
83 #include "magick/prepress.h"
84 #include "magick/profile.h"
85 #include "magick/property.h"
86 #include "magick/quantize.h"
87 #include "magick/quantum.h"
88 #include "magick/random_.h"
89 #include "magick/registry.h"
90 #include "magick/resize.h"
91 #include "magick/resource_.h"
92 #include "magick/signature.h"
93 #include "magick/statistic.h"
94 #include "magick/string_.h"
95 #include "magick/string-private.h"
96 #include "magick/timer.h"
97 #include "magick/timer-private.h"
98 #include "magick/token.h"
99 #include "magick/utility.h"
100 #include "magick/version.h"
101 
102 /*
103 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
104 % %
105 % %
106 % %
107 % I d e n t i f y I m a g e %
108 % %
109 % %
110 % %
111 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
112 %
113 % IdentifyImage() identifies an image by printing its attributes to the file.
114 % Attributes include the image width, height, size, and others.
115 %
116 % The format of the IdentifyImage method is:
117 %
118 % MagickBooleanType IdentifyImage(Image *image,FILE *file,
119 % const MagickBooleanType verbose)
120 %
121 % A description of each parameter follows:
122 %
123 % o image: the image.
124 %
125 % o file: the file, typically stdout.
126 %
127 % o verbose: A value other than zero prints more detailed information
128 % about the image.
129 %
130 */
131 
132 static ChannelStatistics *GetLocationStatistics(const Image *image,
133  const StatisticType type,ExceptionInfo *exception)
134 {
136  *channel_statistics;
137 
138  ssize_t
139  i;
140 
141  size_t
142  length;
143 
144  ssize_t
145  y;
146 
147  assert(image != (Image *) NULL);
148  assert(image->signature == MagickCoreSignature);
149  if (IsEventLogging() != MagickFalse)
150  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
151  length=CompositeChannels+1UL;
152  channel_statistics=(ChannelStatistics *) AcquireQuantumMemory(length,
153  sizeof(*channel_statistics));
154  if (channel_statistics == (ChannelStatistics *) NULL)
155  ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed");
156  (void) memset(channel_statistics,0,length*
157  sizeof(*channel_statistics));
158  for (i=0; i <= (ssize_t) CompositeChannels; i++)
159  {
160  switch (type)
161  {
162  case MaximumStatistic:
163  default:
164  {
165  channel_statistics[i].maxima=(-MagickMaximumValue);
166  break;
167  }
168  case MinimumStatistic:
169  {
170  channel_statistics[i].minima=MagickMaximumValue;
171  break;
172  }
173  }
174  }
175  for (y=0; y < (ssize_t) image->rows; y++)
176  {
177  const IndexPacket
178  *magick_restrict indexes;
179 
180  const PixelPacket
181  *magick_restrict p;
182 
183  ssize_t
184  x;
185 
186  p=GetVirtualPixels(image,0,y,image->columns,1,exception);
187  if (p == (const PixelPacket *) NULL)
188  break;
189  indexes=GetVirtualIndexQueue(image);
190  for (x=0; x < (ssize_t) image->columns; x++)
191  {
192  switch (type)
193  {
194  case MaximumStatistic:
195  default:
196  {
197  if ((double) GetPixelRed(p) > channel_statistics[RedChannel].maxima)
198  channel_statistics[RedChannel].maxima=(double) GetPixelRed(p);
199  if ((double) GetPixelGreen(p) > channel_statistics[GreenChannel].maxima)
200  channel_statistics[GreenChannel].maxima=(double) GetPixelGreen(p);
201  if ((double) GetPixelBlue(p) > channel_statistics[BlueChannel].maxima)
202  channel_statistics[BlueChannel].maxima=(double) GetPixelBlue(p);
203  if ((image->matte != MagickFalse) &&
204  ((double) GetPixelOpacity(p) > channel_statistics[OpacityChannel].maxima))
205  channel_statistics[OpacityChannel].maxima=(double)
206  GetPixelOpacity(p);
207  if ((image->colorspace == CMYKColorspace) &&
208  ((double) GetPixelIndex(indexes+x) > channel_statistics[BlackChannel].maxima))
209  channel_statistics[BlackChannel].maxima=(double)
210  GetPixelIndex(indexes+x);
211  break;
212  }
213  case MinimumStatistic:
214  {
215  if ((double) GetPixelRed(p) < channel_statistics[RedChannel].minima)
216  channel_statistics[RedChannel].minima=(double) GetPixelRed(p);
217  if ((double) GetPixelGreen(p) < channel_statistics[GreenChannel].minima)
218  channel_statistics[GreenChannel].minima=(double) GetPixelGreen(p);
219  if ((double) GetPixelBlue(p) < channel_statistics[BlueChannel].minima)
220  channel_statistics[BlueChannel].minima=(double) GetPixelBlue(p);
221  if ((image->matte != MagickFalse) &&
222  ((double) GetPixelOpacity(p) < channel_statistics[OpacityChannel].minima))
223  channel_statistics[OpacityChannel].minima=(double)
224  GetPixelOpacity(p);
225  if ((image->colorspace == CMYKColorspace) &&
226  ((double) GetPixelIndex(indexes+x) < channel_statistics[BlackChannel].minima))
227  channel_statistics[BlackChannel].minima=(double)
228  GetPixelIndex(indexes+x);
229  break;
230  }
231  }
232  p++;
233  }
234  }
235  return(channel_statistics);
236 }
237 
238 static ssize_t PrintChannelFeatures(FILE *file,const ChannelType channel,
239  const char *name,const ChannelFeatures *channel_features)
240 {
241 #define PrintFeature(feature) \
242  GetMagickPrecision(),(feature)[0], \
243  GetMagickPrecision(),(feature)[1], \
244  GetMagickPrecision(),(feature)[2], \
245  GetMagickPrecision(),(feature)[3], \
246  GetMagickPrecision(),((feature)[0]+(feature)[1]+(feature)[2]+(feature)[3])/4.0 \
247 
248 #define FeaturesFormat " %s:\n" \
249  " Angular Second Moment:\n" \
250  " %.*g, %.*g, %.*g, %.*g, %.*g\n" \
251  " Contrast:\n" \
252  " %.*g, %.*g, %.*g, %.*g, %.*g\n" \
253  " Correlation:\n" \
254  " %.*g, %.*g, %.*g, %.*g, %.*g\n" \
255  " Sum of Squares Variance:\n" \
256  " %.*g, %.*g, %.*g, %.*g, %.*g\n" \
257  " Inverse Difference Moment:\n" \
258  " %.*g, %.*g, %.*g, %.*g, %.*g\n" \
259  " Sum Average:\n" \
260  " %.*g, %.*g, %.*g, %.*g, %.*g\n" \
261  " Sum Variance:\n" \
262  " %.*g, %.*g, %.*g, %.*g, %.*g\n" \
263  " Sum Entropy:\n" \
264  " %.*g, %.*g, %.*g, %.*g, %.*g\n" \
265  " Entropy:\n" \
266  " %.*g, %.*g, %.*g, %.*g, %.*g\n" \
267  " Difference Variance:\n" \
268  " %.*g, %.*g, %.*g, %.*g, %.*g\n" \
269  " Difference Entropy:\n" \
270  " %.*g, %.*g, %.*g, %.*g, %.*g\n" \
271  " Information Measure of Correlation 1:\n" \
272  " %.*g, %.*g, %.*g, %.*g, %.*g\n" \
273  " Information Measure of Correlation 2:\n" \
274  " %.*g, %.*g, %.*g, %.*g, %.*g\n" \
275  " Maximum Correlation Coefficient:\n" \
276  " %.*g, %.*g, %.*g, %.*g, %.*g\n"
277 
278  ssize_t
279  n;
280 
281  n=FormatLocaleFile(file,FeaturesFormat,name,
282  PrintFeature(channel_features[channel].angular_second_moment),
283  PrintFeature(channel_features[channel].contrast),
284  PrintFeature(channel_features[channel].correlation),
285  PrintFeature(channel_features[channel].variance_sum_of_squares),
286  PrintFeature(channel_features[channel].inverse_difference_moment),
287  PrintFeature(channel_features[channel].sum_average),
288  PrintFeature(channel_features[channel].sum_variance),
289  PrintFeature(channel_features[channel].sum_entropy),
290  PrintFeature(channel_features[channel].entropy),
291  PrintFeature(channel_features[channel].difference_variance),
292  PrintFeature(channel_features[channel].difference_entropy),
293  PrintFeature(channel_features[channel].measure_of_correlation_1),
294  PrintFeature(channel_features[channel].measure_of_correlation_2),
295  PrintFeature(channel_features[channel].maximum_correlation_coefficient));
296  return(n);
297 }
298 
299 static ssize_t PrintChannelLocations(FILE *file,const Image *image,
300  const ChannelType channel,const char *name,const StatisticType type,
301  const size_t max_locations,const ChannelStatistics *channel_statistics)
302 {
303  double
304  target;
305 
307  *exception;
308 
309  ssize_t
310  n,
311  y;
312 
313  switch (type)
314  {
315  case MaximumStatistic:
316  default:
317  {
318  target=channel_statistics[channel].maxima;
319  break;
320  }
321  case MeanStatistic:
322  {
323  target=channel_statistics[channel].mean;
324  break;
325  }
326  case MinimumStatistic:
327  {
328  target=channel_statistics[channel].minima;
329  break;
330  }
331  }
332  (void) FormatLocaleFile(file," %s: %.*g (%.*g)",name,GetMagickPrecision(),
333  target,GetMagickPrecision(),QuantumScale*target);
334  exception=AcquireExceptionInfo();
335  n=0;
336  for (y=0; y < (ssize_t) image->rows; y++)
337  {
338  const PixelPacket
339  *p;
340 
341  ssize_t
342  x;
343 
344  p=GetVirtualPixels(image,0,y,image->columns,1,exception);
345  if (p == (const PixelPacket *) NULL)
346  break;
347  for (x=0; x < (ssize_t) image->columns; x++)
348  {
349  MagickBooleanType
350  match;
351 
352  match=MagickFalse;
353  switch (channel)
354  {
355  case RedChannel:
356  {
357  match=fabs((double) p->red-target) < MagickEpsilon ? MagickTrue :
358  MagickFalse;
359  break;
360  }
361  case GreenChannel:
362  {
363  match=fabs((double) p->green-target) < MagickEpsilon ? MagickTrue :
364  MagickFalse;
365  break;
366  }
367  case BlueChannel:
368  {
369  match=fabs((double) p->blue-target) < MagickEpsilon ? MagickTrue :
370  MagickFalse;
371  break;
372  }
373  case AlphaChannel:
374  {
375  match=fabs((double) p->opacity-target) < MagickEpsilon ? MagickTrue :
376  MagickFalse;
377  break;
378  }
379  default:
380  break;
381  }
382  if (match != MagickFalse)
383  {
384  if ((max_locations != 0) && (n >= (ssize_t) max_locations))
385  break;
386  (void) FormatLocaleFile(file," %.20g,%.20g",(double) x,(double) y);
387  n++;
388  }
389  p++;
390  }
391  if (x < (ssize_t) image->columns)
392  break;
393  }
394  (void) FormatLocaleFile(file,"\n");
395  return(n);
396 }
397 
398 static ssize_t PrintChannelMoments(FILE *file,const ChannelType channel,
399  const char *name,const double scale,const ChannelMoments *channel_moments)
400 {
401  double
402  powers[MaximumNumberOfImageMoments] =
403  { 1.0, 2.0, 3.0, 3.0, 6.0, 4.0, 6.0, 4.0 };
404 
405  ssize_t
406  i;
407 
408  ssize_t
409  n;
410 
411  n=FormatLocaleFile(file," %s:\n",name);
412  n+=FormatLocaleFile(file," Centroid: %.*g,%.*g\n",
413  GetMagickPrecision(),channel_moments[channel].centroid.x,
414  GetMagickPrecision(),channel_moments[channel].centroid.y);
415  n+=FormatLocaleFile(file," Ellipse Semi-Major/Minor axis: %.*g,%.*g\n",
416  GetMagickPrecision(),channel_moments[channel].ellipse_axis.x,
417  GetMagickPrecision(),channel_moments[channel].ellipse_axis.y);
418  n+=FormatLocaleFile(file," Ellipse angle: %.*g\n",
419  GetMagickPrecision(),channel_moments[channel].ellipse_angle);
420  n+=FormatLocaleFile(file," Ellipse eccentricity: %.*g\n",
421  GetMagickPrecision(),channel_moments[channel].ellipse_eccentricity);
422  n+=FormatLocaleFile(file," Ellipse intensity: %.*g (%.*g)\n",
423  GetMagickPrecision(),pow(scale,powers[0])*
424  channel_moments[channel].ellipse_intensity,GetMagickPrecision(),
425  channel_moments[channel].ellipse_intensity);
426  for (i=0; i < MaximumNumberOfImageMoments; i++)
427  n+=FormatLocaleFile(file," I%.20g: %.*g (%.*g)\n",i+1.0,
428  GetMagickPrecision(),channel_moments[channel].I[i]/pow(scale,powers[i]),
429  GetMagickPrecision(),channel_moments[channel].I[i]);
430  return(n);
431 }
432 
433 static ssize_t PrintChannelPerceptualHash(FILE *file,const ChannelType channel,
434  const char *name,const ChannelPerceptualHash *channel_phash)
435 {
436  ssize_t
437  i;
438 
439  ssize_t
440  n;
441 
442  n=FormatLocaleFile(file," %s:\n",name);
443  for (i=0; i < MaximumNumberOfPerceptualHashes; i++)
444  n+=FormatLocaleFile(file," PH%.20g: %.*g, %.*g\n",i+1.0,
445  GetMagickPrecision(),channel_phash[channel].P[i],
446  GetMagickPrecision(),channel_phash[channel].Q[i]);
447  return(n);
448 }
449 
450 static ssize_t PrintChannelStatistics(FILE *file,const ChannelType channel,
451  const char *name,const double scale,
452  const ChannelStatistics *channel_statistics)
453 {
454 #define StatisticsFormat " %s:\n min: %.*g (%.*g)\n " \
455  "max: %.*g (%.*g)\n mean: %.*g (%.*g)\n " \
456  "standard deviation: %.*g (%.*g)\n kurtosis: %.*g\n " \
457  "skewness: %.*g\n entropy: %.*g\n"
458 
459  ssize_t
460  n;
461 
462  n=FormatLocaleFile(file,StatisticsFormat,name,GetMagickPrecision(),
463  (double) ClampToQuantum((MagickRealType) (scale*
464  channel_statistics[channel].minima)),GetMagickPrecision(),
465  channel_statistics[channel].minima/(double) QuantumRange,
466  GetMagickPrecision(),(double) ClampToQuantum((MagickRealType) (scale*
467  channel_statistics[channel].maxima)),GetMagickPrecision(),
468  channel_statistics[channel].maxima/(double) QuantumRange,
469  GetMagickPrecision(),scale*channel_statistics[channel].mean,
470  GetMagickPrecision(),channel_statistics[channel].mean/(double) QuantumRange,
471  GetMagickPrecision(),scale*channel_statistics[channel].standard_deviation,
472  GetMagickPrecision(),channel_statistics[channel].standard_deviation/
473  (double) QuantumRange,GetMagickPrecision(),
474  channel_statistics[channel].kurtosis,GetMagickPrecision(),
475  channel_statistics[channel].skewness,GetMagickPrecision(),
476  channel_statistics[channel].entropy);
477  return(n);
478 }
479 
480 MagickExport MagickBooleanType IdentifyImage(Image *image,FILE *file,
481  const MagickBooleanType verbose)
482 {
483  char
484  color[MaxTextExtent],
485  format[MaxTextExtent],
486  key[MaxTextExtent];
487 
489  *channel_features;
490 
492  *channel_moments;
493 
495  *channel_phash;
496 
498  *channel_statistics;
499 
500  ColorspaceType
501  colorspace;
502 
503  const char
504  *artifact,
505  *locate,
506  *name,
507  *property,
508  *registry,
509  *value;
510 
511  const MagickInfo
512  *magick_info;
513 
514  const PixelPacket
515  *pixels;
516 
517  double
518  elapsed_time,
519  scale,
520  user_time;
521 
523  *exception;
524 
525  ImageType
526  type;
527 
528  int
529  expired;
530 
531  MagickBooleanType
532  ping;
533 
534  size_t
535  depth,
536  distance;
537 
538  ssize_t
539  i,
540  x,
541  y;
542 
543  struct stat
544  properties;
545 
546  assert(image != (Image *) NULL);
547  assert(image->signature == MagickCoreSignature);
548  if (IsEventLogging() != MagickFalse)
549  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
550  if (file == (FILE *) NULL)
551  file=stdout;
552  exception=AcquireExceptionInfo();
553  colorspace=image->colorspace;
554  locate=GetImageArtifact(image,"identify:locate");
555  if (locate != (const char *) NULL)
556  {
557  const char
558  *limit;
559 
560  size_t
561  max_locations;
562 
563  StatisticType
564  statistic_type;
565 
566  /*
567  Display minimum, maximum, or mean pixel locations.
568  */
569  statistic_type=(StatisticType) ParseCommandOption(MagickStatisticOptions,
570  MagickFalse,locate);
571  limit=GetImageArtifact(image,"identify:limit");
572  max_locations=0;
573  if (limit != (const char *) NULL)
574  max_locations=StringToUnsignedLong(limit);
575  channel_statistics=GetLocationStatistics(image,statistic_type,exception);
576  if (channel_statistics == (ChannelStatistics *) NULL)
577  return(MagickFalse);
578  (void) FormatLocaleFile(file," Channel %s locations:\n",locate);
579  switch (colorspace)
580  {
581  case RGBColorspace:
582  default:
583  {
584  (void) PrintChannelLocations(file,image,RedChannel,"Red",
585  statistic_type,max_locations,channel_statistics);
586  (void) PrintChannelLocations(file,image,GreenChannel,"Green",
587  statistic_type,max_locations,channel_statistics);
588  (void) PrintChannelLocations(file,image,BlueChannel,"Blue",
589  statistic_type,max_locations,channel_statistics);
590  break;
591  }
592  case CMYKColorspace:
593  {
594  (void) PrintChannelLocations(file,image,CyanChannel,"Cyan",
595  statistic_type,max_locations,channel_statistics);
596  (void) PrintChannelLocations(file,image,MagentaChannel,"Magenta",
597  statistic_type,max_locations,channel_statistics);
598  (void) PrintChannelLocations(file,image,YellowChannel,"Yellow",
599  statistic_type,max_locations,channel_statistics);
600  (void) PrintChannelLocations(file,image,BlackChannel,"Black",
601  statistic_type,max_locations,channel_statistics);
602  break;
603  }
604  case LinearGRAYColorspace:
605  case GRAYColorspace:
606  {
607  (void) PrintChannelLocations(file,image,GrayChannel,"Gray",
608  statistic_type,max_locations,channel_statistics);
609  break;
610  }
611  }
612  if (image->matte != MagickFalse)
613  (void) PrintChannelLocations(file,image,AlphaChannel,"Alpha",
614  statistic_type,max_locations,channel_statistics);
615  channel_statistics=(ChannelStatistics *) RelinquishMagickMemory(
616  channel_statistics);
617  exception=DestroyExceptionInfo(exception);
618  return(ferror(file) != 0 ? MagickFalse : MagickTrue);
619  }
620  *format='\0';
621  elapsed_time=GetElapsedTime(&image->timer);
622  user_time=GetUserTime(&image->timer);
623  GetTimerInfo(&image->timer);
624  if (verbose == MagickFalse)
625  {
626  /*
627  Display summary info about the image.
628  */
629  if (*image->magick_filename != '\0')
630  if (LocaleCompare(image->magick_filename,image->filename) != 0)
631  (void) FormatLocaleFile(file,"%s=>",image->magick_filename);
632  if ((GetPreviousImageInList(image) == (Image *) NULL) &&
633  (GetNextImageInList(image) == (Image *) NULL) && (image->scene == 0))
634  (void) FormatLocaleFile(file,"%s ",image->filename);
635  else
636  (void) FormatLocaleFile(file,"%s[%.20g] ",image->filename,(double)
637  image->scene);
638  (void) FormatLocaleFile(file,"%s ",image->magick);
639  if ((image->magick_columns != 0) || (image->magick_rows != 0))
640  if ((image->magick_columns != image->columns) ||
641  (image->magick_rows != image->rows))
642  (void) FormatLocaleFile(file,"%.20gx%.20g=>",(double)
643  image->magick_columns,(double) image->magick_rows);
644  (void) FormatLocaleFile(file,"%.20gx%.20g ",(double) image->columns,
645  (double) image->rows);
646  if ((image->page.width != 0) || (image->page.height != 0) ||
647  (image->page.x != 0) || (image->page.y != 0))
648  (void) FormatLocaleFile(file,"%.20gx%.20g%+.20g%+.20g ",(double)
649  image->page.width,(double) image->page.height,(double) image->page.x,
650  (double) image->page.y);
651  (void) FormatLocaleFile(file,"%.20g-bit ",(double) image->depth);
652  if (image->type != UndefinedType)
653  (void) FormatLocaleFile(file,"%s ",CommandOptionToMnemonic(
654  MagickTypeOptions,(ssize_t) image->type));
655  if (colorspace != UndefinedColorspace)
656  (void) FormatLocaleFile(file,"%s ",CommandOptionToMnemonic(
657  MagickColorspaceOptions,(ssize_t) colorspace));
658  if (image->storage_class == DirectClass)
659  {
660  if (image->total_colors != 0)
661  {
662  (void) FormatMagickSize(image->total_colors,MagickFalse,format);
663  (void) FormatLocaleFile(file,"%s ",format);
664  }
665  }
666  else
667  if (image->total_colors <= image->colors)
668  (void) FormatLocaleFile(file,"%.20gc ",(double) image->colors);
669  else
670  (void) FormatLocaleFile(file,"%.20g=>%.20gc ",(double)
671  image->total_colors,(double) image->colors);
672  if (image->error.mean_error_per_pixel != 0.0)
673  (void) FormatLocaleFile(file,"%.20g/%f/%fdb ",(double)
674  (image->error.mean_error_per_pixel+0.5),
675  image->error.normalized_mean_error,
676  image->error.normalized_maximum_error);
677  if (image->extent != 0)
678  {
679  (void) FormatMagickSize(image->extent,MagickTrue,format);
680  (void) FormatLocaleFile(file,"%s ",format);
681  }
682  (void) FormatLocaleFile(file,"%0.3fu %lu:%02lu.%03lu",user_time,
683  (unsigned long) (elapsed_time/60.0),(unsigned long) floor(fmod(
684  elapsed_time,60.0)),(unsigned long) (1000.0*(elapsed_time-
685  floor(elapsed_time))));
686  (void) FormatLocaleFile(file,"\n");
687  (void) fflush(file);
688  exception=DestroyExceptionInfo(exception);
689  return(ferror(file) != 0 ? MagickFalse : MagickTrue);
690  }
691  /*
692  Display verbose info about the image.
693  */
694  pixels=GetVirtualPixels(image,0,0,1,1,exception);
695  exception=DestroyExceptionInfo(exception);
696  ping=pixels == (const PixelPacket *) NULL ? MagickTrue : MagickFalse;
697  exception=(&image->exception);
698  (void) SignatureImage(image);
699  channel_statistics=(ChannelStatistics *) NULL;
700  channel_moments=(ChannelMoments *) NULL;
701  channel_phash=(ChannelPerceptualHash *) NULL;
702  channel_features=(ChannelFeatures *) NULL;
703  depth=0;
704  if (ping == MagickFalse)
705  {
706  depth=GetImageDepth(image,exception);
707  channel_statistics=GetImageChannelStatistics(image,exception);
708  if (channel_statistics == (ChannelStatistics *) NULL)
709  return(MagickFalse);
710  artifact=GetImageArtifact(image,"identify:moments");
711  if (artifact != (const char *) NULL)
712  {
713  channel_moments=GetImageChannelMoments(image,exception);
714  channel_phash=GetImageChannelPerceptualHash(image,exception);
715  }
716  artifact=GetImageArtifact(image,"identify:features");
717  if (artifact != (const char *) NULL)
718  {
719  distance=StringToUnsignedLong(artifact);
720  channel_features=GetImageChannelFeatures(image,distance,exception);
721  }
722  }
723  (void) FormatLocaleFile(file,"Image:\n Filename: %s\n",image->filename);
724  if (*image->magick_filename != '\0')
725  if (LocaleCompare(image->magick_filename,image->filename) != 0)
726  {
727  char
728  filename[MaxTextExtent];
729 
730  GetPathComponent(image->magick_filename,TailPath,filename);
731  (void) FormatLocaleFile(file," Base filename: %s\n",filename);
732  }
733  properties=(*GetBlobProperties(image));
734  if (properties.st_mode != 0)
735  {
736  static const char *rwx[] =
737  { "---", "--x", "-w-", "-wx", "r--", "r-x", "rw-", "rwx"};
738  (void) FormatLocaleFile(file," Permissions: %s%s%s\n",
739  rwx[(properties.st_mode >> 6) & 0x07],
740  rwx[(properties.st_mode >> 3) & 0x07],
741  rwx[(properties.st_mode >> 0) & 0x07]);
742  }
743  magick_info=GetMagickInfo(image->magick,exception);
744  if ((magick_info == (const MagickInfo *) NULL) ||
745  (GetMagickDescription(magick_info) == (const char *) NULL))
746  (void) FormatLocaleFile(file," Format: %s\n",image->magick);
747  else
748  (void) FormatLocaleFile(file," Format: %s (%s)\n",image->magick,
749  GetMagickDescription(magick_info));
750  if ((magick_info != (const MagickInfo *) NULL) &&
751  (GetMagickMimeType(magick_info) != (const char *) NULL))
752  (void) FormatLocaleFile(file," Mime type: %s\n",GetMagickMimeType(
753  magick_info));
754  (void) FormatLocaleFile(file," Class: %s\n",CommandOptionToMnemonic(
755  MagickClassOptions,(ssize_t) image->storage_class));
756  (void) FormatLocaleFile(file," Geometry: %.20gx%.20g%+.20g%+.20g\n",(double)
757  image->columns,(double) image->rows,(double) image->tile_offset.x,(double)
758  image->tile_offset.y);
759  if ((image->magick_columns != 0) || (image->magick_rows != 0))
760  if ((image->magick_columns != image->columns) ||
761  (image->magick_rows != image->rows))
762  (void) FormatLocaleFile(file," Base geometry: %.20gx%.20g\n",(double)
763  image->magick_columns,(double) image->magick_rows);
764  if ((image->x_resolution != 0.0) && (image->y_resolution != 0.0))
765  {
766  (void) FormatLocaleFile(file," Resolution: %gx%g\n",image->x_resolution,
767  image->y_resolution);
768  (void) FormatLocaleFile(file," Print size: %gx%g\n",(double)
769  image->columns/image->x_resolution,(double) image->rows/
770  image->y_resolution);
771  }
772  (void) FormatLocaleFile(file," Units: %s\n",CommandOptionToMnemonic(
773  MagickResolutionOptions,(ssize_t) image->units));
774  (void) FormatLocaleFile(file," Colorspace: %s\n",CommandOptionToMnemonic(
775  MagickColorspaceOptions,(ssize_t) colorspace));
776  type=IdentifyImageType(image,exception);
777  (void) FormatLocaleFile(file," Type: %s\n",CommandOptionToMnemonic(
778  MagickTypeOptions,(ssize_t) type));
779  if (image->type != type)
780  (void) FormatLocaleFile(file," Base type: %s\n",CommandOptionToMnemonic(
781  MagickTypeOptions,(ssize_t) image->type));
782  (void) FormatLocaleFile(file," Endianness: %s\n",CommandOptionToMnemonic(
783  MagickEndianOptions,(ssize_t) image->endian));
784  if (depth != 0)
785  {
786  if (image->depth == depth)
787  (void) FormatLocaleFile(file," Depth: %.20g-bit\n",(double)
788  image->depth);
789  else
790  (void) FormatLocaleFile(file," Depth: %.20g/%.20g-bit\n",(double)
791  image->depth,(double) depth);
792  }
793  if (channel_statistics != (ChannelStatistics *) NULL)
794  {
795  /*
796  Detail channel depth and extrema.
797  */
798  (void) FormatLocaleFile(file," Channel depth:\n");
799  switch (colorspace)
800  {
801  case RGBColorspace:
802  default:
803  {
804  (void) FormatLocaleFile(file," red: %.20g-bit\n",(double)
805  channel_statistics[RedChannel].depth);
806  (void) FormatLocaleFile(file," green: %.20g-bit\n",(double)
807  channel_statistics[GreenChannel].depth);
808  (void) FormatLocaleFile(file," blue: %.20g-bit\n",(double)
809  channel_statistics[BlueChannel].depth);
810  break;
811  }
812  case CMYKColorspace:
813  {
814  (void) FormatLocaleFile(file," cyan: %.20g-bit\n",(double)
815  channel_statistics[CyanChannel].depth);
816  (void) FormatLocaleFile(file," magenta: %.20g-bit\n",(double)
817  channel_statistics[MagentaChannel].depth);
818  (void) FormatLocaleFile(file," yellow: %.20g-bit\n",(double)
819  channel_statistics[YellowChannel].depth);
820  (void) FormatLocaleFile(file," black: %.20g-bit\n",(double)
821  channel_statistics[BlackChannel].depth);
822  break;
823  }
824  case LinearGRAYColorspace:
825  case GRAYColorspace:
826  {
827  (void) FormatLocaleFile(file," gray: %.20g-bit\n",(double)
828  channel_statistics[GrayChannel].depth);
829  break;
830  }
831  }
832  if (image->matte != MagickFalse)
833  (void) FormatLocaleFile(file," alpha: %.20g-bit\n",(double)
834  channel_statistics[OpacityChannel].depth);
835  scale=1.0;
836  if (image->depth <= MAGICKCORE_QUANTUM_DEPTH)
837  scale=(double) QuantumRange/((size_t) QuantumRange >> ((size_t)
838  MAGICKCORE_QUANTUM_DEPTH-image->depth));
839  (void) FormatLocaleFile(file," Channel statistics:\n");
840  (void) FormatLocaleFile(file," Pixels: %.20g\n",(double)
841  image->columns*image->rows);
842  switch (colorspace)
843  {
844  case RGBColorspace:
845  default:
846  {
847  (void) PrintChannelStatistics(file,RedChannel,"Red",1.0/scale,
848  channel_statistics);
849  (void) PrintChannelStatistics(file,GreenChannel,"Green",1.0/scale,
850  channel_statistics);
851  (void) PrintChannelStatistics(file,BlueChannel,"Blue",1.0/scale,
852  channel_statistics);
853  break;
854  }
855  case CMYKColorspace:
856  {
857  (void) PrintChannelStatistics(file,CyanChannel,"Cyan",1.0/scale,
858  channel_statistics);
859  (void) PrintChannelStatistics(file,MagentaChannel,"Magenta",1.0/scale,
860  channel_statistics);
861  (void) PrintChannelStatistics(file,YellowChannel,"Yellow",1.0/scale,
862  channel_statistics);
863  (void) PrintChannelStatistics(file,BlackChannel,"Black",1.0/scale,
864  channel_statistics);
865  break;
866  }
867  case LinearGRAYColorspace:
868  case GRAYColorspace:
869  {
870  (void) PrintChannelStatistics(file,GrayChannel,"Gray",1.0/scale,
871  channel_statistics);
872  break;
873  }
874  }
875  if (image->matte != MagickFalse)
876  (void) PrintChannelStatistics(file,AlphaChannel,"Alpha",1.0/scale,
877  channel_statistics);
878  if ((colorspace != LinearGRAYColorspace) && (colorspace != GRAYColorspace))
879  {
880  (void) FormatLocaleFile(file," Image statistics:\n");
881  (void) PrintChannelStatistics(file,CompositeChannels,"Overall",1.0/
882  scale,channel_statistics);
883  }
884  channel_statistics=(ChannelStatistics *) RelinquishMagickMemory(
885  channel_statistics);
886  }
887  if (channel_moments != (ChannelMoments *) NULL)
888  {
889  scale=(double) ((1UL << image->depth)-1);
890  (void) FormatLocaleFile(file," Channel Hu moments:\n");
891  switch (colorspace)
892  {
893  case RGBColorspace:
894  default:
895  {
896  (void) PrintChannelMoments(file,RedChannel,"Red",scale,
897  channel_moments);
898  (void) PrintChannelMoments(file,GreenChannel,"Green",scale,
899  channel_moments);
900  (void) PrintChannelMoments(file,BlueChannel,"Blue",scale,
901  channel_moments);
902  break;
903  }
904  case CMYKColorspace:
905  {
906  (void) PrintChannelMoments(file,CyanChannel,"Cyan",scale,
907  channel_moments);
908  (void) PrintChannelMoments(file,MagentaChannel,"Magenta",scale,
909  channel_moments);
910  (void) PrintChannelMoments(file,YellowChannel,"Yellow",scale,
911  channel_moments);
912  (void) PrintChannelMoments(file,BlackChannel,"Black",scale,
913  channel_moments);
914  break;
915  }
916  case LinearGRAYColorspace:
917  case GRAYColorspace:
918  {
919  (void) PrintChannelMoments(file,GrayChannel,"Gray",scale,
920  channel_moments);
921  break;
922  }
923  }
924  if (image->matte != MagickFalse)
925  (void) PrintChannelMoments(file,AlphaChannel,"Alpha",scale,
926  channel_moments);
927  if ((colorspace != LinearGRAYColorspace) && (colorspace != GRAYColorspace))
928  {
929  (void) FormatLocaleFile(file," Image moments:\n");
930  (void) PrintChannelMoments(file,CompositeChannels,"Overall",scale,
931  channel_moments);
932  }
933  channel_moments=(ChannelMoments *) RelinquishMagickMemory(
934  channel_moments);
935  }
936  if (channel_phash != (ChannelPerceptualHash *) NULL)
937  {
938  (void) FormatLocaleFile(file," Channel perceptual hash:\n");
939  (void) PrintChannelPerceptualHash(file,RedChannel,"Red, Hue",
940  channel_phash);
941  (void) PrintChannelPerceptualHash(file,GreenChannel,"Green, Chroma",
942  channel_phash);
943  (void) PrintChannelPerceptualHash(file,BlueChannel,"Blue, Luma",
944  channel_phash);
945  if (image->matte != MagickFalse)
946  (void) PrintChannelPerceptualHash(file,AlphaChannel,"Alpha, Alpha",
947  channel_phash);
948  channel_phash=(ChannelPerceptualHash *) RelinquishMagickMemory(
949  channel_phash);
950  }
951  if (channel_features != (ChannelFeatures *) NULL)
952  {
953  (void) FormatLocaleFile(file," Channel features (horizontal, vertical, "
954  "left and right diagonals, average):\n");
955  switch (colorspace)
956  {
957  case RGBColorspace:
958  default:
959  {
960  (void) PrintChannelFeatures(file,RedChannel,"Red",channel_features);
961  (void) PrintChannelFeatures(file,GreenChannel,"Green",
962  channel_features);
963  (void) PrintChannelFeatures(file,BlueChannel,"Blue",channel_features);
964  break;
965  }
966  case CMYKColorspace:
967  {
968  (void) PrintChannelFeatures(file,CyanChannel,"Cyan",channel_features);
969  (void) PrintChannelFeatures(file,MagentaChannel,"Magenta",
970  channel_features);
971  (void) PrintChannelFeatures(file,YellowChannel,"Yellow",
972  channel_features);
973  (void) PrintChannelFeatures(file,BlackChannel,"Black",
974  channel_features);
975  break;
976  }
977  case LinearGRAYColorspace:
978  case GRAYColorspace:
979  {
980  (void) PrintChannelFeatures(file,GrayChannel,"Gray",channel_features);
981  break;
982  }
983  }
984  if (image->matte != MagickFalse)
985  (void) PrintChannelFeatures(file,AlphaChannel,"Alpha",channel_features);
986  channel_features=(ChannelFeatures *) RelinquishMagickMemory(
987  channel_features);
988  }
989  if (ping == MagickFalse)
990  {
991  if (colorspace == CMYKColorspace)
992  (void) FormatLocaleFile(file," Total ink density: %.*g%%\n",
993  GetMagickPrecision(),100.0*GetImageTotalInkDensity(image)/(double)
994  QuantumRange);
995  x=0;
996  if (image->matte != MagickFalse)
997  {
998  MagickBooleanType
999  found = MagickFalse;
1000 
1001  const IndexPacket
1002  *indexes;
1003 
1004  const PixelPacket
1005  *p;
1006 
1007  p=(PixelPacket *) NULL;
1008  indexes=(IndexPacket *) NULL;
1009  for (y=0; y < (ssize_t) image->rows; y++)
1010  {
1011  p=GetVirtualPixels(image,0,y,image->columns,1,exception);
1012  if (p == (const PixelPacket *) NULL)
1013  break;
1014  indexes=GetVirtualIndexQueue(image);
1015  for (x=0; x < (ssize_t) image->columns; x++)
1016  {
1017  if (GetPixelOpacity(p) == (Quantum) TransparentOpacity)
1018  {
1019  found=MagickTrue;
1020  break;
1021  }
1022  p++;
1023  }
1024  if (found != MagickFalse)
1025  break;
1026  }
1027  if (found != MagickFalse)
1028  {
1029  char
1030  tuple[MaxTextExtent];
1031 
1033  pixel;
1034 
1035  GetMagickPixelPacket(image,&pixel);
1036  SetMagickPixelPacket(image,p,indexes+x,&pixel);
1037  (void) QueryMagickColorname(image,&pixel,SVGCompliance,tuple,
1038  exception);
1039  (void) FormatLocaleFile(file," Alpha: %s ",tuple);
1040  GetColorTuple(&pixel,MagickTrue,tuple);
1041  (void) FormatLocaleFile(file," %s\n",tuple);
1042  }
1043  }
1044  artifact=GetImageArtifact(image,"identify:unique-colors");
1045  if (IsHistogramImage(image,exception) != MagickFalse)
1046  {
1047  (void) FormatLocaleFile(file," Colors: %.20g\n",(double)
1048  GetNumberColors(image,(FILE *) NULL,exception));
1049  (void) FormatLocaleFile(file," Histogram:\n");
1050  (void) GetNumberColors(image,file,exception);
1051  }
1052  else
1053  if ((artifact != (const char *) NULL) &&
1054  (IsMagickTrue(artifact) != MagickFalse))
1055  (void) FormatLocaleFile(file," Colors: %.20g\n",(double)
1056  GetNumberColors(image,(FILE *) NULL,exception));
1057  }
1058  if (image->storage_class == PseudoClass)
1059  {
1060  (void) FormatLocaleFile(file," Colormap entries: %.20g\n",(double)
1061  image->colors);
1062  (void) FormatLocaleFile(file," Colormap:\n");
1063  if (image->colors <= 1024)
1064  {
1065  char
1066  color[MaxTextExtent],
1067  hex[MaxTextExtent],
1068  tuple[MaxTextExtent];
1069 
1071  pixel;
1072 
1073  PixelPacket
1074  *magick_restrict p;
1075 
1076  GetMagickPixelPacket(image,&pixel);
1077  p=image->colormap;
1078  for (i=0; i < (ssize_t) image->colors; i++)
1079  {
1080  SetMagickPixelPacket(image,p,(IndexPacket *) NULL,&pixel);
1081  (void) CopyMagickString(tuple,"(",MaxTextExtent);
1082  ConcatenateColorComponent(&pixel,RedChannel,X11Compliance,tuple);
1083  (void) ConcatenateMagickString(tuple,",",MaxTextExtent);
1084  ConcatenateColorComponent(&pixel,GreenChannel,X11Compliance,tuple);
1085  (void) ConcatenateMagickString(tuple,",",MaxTextExtent);
1086  ConcatenateColorComponent(&pixel,BlueChannel,X11Compliance,tuple);
1087  if (pixel.colorspace == CMYKColorspace)
1088  {
1089  (void) ConcatenateMagickString(tuple,",",MaxTextExtent);
1090  ConcatenateColorComponent(&pixel,IndexChannel,X11Compliance,
1091  tuple);
1092  }
1093  if (pixel.matte != MagickFalse)
1094  {
1095  (void) ConcatenateMagickString(tuple,",",MaxTextExtent);
1096  ConcatenateColorComponent(&pixel,AlphaChannel,X11Compliance,
1097  tuple);
1098  }
1099  (void) ConcatenateMagickString(tuple,")",MaxTextExtent);
1100  (void) QueryMagickColorname(image,&pixel,SVGCompliance,color,
1101  exception);
1102  GetColorTuple(&pixel,MagickTrue,hex);
1103  (void) FormatLocaleFile(file," %g: %s %s %s\n",(double) i,tuple,
1104  hex,color);
1105  p++;
1106  }
1107  }
1108  }
1109  if (image->error.mean_error_per_pixel != 0.0)
1110  (void) FormatLocaleFile(file," Mean error per pixel: %g\n",
1111  image->error.mean_error_per_pixel);
1112  if (image->error.normalized_mean_error != 0.0)
1113  (void) FormatLocaleFile(file," Normalized mean error: %g\n",
1114  image->error.normalized_mean_error);
1115  if (image->error.normalized_maximum_error != 0.0)
1116  (void) FormatLocaleFile(file," Normalized maximum error: %g\n",
1117  image->error.normalized_maximum_error);
1118  (void) FormatLocaleFile(file," Rendering intent: %s\n",
1119  CommandOptionToMnemonic(MagickIntentOptions,(ssize_t)
1120  image->rendering_intent));
1121  if (image->gamma != 0.0)
1122  (void) FormatLocaleFile(file," Gamma: %g\n",image->gamma);
1123  if ((image->chromaticity.red_primary.x != 0.0) ||
1124  (image->chromaticity.green_primary.x != 0.0) ||
1125  (image->chromaticity.blue_primary.x != 0.0) ||
1126  (image->chromaticity.white_point.x != 0.0))
1127  {
1128  /*
1129  Display image chromaticity.
1130  */
1131  (void) FormatLocaleFile(file," Chromaticity:\n");
1132  (void) FormatLocaleFile(file," red primary: (%g,%g,%g)\n",
1133  image->chromaticity.red_primary.x,image->chromaticity.red_primary.y,
1134  image->chromaticity.red_primary.z);
1135  (void) FormatLocaleFile(file," green primary: (%g,%g,%g)\n",
1136  image->chromaticity.green_primary.x,image->chromaticity.green_primary.y,
1137  image->chromaticity.green_primary.z);
1138  (void) FormatLocaleFile(file," blue primary: (%g,%g,%g)\n",
1139  image->chromaticity.blue_primary.x,image->chromaticity.blue_primary.y,
1140  image->chromaticity.blue_primary.z);
1141  (void) FormatLocaleFile(file," white point: (%g,%g,%g)\n",
1142  image->chromaticity.white_point.x,image->chromaticity.white_point.y,
1143  image->chromaticity.white_point.z);
1144  }
1145  if ((image->extract_info.width*image->extract_info.height) != 0)
1146  (void) FormatLocaleFile(file," Tile geometry: %.20gx%.20g%+.20g%+.20g\n",
1147  (double) image->extract_info.width,(double) image->extract_info.height,
1148  (double) image->extract_info.x,(double) image->extract_info.y);
1149  (void) QueryColorname(image,&image->background_color,SVGCompliance,color,
1150  exception);
1151  (void) FormatLocaleFile(file," Background color: %s\n",color);
1152  (void) QueryColorname(image,&image->border_color,SVGCompliance,color,
1153  exception);
1154  (void) FormatLocaleFile(file," Border color: %s\n",color);
1155  (void) QueryColorname(image,&image->matte_color,SVGCompliance,color,
1156  exception);
1157  (void) FormatLocaleFile(file," Matte color: %s\n",color);
1158  (void) QueryColorname(image,&image->transparent_color,SVGCompliance,color,
1159  exception);
1160  (void) FormatLocaleFile(file," Transparent color: %s\n",color);
1161  (void) FormatLocaleFile(file," Interlace: %s\n",CommandOptionToMnemonic(
1162  MagickInterlaceOptions,(ssize_t) image->interlace));
1163  (void) FormatLocaleFile(file," Intensity: %s\n",CommandOptionToMnemonic(
1164  MagickPixelIntensityOptions,(ssize_t) image->intensity));
1165  (void) FormatLocaleFile(file," Compose: %s\n",CommandOptionToMnemonic(
1166  MagickComposeOptions,(ssize_t) image->compose));
1167  if ((image->page.width != 0) || (image->page.height != 0) ||
1168  (image->page.x != 0) || (image->page.y != 0))
1169  (void) FormatLocaleFile(file," Page geometry: %.20gx%.20g%+.20g%+.20g\n",
1170  (double) image->page.width,(double) image->page.height,(double)
1171  image->page.x,(double) image->page.y);
1172  if ((image->page.x != 0) || (image->page.y != 0))
1173  (void) FormatLocaleFile(file," Origin geometry: %+.20g%+.20g\n",(double)
1174  image->page.x,(double) image->page.y);
1175  (void) FormatLocaleFile(file," Dispose: %s\n",CommandOptionToMnemonic(
1176  MagickDisposeOptions,(ssize_t) image->dispose));
1177  if (image->delay != 0)
1178  (void) FormatLocaleFile(file," Delay: %.20gx%.20g\n",(double) image->delay,
1179  (double) image->ticks_per_second);
1180  if (image->iterations != 1)
1181  (void) FormatLocaleFile(file," Iterations: %.20g\n",(double)
1182  image->iterations);
1183  if (image->duration != 0)
1184  (void) FormatLocaleFile(file," Duration: %.20g\n",(double)
1185  image->duration);
1186  if ((image->next != (Image *) NULL) || (image->previous != (Image *) NULL))
1187  (void) FormatLocaleFile(file," Scene: %.20g of %.20g\n",(double)
1188  image->scene,(double) GetImageListLength(image));
1189  else
1190  if (image->scene != 0)
1191  (void) FormatLocaleFile(file," Scene: %.20g\n",(double) image->scene);
1192  (void) FormatLocaleFile(file," Compression: %s\n",CommandOptionToMnemonic(
1193  MagickCompressOptions,(ssize_t) image->compression));
1194  if (image->quality != UndefinedCompressionQuality)
1195  (void) FormatLocaleFile(file," Quality: %.20g\n",(double) image->quality);
1196  (void) FormatLocaleFile(file," Orientation: %s\n",CommandOptionToMnemonic(
1197  MagickOrientationOptions,(ssize_t) image->orientation));
1198  if (image->montage != (char *) NULL)
1199  (void) FormatLocaleFile(file," Montage: %s\n",image->montage);
1200  if (image->directory != (char *) NULL)
1201  {
1202  Image
1203  *tile;
1204 
1205  ImageInfo
1206  *image_info;
1207 
1208  char
1209  *p,
1210  *q;
1211 
1212  WarningHandler
1213  handler;
1214 
1215  /*
1216  Display visual image directory.
1217  */
1218  image_info=AcquireImageInfo();
1219  (void) CloneString(&image_info->size,"64x64");
1220  (void) FormatLocaleFile(file," Directory:\n");
1221  for (p=image->directory; *p != '\0'; p++)
1222  {
1223  q=p;
1224  while ((*q != '\xff') && (*q != '\0') &&
1225  ((size_t) (q-p+1) < sizeof(image_info->filename)))
1226  q++;
1227  (void) CopyMagickString(image_info->filename,p,(size_t) (q-p+1));
1228  p=q;
1229  (void) FormatLocaleFile(file," %s",image_info->filename);
1230  handler=SetWarningHandler((WarningHandler) NULL);
1231  tile=StrictReadImage(image_info,exception);
1232  (void) SetWarningHandler(handler);
1233  if (tile == (Image *) NULL)
1234  {
1235  (void) FormatLocaleFile(file,"\n");
1236  continue;
1237  }
1238  (void) FormatLocaleFile(file," %.20gx%.20g %s\n",(double)
1239  tile->magick_columns,(double) tile->magick_rows,tile->magick);
1240  (void) SignatureImage(tile);
1241  ResetImagePropertyIterator(tile);
1242  property=GetNextImageProperty(tile);
1243  while (property != (const char *) NULL)
1244  {
1245  (void) FormatLocaleFile(file," %s:\n",property);
1246  value=GetImageProperty(tile,property);
1247  if (value != (const char *) NULL)
1248  (void) FormatLocaleFile(file,"%s\n",value);
1249  property=GetNextImageProperty(tile);
1250  }
1251  tile=DestroyImage(tile);
1252  }
1253  image_info=DestroyImageInfo(image_info);
1254  }
1255  (void) FormatLocaleString(key,MaxTextExtent,"8BIM:1999,2998:#1");
1256  value=GetImageProperty(image,key);
1257  if (value != (const char *) NULL)
1258  {
1259  /*
1260  Display clipping path.
1261  */
1262  (void) FormatLocaleFile(file," Clipping path: ");
1263  if (strlen(value) > 80)
1264  (void) fputc('\n',file);
1265  (void) FormatLocaleFile(file,"%s\n",value);
1266  }
1267  ResetImageProfileIterator(image);
1268  name=GetNextImageProfile(image);
1269  if (name != (char *) NULL)
1270  {
1271  const StringInfo
1272  *profile;
1273 
1274  /*
1275  Identify image profiles.
1276  */
1277  (void) FormatLocaleFile(file," Profiles:\n");
1278  while (name != (char *) NULL)
1279  {
1280  profile=GetImageProfile(image,name);
1281  if (profile == (StringInfo *) NULL)
1282  continue;
1283  (void) FormatLocaleFile(file," Profile-%s: %.20g bytes\n",name,
1284  (double) GetStringInfoLength(profile));
1285  if (LocaleCompare(name,"iptc") == 0)
1286  {
1287  char
1288  *attribute,
1289  **attribute_list;
1290 
1291  const char
1292  *tag;
1293 
1294  long
1295  dataset,
1296  record,
1297  sentinel;
1298 
1299  ssize_t
1300  j;
1301 
1302  size_t
1303  length,
1304  profile_length;
1305 
1306  profile_length=GetStringInfoLength(profile);
1307  for (i=0; i < (ssize_t) profile_length-5; i+=(ssize_t) length)
1308  {
1309  length=1;
1310  sentinel=GetStringInfoDatum(profile)[i++];
1311  if (sentinel != 0x1c)
1312  continue;
1313  dataset=GetStringInfoDatum(profile)[i++];
1314  record=GetStringInfoDatum(profile)[i++];
1315  switch (record)
1316  {
1317  case 5: tag="Image Name"; break;
1318  case 7: tag="Edit Status"; break;
1319  case 10: tag="Priority"; break;
1320  case 15: tag="Category"; break;
1321  case 20: tag="Supplemental Category"; break;
1322  case 22: tag="Fixture Identifier"; break;
1323  case 25: tag="Keyword"; break;
1324  case 30: tag="Release Date"; break;
1325  case 35: tag="Release Time"; break;
1326  case 40: tag="Special Instructions"; break;
1327  case 45: tag="Reference Service"; break;
1328  case 47: tag="Reference Date"; break;
1329  case 50: tag="Reference Number"; break;
1330  case 55: tag="Created Date"; break;
1331  case 60: tag="Created Time"; break;
1332  case 65: tag="Originating Program"; break;
1333  case 70: tag="Program Version"; break;
1334  case 75: tag="Object Cycle"; break;
1335  case 80: tag="Byline"; break;
1336  case 85: tag="Byline Title"; break;
1337  case 90: tag="City"; break;
1338  case 92: tag="Sub-Location"; break;
1339  case 95: tag="Province State"; break;
1340  case 100: tag="Country Code"; break;
1341  case 101: tag="Country"; break;
1342  case 103: tag="Original Transmission Reference"; break;
1343  case 105: tag="Headline"; break;
1344  case 110: tag="Credit"; break;
1345  case 115: tag="Src"; break;
1346  case 116: tag="Copyright String"; break;
1347  case 120: tag="Caption"; break;
1348  case 121: tag="Local Caption"; break;
1349  case 122: tag="Caption Writer"; break;
1350  case 200: tag="Custom Field 1"; break;
1351  case 201: tag="Custom Field 2"; break;
1352  case 202: tag="Custom Field 3"; break;
1353  case 203: tag="Custom Field 4"; break;
1354  case 204: tag="Custom Field 5"; break;
1355  case 205: tag="Custom Field 6"; break;
1356  case 206: tag="Custom Field 7"; break;
1357  case 207: tag="Custom Field 8"; break;
1358  case 208: tag="Custom Field 9"; break;
1359  case 209: tag="Custom Field 10"; break;
1360  case 210: tag="Custom Field 11"; break;
1361  case 211: tag="Custom Field 12"; break;
1362  case 212: tag="Custom Field 13"; break;
1363  case 213: tag="Custom Field 14"; break;
1364  case 214: tag="Custom Field 15"; break;
1365  case 215: tag="Custom Field 16"; break;
1366  case 216: tag="Custom Field 17"; break;
1367  case 217: tag="Custom Field 18"; break;
1368  case 218: tag="Custom Field 19"; break;
1369  case 219: tag="Custom Field 20"; break;
1370  default: tag="unknown"; break;
1371  }
1372  (void) FormatLocaleFile(file," %s[%.20g,%.20g]: ",tag,
1373  (double) dataset,(double) record);
1374  length=(size_t) (GetStringInfoDatum(profile)[i++] << 8);
1375  length|=GetStringInfoDatum(profile)[i++];
1376  length=MagickMin(length,profile_length-i);
1377  attribute=(char *) NULL;
1378  if (~length >= (MaxTextExtent-1))
1379  attribute=(char *) AcquireQuantumMemory(length+
1380  MaxTextExtent,sizeof(*attribute));
1381  if (attribute != (char *) NULL)
1382  {
1383  (void) CopyMagickString(attribute,(char *)
1384  GetStringInfoDatum(profile)+i,length+1);
1385  attribute_list=StringToList(attribute);
1386  if (attribute_list != (char **) NULL)
1387  {
1388  for (j=0; attribute_list[j] != (char *) NULL; j++)
1389  {
1390  (void) fputs(attribute_list[j],file);
1391  (void) fputs("\n",file);
1392  attribute_list[j]=(char *) RelinquishMagickMemory(
1393  attribute_list[j]);
1394  }
1395  attribute_list=(char **) RelinquishMagickMemory(
1396  attribute_list);
1397  }
1398  attribute=DestroyString(attribute);
1399  }
1400  }
1401  }
1402  if (image->debug != MagickFalse)
1403  PrintStringInfo(file,name,profile);
1404  name=GetNextImageProfile(image);
1405  }
1406  }
1407  ResetImagePropertyIterator(image);
1408  property=GetNextImageProperty(image);
1409  if (property != (const char *) NULL)
1410  {
1411  /*
1412  Display image properties.
1413  */
1414  (void) FormatLocaleFile(file," Properties:\n");
1415  while (property != (const char *) NULL)
1416  {
1417  (void) FormatLocaleFile(file," %s: ",property);
1418  value=GetImageProperty(image,property);
1419  if (value != (const char *) NULL)
1420  (void) FormatLocaleFile(file,"%s\n",value);
1421  property=GetNextImageProperty(image);
1422  }
1423  }
1424  ResetImageArtifactIterator(image);
1425  artifact=GetNextImageArtifact(image);
1426  if (artifact != (const char *) NULL)
1427  {
1428  /*
1429  Display image artifacts.
1430  */
1431  (void) FormatLocaleFile(file," Artifacts:\n");
1432  while (artifact != (const char *) NULL)
1433  {
1434  (void) FormatLocaleFile(file," %s: ",artifact);
1435  value=GetImageArtifact(image,artifact);
1436  if (value != (const char *) NULL)
1437  (void) FormatLocaleFile(file,"%s\n",value);
1438  artifact=GetNextImageArtifact(image);
1439  }
1440  }
1441  ResetImageRegistryIterator();
1442  registry=GetNextImageRegistry();
1443  if (registry != (const char *) NULL)
1444  {
1445  /*
1446  Display image registry.
1447  */
1448  (void) FormatLocaleFile(file," Registry:\n");
1449  while (registry != (const char *) NULL)
1450  {
1451  (void) FormatLocaleFile(file," %s: ",registry);
1452  value=(const char *) GetImageRegistry(StringRegistryType,registry,
1453  exception);
1454  if (value != (const char *) NULL)
1455  (void) FormatLocaleFile(file,"%s\n",value);
1456  registry=GetNextImageRegistry();
1457  }
1458  }
1459  (void) FormatLocaleFile(file," Tainted: %s\n",CommandOptionToMnemonic(
1460  MagickBooleanOptions,(ssize_t) image->taint));
1461  (void) FormatMagickSize(image->extent,MagickTrue,format);
1462  (void) FormatLocaleFile(file," Filesize: %s\n",format);
1463  (void) FormatMagickSize((MagickSizeType) image->columns*image->rows,
1464  MagickFalse,format);
1465  if (strlen(format) > 1)
1466  format[strlen(format)-1]='\0';
1467  (void) FormatLocaleFile(file," Number pixels: %s\n",format);
1468  if (elapsed_time > MagickEpsilon)
1469  {
1470  (void) FormatMagickSize((MagickSizeType) ((double) image->columns*
1471  image->rows/elapsed_time+0.5),MagickFalse,format);
1472  (void) FormatLocaleFile(file," Pixels per second: %s\n",format);
1473  }
1474  if (image->ttl != (time_t) 0)
1475  {
1476  char
1477  iso8601[sizeof("9999-99-99T99:99:99Z")];
1478 
1479  int
1480  seconds;
1481 
1482  struct tm
1483  timestamp;
1484 
1485  (void) GetMagickUTCTime(&image->ttl,&timestamp);
1486  (void) strftime(iso8601,sizeof(iso8601),"%Y-%m-%dT%H:%M:%SZ",&timestamp);
1487  seconds=MagickMax((int)(image->ttl-GetMagickTime()),0);
1488  expired=' ';
1489  if (seconds == 0)
1490  expired='*';
1491  (void) FormatLocaleFile(file," Time-to-live: %g:%02g:%02g:%02g%c %s\n",
1492  ceil((double) (seconds/(3600*24))),
1493  ceil((double) ((seconds % (24*3600))/3600)),
1494  ceil((double) ((seconds % 3600)/60)),
1495  ceil((double) ((seconds % 3600) % 60)),expired,iso8601);
1496  }
1497  (void) FormatLocaleFile(file," User time: %0.3fu\n",user_time);
1498  (void) FormatLocaleFile(file," Elapsed time: %lu:%02lu.%03lu\n",
1499  (unsigned long) (elapsed_time/60.0),(unsigned long) ceil(fmod(
1500  elapsed_time,60.0)),(unsigned long) (1000.0*(elapsed_time-floor(
1501  elapsed_time))));
1502  (void) FormatLocaleFile(file," Version: %s\n",GetMagickVersion((size_t *)
1503  NULL));
1504  (void) fflush(file);
1505  return(ferror(file) != 0 ? MagickFalse : MagickTrue);
1506 }
Definition: image.h:133