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