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/blob-private.h"
51#include "MagickCore/cache.h"
52#include "MagickCore/client.h"
53#include "MagickCore/coder.h"
54#include "MagickCore/color.h"
55#include "MagickCore/configure.h"
56#include "MagickCore/constitute.h"
57#include "MagickCore/constitute-private.h"
58#include "MagickCore/decorate.h"
59#include "MagickCore/delegate.h"
60#include "MagickCore/draw.h"
61#include "MagickCore/effect.h"
62#include "MagickCore/exception.h"
63#include "MagickCore/exception-private.h"
64#include "MagickCore/feature.h"
65#include "MagickCore/gem.h"
66#include "MagickCore/geometry.h"
67#include "MagickCore/histogram.h"
68#include "MagickCore/identify.h"
69#include "MagickCore/image.h"
70#include "MagickCore/image-private.h"
71#include "MagickCore/list.h"
72#include "MagickCore/locale_.h"
73#include "MagickCore/log.h"
74#include "MagickCore/magic.h"
75#include "MagickCore/magick.h"
76#include "MagickCore/memory_.h"
77#include "MagickCore/module.h"
78#include "MagickCore/monitor.h"
79#include "MagickCore/montage.h"
80#include "MagickCore/option.h"
81#include "MagickCore/pixel-accessor.h"
82#include "MagickCore/pixel-private.h"
83#include "MagickCore/prepress.h"
84#include "MagickCore/profile.h"
85#include "MagickCore/property.h"
86#include "MagickCore/quantize.h"
87#include "MagickCore/quantum.h"
88#include "MagickCore/random_.h"
89#include "MagickCore/registry.h"
90#include "MagickCore/resize.h"
91#include "MagickCore/resource_.h"
92#include "MagickCore/signature.h"
93#include "MagickCore/statistic.h"
94#include "MagickCore/string_.h"
95#include "MagickCore/string-private.h"
96#include "MagickCore/timer.h"
97#include "MagickCore/timer-private.h"
98#include "MagickCore/token.h"
99#include "MagickCore/utility.h"
100#include "MagickCore/utility-private.h"
101#include "MagickCore/version.h"
135static ChannelStatistics *GetLocationStatistics(
const Image *image,
136 const StatisticType type,ExceptionInfo *exception)
145 assert(image != (Image *) NULL);
146 assert(image->signature == MagickCoreSignature);
147 if (IsEventLogging() != MagickFalse)
148 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",image->filename);
149 channel_statistics=(ChannelStatistics *) AcquireQuantumMemory(
150 MaxPixelChannels+1,
sizeof(*channel_statistics));
151 if (channel_statistics == (ChannelStatistics *) NULL)
153 (void) ThrowMagickException(exception,GetMagickModule(),
154 ResourceLimitError,
"MemoryAllocationFailed",
"`%s'",image->filename);
155 return(channel_statistics);
157 (void) memset(channel_statistics,0,(MaxPixelChannels+1)*
158 sizeof(*channel_statistics));
159 for (i=0; i <= (ssize_t) MaxPixelChannels; i++)
163 case MaximumStatistic:
166 channel_statistics[i].maxima=(-MagickMaximumValue);
169 case MinimumStatistic:
171 channel_statistics[i].minima=MagickMaximumValue;
176 for (y=0; y < (ssize_t) image->rows; y++)
184 p=GetVirtualPixels(image,0,y,image->columns,1,exception);
185 if (p == (
const Quantum *) NULL)
187 for (x=0; x < (ssize_t) image->columns; x++)
189 if (GetPixelReadMask(image,p) <= (QuantumRange/2))
191 p+=(ptrdiff_t) GetPixelChannels(image);
194 for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
196 PixelChannel channel = GetPixelChannelChannel(image,i);
197 PixelTrait traits = GetPixelChannelTraits(image,channel);
198 if (traits == UndefinedPixelTrait)
202 case MaximumStatistic:
205 if ((
double) p[i] > channel_statistics[channel].maxima)
206 channel_statistics[channel].maxima=(double) p[i];
209 case MinimumStatistic:
211 if ((
double) p[i] < channel_statistics[channel].minima)
212 channel_statistics[channel].minima=(double) p[i];
217 p+=(ptrdiff_t) GetPixelChannels(image);
220 return(channel_statistics);
223static ssize_t PrintChannelFeatures(FILE *file,
const PixelChannel channel,
224 const char *name,
const ChannelFeatures *channel_features)
226#define PrintFeature(feature) \
227 GetMagickPrecision(),(feature)[0], \
228 GetMagickPrecision(),(feature)[1], \
229 GetMagickPrecision(),(feature)[2], \
230 GetMagickPrecision(),(feature)[3], \
231 GetMagickPrecision(),((feature)[0]+(feature)[1]+(feature)[2]+(feature)[3])/4.0 \
233#define FeaturesFormat " %s:\n" \
234 " Angular Second Moment:\n" \
235 " %.*g, %.*g, %.*g, %.*g, %.*g\n" \
237 " %.*g, %.*g, %.*g, %.*g, %.*g\n" \
239 " %.*g, %.*g, %.*g, %.*g, %.*g\n" \
240 " Sum of Squares Variance:\n" \
241 " %.*g, %.*g, %.*g, %.*g, %.*g\n" \
242 " Inverse Difference Moment:\n" \
243 " %.*g, %.*g, %.*g, %.*g, %.*g\n" \
245 " %.*g, %.*g, %.*g, %.*g, %.*g\n" \
247 " %.*g, %.*g, %.*g, %.*g, %.*g\n" \
249 " %.*g, %.*g, %.*g, %.*g, %.*g\n" \
251 " %.*g, %.*g, %.*g, %.*g, %.*g\n" \
252 " Difference Variance:\n" \
253 " %.*g, %.*g, %.*g, %.*g, %.*g\n" \
254 " Difference Entropy:\n" \
255 " %.*g, %.*g, %.*g, %.*g, %.*g\n" \
256 " Information Measure of Correlation 1:\n" \
257 " %.*g, %.*g, %.*g, %.*g, %.*g\n" \
258 " Information Measure of Correlation 2:\n" \
259 " %.*g, %.*g, %.*g, %.*g, %.*g\n" \
260 " Maximum Correlation Coefficient:\n" \
261 " %.*g, %.*g, %.*g, %.*g, %.*g\n"
266 n=FormatLocaleFile(file,FeaturesFormat,name,
267 PrintFeature(channel_features[channel].angular_second_moment),
268 PrintFeature(channel_features[channel].contrast),
269 PrintFeature(channel_features[channel].correlation),
270 PrintFeature(channel_features[channel].variance_sum_of_squares),
271 PrintFeature(channel_features[channel].inverse_difference_moment),
272 PrintFeature(channel_features[channel].sum_average),
273 PrintFeature(channel_features[channel].sum_variance),
274 PrintFeature(channel_features[channel].sum_entropy),
275 PrintFeature(channel_features[channel].entropy),
276 PrintFeature(channel_features[channel].difference_variance),
277 PrintFeature(channel_features[channel].difference_entropy),
278 PrintFeature(channel_features[channel].measure_of_correlation_1),
279 PrintFeature(channel_features[channel].measure_of_correlation_2),
280 PrintFeature(channel_features[channel].maximum_correlation_coefficient));
284static ssize_t PrintChannelLocations(FILE *file,
const Image *image,
285 const PixelChannel channel,
const char *name,
const StatisticType type,
286 const size_t locations,
const ChannelStatistics *channel_statistics)
300 case MaximumStatistic:
303 target=channel_statistics[channel].maxima;
306 case MinimumStatistic:
308 target=channel_statistics[channel].minima;
312 (void) FormatLocaleFile(file,
" %s: %.*g (%.*g)",name,GetMagickPrecision(),
313 target,GetMagickPrecision(),QuantumScale*target);
314 exception=AcquireExceptionInfo();
316 for (y=0; y < (ssize_t) image->rows; y++)
325 p=GetVirtualPixels(image,0,y,image->columns,1,exception);
326 if (p == (
const Quantum *) NULL)
328 for (x=0; x < (ssize_t) image->columns; x++)
333 PixelTrait traits = GetPixelChannelTraits(image,channel);
334 if (traits == UndefinedPixelTrait)
336 offset=GetPixelChannelOffset(image,channel);
337 match=fabs((
double) p[offset]-target) < MagickEpsilon ? MagickTrue :
339 if (match != MagickFalse)
341 if ((locations != 0) && (n >= (ssize_t) locations))
343 (void) FormatLocaleFile(file,
" %.17g,%.17g",(
double) x,(
double) y);
346 p+=(ptrdiff_t) GetPixelChannels(image);
348 if (x < (ssize_t) image->columns)
351 (void) FormatLocaleFile(file,
"\n");
355static ssize_t PrintChannelMoments(FILE *file,
const PixelChannel channel,
356 const char *name,
const double scale,
const ChannelMoments *channel_moments)
359 powers[MaximumNumberOfImageMoments] =
360 { 1.0, 2.0, 3.0, 3.0, 6.0, 4.0, 6.0, 4.0 };
368 n=FormatLocaleFile(file,
" %s:\n",name);
369 n+=FormatLocaleFile(file,
" Centroid: %.*g,%.*g\n",
370 GetMagickPrecision(),channel_moments[channel].centroid.x,
371 GetMagickPrecision(),channel_moments[channel].centroid.y);
372 n+=FormatLocaleFile(file,
" Ellipse Semi-Major/Minor axis: %.*g,%.*g\n",
373 GetMagickPrecision(),channel_moments[channel].ellipse_axis.x,
374 GetMagickPrecision(),channel_moments[channel].ellipse_axis.y);
375 n+=FormatLocaleFile(file,
" Ellipse angle: %.*g\n",
376 GetMagickPrecision(),channel_moments[channel].ellipse_angle);
377 n+=FormatLocaleFile(file,
" Ellipse eccentricity: %.*g\n",
378 GetMagickPrecision(),channel_moments[channel].ellipse_eccentricity);
379 n+=FormatLocaleFile(file,
" Ellipse intensity: %.*g (%.*g)\n",
380 GetMagickPrecision(),pow(scale,powers[0])*
381 channel_moments[channel].ellipse_intensity,GetMagickPrecision(),
382 channel_moments[channel].ellipse_intensity);
383 for (i=0; i < MaximumNumberOfImageMoments; i++)
384 n+=FormatLocaleFile(file,
" I%.17g: %.*g (%.*g)\n",i+1.0,
385 GetMagickPrecision(),channel_moments[channel].invariant[i]/pow(scale,
386 powers[i]),GetMagickPrecision(),channel_moments[channel].invariant[i]);
390static ssize_t PrintChannelPerceptualHash(Image *image,FILE *file,
391 const ChannelPerceptualHash *channel_phash)
399 (void) FormatLocaleFile(file,
" Channel perceptual hash: ");
400 for (i=0; i < (ssize_t) channel_phash[0].number_colorspaces; i++)
402 (void) FormatLocaleFile(file,
"%s",CommandOptionToMnemonic(
403 MagickColorspaceOptions,(ssize_t) channel_phash[0].colorspace[i]));
404 if (i < (ssize_t) (channel_phash[0].number_colorspaces-1))
405 (void) FormatLocaleFile(file,
", ");
407 (void) FormatLocaleFile(file,
"\n");
409 for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
420 channel=GetPixelChannelChannel(image,i);
421 if (channel == IndexPixelChannel)
423 traits=GetPixelChannelTraits(image,channel);
424 if (traits == UndefinedPixelTrait)
426 n=FormatLocaleFile(file,
" Channel %.17g:\n",(
double) channel);
427 for (j=0; j < MaximumNumberOfPerceptualHashes; j++)
432 n+=FormatLocaleFile(file,
" PH%.17g: ",(
double) j+1);
433 for (k=0; k < (ssize_t) channel_phash[0].number_colorspaces; k++)
435 n+=FormatLocaleFile(file,
"%.*g",GetMagickPrecision(),
436 channel_phash[channel].phash[k][j]);
437 if (k < (ssize_t) (channel_phash[0].number_colorspaces-1))
438 n+=FormatLocaleFile(file,
", ");
440 n+=FormatLocaleFile(file,
"\n");
446static ssize_t PrintChannelStatistics(FILE *file,
const PixelChannel channel,
447 const char *name,
const double scale,
448 const ChannelStatistics *channel_statistics)
450#define StatisticsFormat " %s:\n min: %.*g (%.*g)\n " \
451 "max: %.*g (%.*g)\n mean: %.*g (%.*g)\n median: %.*g (%.*g)\n " \
452 "standard deviation: %.*g (%.*g)\n kurtosis: %.*g\n " \
453 "skewness: %.*g\n entropy: %.*g\n"
458 n=FormatLocaleFile(file,StatisticsFormat,name,GetMagickPrecision(),
459 (
double) ClampToQuantum((MagickRealType) (scale*
460 channel_statistics[channel].minima)),GetMagickPrecision(),
461 channel_statistics[channel].minima/(
double) QuantumRange,
462 GetMagickPrecision(),(
double) ClampToQuantum((MagickRealType) (scale*
463 channel_statistics[channel].maxima)),GetMagickPrecision(),
464 channel_statistics[channel].maxima/(
double) QuantumRange,
465 GetMagickPrecision(),scale*channel_statistics[channel].mean,
466 GetMagickPrecision(),channel_statistics[channel].mean/(
double) QuantumRange,
467 GetMagickPrecision(),scale*channel_statistics[channel].median,
468 GetMagickPrecision(),channel_statistics[channel].median/(
double) QuantumRange,
469 GetMagickPrecision(),scale*channel_statistics[channel].standard_deviation,
470 GetMagickPrecision(),channel_statistics[channel].standard_deviation/
471 (
double) QuantumRange,GetMagickPrecision(),
472 channel_statistics[channel].kurtosis,GetMagickPrecision(),
473 channel_statistics[channel].skewness,GetMagickPrecision(),
474 channel_statistics[channel].entropy);
478MagickExport MagickBooleanType IdentifyImage(Image *image,FILE *file,
479 const MagickBooleanType verbose,ExceptionInfo *exception)
482 buffer[MagickPathExtent],
483 color[MagickPathExtent],
484 key[MagickPathExtent];
492 ChannelPerceptualHash
541 assert(image != (Image *) NULL);
542 assert(image->signature == MagickCoreSignature);
543 if (IsEventLogging() != MagickFalse)
544 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",image->filename);
545 if (file == (FILE *) NULL)
547 colorspace=image->colorspace;
548 locate=GetImageArtifact(image,
"identify:locate");
549 if (locate != (
const char *) NULL)
563 statistic_type=(StatisticType) ParseCommandOption(MagickStatisticOptions,
565 limit=GetImageArtifact(image,
"identify:limit");
567 if (limit != (
const char *) NULL)
568 locations=StringToUnsignedLong(limit);
569 channel_statistics=GetLocationStatistics(image,statistic_type,exception);
570 if (channel_statistics == (ChannelStatistics *) NULL)
572 (void) FormatLocaleFile(file,
"Channel %s locations:\n",locate);
578 if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0)
579 (void) PrintChannelLocations(file,image,RedPixelChannel,
"Red",
580 statistic_type,locations,channel_statistics);
581 if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0)
582 (void) PrintChannelLocations(file,image,GreenPixelChannel,
"Green",
583 statistic_type,locations,channel_statistics);
584 if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0)
585 (void) PrintChannelLocations(file,image,BluePixelChannel,
"Blue",
586 statistic_type,locations,channel_statistics);
591 if ((GetPixelCyanTraits(image) & UpdatePixelTrait) != 0)
592 (void) PrintChannelLocations(file,image,CyanPixelChannel,
"Cyan",
593 statistic_type,locations,channel_statistics);
594 if ((GetPixelMagentaTraits(image) & UpdatePixelTrait) != 0)
595 (void) PrintChannelLocations(file,image,MagentaPixelChannel,
596 "Magenta",statistic_type,locations,channel_statistics);
597 if ((GetPixelYellowTraits(image) & UpdatePixelTrait) != 0)
598 (void) PrintChannelLocations(file,image,YellowPixelChannel,
"Yellow",
599 statistic_type,locations,channel_statistics);
600 if ((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0)
601 (void) PrintChannelLocations(file,image,BlackPixelChannel,
"Black",
602 statistic_type,locations,channel_statistics);
605 case LinearGRAYColorspace:
608 if ((GetPixelGrayTraits(image) & UpdatePixelTrait) != 0)
609 (void) PrintChannelLocations(file,image,GrayPixelChannel,
"Gray",
610 statistic_type,locations,channel_statistics);
615 for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
617 PixelChannel channel = GetPixelChannelChannel(image,i);
618 PixelTrait traits = GetPixelChannelTraits(image,channel);
619 if ((traits & UpdatePixelTrait) != 0)
620 (void) PrintChannelLocations(file,image,channel,
"Channel",
621 statistic_type,locations,channel_statistics);
626 if (image->alpha_trait != UndefinedPixelTrait)
627 (void) PrintChannelLocations(file,image,AlphaPixelChannel,
"Alpha",
628 statistic_type,locations,channel_statistics);
629 channel_statistics=(ChannelStatistics *) RelinquishMagickMemory(
631 return(ferror(file) != 0 ? MagickFalse : MagickTrue);
633 elapsed_time=GetElapsedTime(&image->timer);
634 user_time=GetUserTime(&image->timer);
635 GetTimerInfo(&image->timer);
636 if (verbose == MagickFalse)
641 if (*image->magick_filename !=
'\0')
642 if (LocaleCompare(image->magick_filename,image->filename) != 0)
643 (void) FormatLocaleFile(file,
"%s=>",image->magick_filename);
644 if ((GetPreviousImageInList(image) == (Image *) NULL) &&
645 (GetNextImageInList(image) == (Image *) NULL) &&
647 (void) FormatLocaleFile(file,
"%s ",image->filename);
649 (
void) FormatLocaleFile(file,
"%s[%.17g] ",image->filename,(
double)
651 (void) FormatLocaleFile(file,
"%s ",image->magick);
652 if ((image->magick_columns != 0) || (image->magick_rows != 0))
653 if ((image->magick_columns != image->columns) ||
654 (image->magick_rows != image->rows))
655 (void) FormatLocaleFile(file,
"%.17gx%.17g=>",(
double)
656 image->magick_columns,(
double) image->magick_rows);
657 (void) FormatLocaleFile(file,
"%.17gx%.17g ",(
double) image->columns,
658 (
double) image->rows);
659 if ((image->page.width != 0) || (image->page.height != 0) ||
660 (image->page.x != 0) || (image->page.y != 0))
661 (void) FormatLocaleFile(file,
"%.17gx%.17g%+.20g%+.20g ",(
double)
662 image->page.width,(
double) image->page.height,(
double) image->page.x,
663 (
double) image->page.y);
664 (void) FormatLocaleFile(file,
"%.17g-bit ",(
double) image->depth);
665 if (image->type != UndefinedType)
666 (void) FormatLocaleFile(file,
"%s ",CommandOptionToMnemonic(
667 MagickTypeOptions,(ssize_t) image->type));
668 if (colorspace != UndefinedColorspace)
669 (void) FormatLocaleFile(file,
"%s ",CommandOptionToMnemonic(
670 MagickColorspaceOptions,(ssize_t) colorspace));
671 if (image->storage_class == DirectClass)
673 if (image->total_colors != 0)
675 (void) FormatMagickSize(image->total_colors,MagickFalse,
"B",
676 MagickPathExtent,buffer);
677 (void) FormatLocaleFile(file,
"%s ",buffer);
681 if (image->total_colors <= image->colors)
682 (void) FormatLocaleFile(file,
"%.17gc ",(
double)
685 (
void) FormatLocaleFile(file,
"%.17g=>%.17gc ",(
double)
686 image->total_colors,(
double) image->colors);
687 if (image->error.mean_error_per_pixel != 0.0)
688 (void) FormatLocaleFile(file,
"%.17g/%f/%fdb ",(
double)
689 (image->error.mean_error_per_pixel+0.5),
690 image->error.normalized_mean_error,
691 image->error.normalized_maximum_error);
692 if (image->extent != 0)
694 (void) FormatMagickSize(image->extent,MagickTrue,
"B",
695 MagickPathExtent,buffer);
696 (void) FormatLocaleFile(file,
"%s ",buffer);
698 (void) FormatLocaleFile(file,
"%0.3fu %lu:%02lu.%03lu",user_time,
699 (
unsigned long) (elapsed_time/60.0),(
unsigned long) floor(fmod(
700 elapsed_time,60.0)),(
unsigned long) (1000.0*(elapsed_time-
701 floor(elapsed_time))));
702 (void) FormatLocaleFile(file,
"\n");
704 return(ferror(file) != 0 ? MagickFalse : MagickTrue);
709 p=GetVirtualPixels(image,0,0,1,1,exception);
710 ping=p == (
const Quantum *) NULL ? MagickTrue : MagickFalse;
711 (void) SignatureImage(image,exception);
712 channel_statistics=(ChannelStatistics *) NULL;
713 channel_moments=(ChannelMoments *) NULL;
714 channel_phash=(ChannelPerceptualHash *) NULL;
715 channel_features=(ChannelFeatures *) NULL;
717 if (ping == MagickFalse)
719 depth=GetImageDepth(image,exception);
720 channel_statistics=GetImageStatistics(image,exception);
721 artifact=GetImageArtifact(image,
"identify:moments");
722 if (artifact != (
const char *) NULL)
724 channel_moments=GetImageMoments(image,exception);
725 channel_phash=GetImagePerceptualHash(image,exception);
727 artifact=GetImageArtifact(image,
"identify:features");
728 if (artifact != (
const char *) NULL)
730 distance=StringToUnsignedLong(artifact);
731 channel_features=GetImageFeatures(image,distance,exception);
734 (void) FormatLocaleFile(file,
"Image:\n Filename: %s\n",image->filename);
735 if (*image->magick_filename !=
'\0')
736 if (LocaleCompare(image->magick_filename,image->filename) != 0)
739 filename[MagickPathExtent];
741 GetPathComponent(image->magick_filename,TailPath,filename);
742 (void) FormatLocaleFile(file,
" Base filename: %s\n",filename);
744 properties=(*GetBlobProperties(image));
745 if (properties.st_mode != 0)
747 static const char *rwx[] =
748 {
"---",
"--x",
"-w-",
"-wx",
"r--",
"r-x",
"rw-",
"rwx"};
749 (void) FormatLocaleFile(file,
" Permissions: %s%s%s\n",
750 rwx[(properties.st_mode >> 6) & 0x07],
751 rwx[(properties.st_mode >> 3) & 0x07],
752 rwx[(properties.st_mode >> 0) & 0x07]);
754 magick_info=GetMagickInfo(image->magick,exception);
755 if ((magick_info == (
const MagickInfo *) NULL) ||
756 (GetMagickDescription(magick_info) == (
const char *) NULL))
757 (void) FormatLocaleFile(file,
" Format: %s\n",image->magick);
760 (void) FormatLocaleFile(file,
" Format: %s (%s)\n",image->magick,
761 GetMagickDescription(magick_info));
762 if (GetMagickMimeType(magick_info) != (
const char *) NULL)
763 (void) FormatLocaleFile(file,
" Mime type: %s\n",GetMagickMimeType(
766 (void) FormatLocaleFile(file,
" Class: %s\n",CommandOptionToMnemonic(
767 MagickClassOptions,(ssize_t) image->storage_class));
768 (void) FormatLocaleFile(file,
" Geometry: %.17gx%.17g%+.20g%+.20g\n",(
double)
769 image->columns,(
double) image->rows,(
double) image->tile_offset.x,(
double)
770 image->tile_offset.y);
771 if ((image->magick_columns != 0) || (image->magick_rows != 0))
772 if ((image->magick_columns != image->columns) ||
773 (image->magick_rows != image->rows))
774 (void) FormatLocaleFile(file,
" Base geometry: %.17gx%.17g\n",(
double)
775 image->magick_columns,(
double) image->magick_rows);
776 if ((image->resolution.x != 0.0) && (image->resolution.y != 0.0))
778 (void) FormatLocaleFile(file,
" Resolution: %gx%g\n",image->resolution.x,
779 image->resolution.y);
780 (void) FormatLocaleFile(file,
" Print size: %gx%g\n",(
double)
781 image->columns/image->resolution.x,(
double) image->rows/
782 image->resolution.y);
784 (void) FormatLocaleFile(file,
" Units: %s\n",CommandOptionToMnemonic(
785 MagickResolutionOptions,(ssize_t) image->units));
786 (void) FormatLocaleFile(file,
" Colorspace: %s\n",CommandOptionToMnemonic(
787 MagickColorspaceOptions,(ssize_t) colorspace));
788 type=IdentifyImageType(image,exception);
789 (void) FormatLocaleFile(file,
" Type: %s\n",CommandOptionToMnemonic(
790 MagickTypeOptions,(ssize_t) type));
791 if (image->type != type)
792 (void) FormatLocaleFile(file,
" Base type: %s\n",CommandOptionToMnemonic(
793 MagickTypeOptions,(ssize_t) image->type));
794 (void) FormatLocaleFile(file,
" Endianness: %s\n",CommandOptionToMnemonic(
795 MagickEndianOptions,(ssize_t) image->endian));
798 if (image->depth == depth)
799 (void) FormatLocaleFile(file,
" Depth: %.17g-bit\n",(
double)
802 (
void) FormatLocaleFile(file,
" Depth: %.17g/%.17g-bit\n",(
double)
803 image->depth,(
double) depth);
805 (void) FormatLocaleFile(file,
" Channels: %g.%g\n",(
double)
806 image->number_channels,(
double) image->number_meta_channels);
807 if (channel_statistics != (ChannelStatistics *) NULL)
812 (void) FormatLocaleFile(file,
" Channel depth:\n");
818 if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0)
819 (void) FormatLocaleFile(file,
" Red: %.17g-bit\n",(
double)
820 channel_statistics[RedPixelChannel].depth);
821 if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0)
822 (void) FormatLocaleFile(file,
" Green: %.17g-bit\n",(
double)
823 channel_statistics[GreenPixelChannel].depth);
824 if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0)
825 (void) FormatLocaleFile(file,
" Blue: %.17g-bit\n",(
double)
826 channel_statistics[BluePixelChannel].depth);
831 if ((GetPixelCyanTraits(image) & UpdatePixelTrait) != 0)
832 (void) FormatLocaleFile(file,
" Cyan: %.17g-bit\n",(
double)
833 channel_statistics[CyanPixelChannel].depth);
834 if ((GetPixelMagentaTraits(image) & UpdatePixelTrait) != 0)
835 (void) FormatLocaleFile(file,
" Magenta: %.17g-bit\n",(
double)
836 channel_statistics[MagentaPixelChannel].depth);
837 if ((GetPixelYellowTraits(image) & UpdatePixelTrait) != 0)
838 (void) FormatLocaleFile(file,
" Yellow: %.17g-bit\n",(
double)
839 channel_statistics[YellowPixelChannel].depth);
840 if ((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0)
841 (void) FormatLocaleFile(file,
" Black: %.17g-bit\n",(
double)
842 channel_statistics[BlackPixelChannel].depth);
845 case LinearGRAYColorspace:
848 if ((GetPixelGrayTraits(image) & UpdatePixelTrait) != 0)
849 (void) FormatLocaleFile(file,
" Gray: %.17g-bit\n",(
double)
850 channel_statistics[GrayPixelChannel].depth);
855 for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
857 PixelChannel channel = GetPixelChannelChannel(image,i);
858 PixelTrait traits = GetPixelChannelTraits(image,channel);
859 if ((traits & UpdatePixelTrait) != 0)
860 (void) FormatLocaleFile(file,
" Channel %.17g: %.17g-bit\n",
861 (
double) i,(
double) channel_statistics[channel].depth);
866 if (image->alpha_trait != UndefinedPixelTrait)
867 (void) FormatLocaleFile(file,
" Alpha: %.17g-bit\n",(
double)
868 channel_statistics[AlphaPixelChannel].depth);
869 if ((image->channels & ReadMaskChannel) != 0)
870 (void) FormatLocaleFile(file,
" Read mask: %.17g-bit\n",(
double)
871 channel_statistics[ReadMaskPixelChannel].depth);
872 if ((image->channels & WriteMaskChannel) != 0)
873 (void) FormatLocaleFile(file,
" Write mask: %.17g-bit\n",(
double)
874 channel_statistics[WriteMaskPixelChannel].depth);
875 if ((image->channels & CompositeMaskChannel) != 0)
876 (void) FormatLocaleFile(file,
" Composite mask: %.17g-bit\n",
877 (
double) channel_statistics[CompositeMaskPixelChannel].depth);
878 if (image->number_meta_channels != 0)
879 for (i=0; i < (ssize_t) image->number_meta_channels; i++)
882 channel = (PixelChannel) (MetaPixelChannels+i);
884 (void) FormatLocaleFile(file,
" Meta channel[%.17g]: %.17g-bit\n",
885 (
double) i,(
double) channel_statistics[channel].depth);
888 if (image->depth <= MAGICKCORE_QUANTUM_DEPTH)
889 scale=(double) (QuantumRange/((
size_t) QuantumRange >> ((
size_t)
890 MAGICKCORE_QUANTUM_DEPTH-image->depth)));
891 (void) FormatLocaleFile(file,
" Channel statistics:\n");
892 (void) FormatLocaleFile(file,
" Pixels: %.17g\n",(
double)
893 image->columns*image->rows);
899 if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0)
900 (void) PrintChannelStatistics(file,RedPixelChannel,
"Red",1.0/
901 scale,channel_statistics);
902 if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0)
903 (void) PrintChannelStatistics(file,GreenPixelChannel,
"Green",1.0/
904 scale,channel_statistics);
905 if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0)
906 (void) PrintChannelStatistics(file,BluePixelChannel,
"Blue",1.0/
907 scale,channel_statistics);
912 if ((GetPixelCyanTraits(image) & UpdatePixelTrait) != 0)
913 (void) PrintChannelStatistics(file,CyanPixelChannel,
"Cyan",1.0/
914 scale,channel_statistics);
915 if ((GetPixelMagentaTraits(image) & UpdatePixelTrait) != 0)
916 (void) PrintChannelStatistics(file,MagentaPixelChannel,
"Magenta",
917 1.0/scale,channel_statistics);
918 if ((GetPixelYellowTraits(image) & UpdatePixelTrait) != 0)
919 (void) PrintChannelStatistics(file,YellowPixelChannel,
"Yellow",1.0/
920 scale,channel_statistics);
921 if ((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0)
922 (void) PrintChannelStatistics(file,BlackPixelChannel,
"Black",1.0/
923 scale,channel_statistics);
926 case LinearGRAYColorspace:
929 if ((GetPixelGrayTraits(image) & UpdatePixelTrait) != 0)
930 (void) PrintChannelStatistics(file,GrayPixelChannel,
"Gray",1.0/
931 scale,channel_statistics);
936 for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
939 label[MagickPathExtent];
941 PixelChannel channel = GetPixelChannelChannel(image,i);
942 PixelTrait traits = GetPixelChannelTraits(image,channel);
943 if ((traits & UpdatePixelTrait) != 0)
945 (void) FormatLocaleString(label,MagickPathExtent,
946 "Channel %.17g",(
double) i);
947 (void) PrintChannelStatistics(file,channel,label,1.0/scale,
954 if (image->alpha_trait != UndefinedPixelTrait)
955 (void) PrintChannelStatistics(file,AlphaPixelChannel,
956 "Alpha",1.0/scale,channel_statistics);
957 if ((image->channels & ReadMaskChannel) != 0)
958 (void) PrintChannelStatistics(file,ReadMaskPixelChannel,
959 "Read mask",1.0/scale,channel_statistics);
960 if ((image->channels & WriteMaskChannel) != 0)
961 (void) PrintChannelStatistics(file,WriteMaskPixelChannel,
962 "Write mask",1.0/scale,channel_statistics);
963 if ((image->channels & CompositeMaskChannel) != 0)
964 (void) PrintChannelStatistics(file,WriteMaskPixelChannel,
965 "Composite mask",1.0/scale,channel_statistics);
966 if (image->number_meta_channels != 0)
967 for (i=0; i < (ssize_t) image->number_meta_channels; i++)
970 label[MagickPathExtent];
973 channel = (PixelChannel) (MetaPixelChannels+i);
975 (void) FormatLocaleString(label,MagickPathExtent,
976 "Meta channel[%.17g]",(
double) i);
977 (void) PrintChannelStatistics(file,channel,label,1.0/scale,
980 if ((colorspace != LinearGRAYColorspace) &&
981 (colorspace != GRAYColorspace))
983 (void) FormatLocaleFile(file,
" Image statistics:\n");
984 (void) PrintChannelStatistics(file,CompositePixelChannel,
"Overall",
985 1.0/scale,channel_statistics);
987 channel_statistics=(ChannelStatistics *) RelinquishMagickMemory(
990 if (channel_moments != (ChannelMoments *) NULL)
992 scale=(double) ((1UL << image->depth)-1);
993 (void) FormatLocaleFile(file,
" Channel Hu moments:\n");
999 if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0)
1000 (void) PrintChannelMoments(file,RedPixelChannel,
"Red",scale,
1002 if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0)
1003 (void) PrintChannelMoments(file,GreenPixelChannel,
"Green",scale,
1005 if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0)
1006 (void) PrintChannelMoments(file,BluePixelChannel,
"Blue",scale,
1010 case CMYKColorspace:
1012 if ((GetPixelCyanTraits(image) & UpdatePixelTrait) != 0)
1013 (void) PrintChannelMoments(file,CyanPixelChannel,
"Cyan",scale,
1015 if ((GetPixelMagentaTraits(image) & UpdatePixelTrait) != 0)
1016 (void) PrintChannelMoments(file,MagentaPixelChannel,
"Magenta",scale,
1018 if ((GetPixelYellowTraits(image) & UpdatePixelTrait) != 0)
1019 (void) PrintChannelMoments(file,YellowPixelChannel,
"Yellow",scale,
1021 if ((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0)
1022 (void) PrintChannelMoments(file,BlackPixelChannel,
"Black",scale,
1026 case GRAYColorspace:
1028 if ((GetPixelGrayTraits(image) & UpdatePixelTrait) != 0)
1029 (void) PrintChannelMoments(file,GrayPixelChannel,
"Gray",scale,
1035 for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
1038 label[MagickPathExtent];
1040 PixelChannel channel = GetPixelChannelChannel(image,i);
1041 PixelTrait traits = GetPixelChannelTraits(image,channel);
1042 if ((traits & UpdatePixelTrait) != 0)
1044 (void) FormatLocaleString(label,MagickPathExtent,
1045 "Channel %.17g",(
double) i);
1046 (void) PrintChannelMoments(file,channel,label,scale,
1053 if (image->alpha_trait != UndefinedPixelTrait)
1054 (void) PrintChannelMoments(file,AlphaPixelChannel,
"Alpha",scale,
1056 if (colorspace != GRAYColorspace)
1058 (void) FormatLocaleFile(file,
" Image moments:\n");
1059 (void) PrintChannelMoments(file,CompositePixelChannel,
"Overall",scale,
1062 channel_moments=(ChannelMoments *) RelinquishMagickMemory(
1065 if (channel_phash != (ChannelPerceptualHash *) NULL)
1067 (void) PrintChannelPerceptualHash(image,file,channel_phash);
1068 channel_phash=(ChannelPerceptualHash *) RelinquishMagickMemory(
1071 if (channel_features != (ChannelFeatures *) NULL)
1073 (void) FormatLocaleFile(file,
" Channel features (horizontal, vertical, "
1074 "left and right diagonals, average):\n");
1078 case sRGBColorspace:
1080 if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0)
1081 (void) PrintChannelFeatures(file,RedPixelChannel,
"Red",
1083 if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0)
1084 (void) PrintChannelFeatures(file,GreenPixelChannel,
"Green",
1086 if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0)
1087 (void) PrintChannelFeatures(file,BluePixelChannel,
"Blue",
1091 case CMYKColorspace:
1093 if ((GetPixelCyanTraits(image) & UpdatePixelTrait) != 0)
1094 (void) PrintChannelFeatures(file,CyanPixelChannel,
"Cyan",
1096 if ((GetPixelMagentaTraits(image) & UpdatePixelTrait) != 0)
1097 (void) PrintChannelFeatures(file,MagentaPixelChannel,
"Magenta",
1099 if ((GetPixelYellowTraits(image) & UpdatePixelTrait) != 0)
1100 (void) PrintChannelFeatures(file,YellowPixelChannel,
"Yellow",
1102 if ((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0)
1103 (void) PrintChannelFeatures(file,BlackPixelChannel,
"Black",
1107 case GRAYColorspace:
1109 if ((GetPixelGrayTraits(image) & UpdatePixelTrait) != 0)
1110 (void) PrintChannelFeatures(file,GrayPixelChannel,
"Gray",
1116 for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
1119 label[MagickPathExtent];
1121 PixelChannel channel = GetPixelChannelChannel(image,i);
1122 PixelTrait traits = GetPixelChannelTraits(image,channel);
1123 if ((traits & UpdatePixelTrait) != 0)
1125 (void) FormatLocaleString(label,MagickPathExtent,
1126 "Channel %.17g",(
double) i);
1127 (void) PrintChannelFeatures(file,channel,label,
1134 if (image->alpha_trait != UndefinedPixelTrait)
1135 (void) PrintChannelFeatures(file,AlphaPixelChannel,
"Alpha",
1137 channel_features=(ChannelFeatures *) RelinquishMagickMemory(
1140 if (ping == MagickFalse)
1142 if (colorspace == CMYKColorspace)
1143 (void) FormatLocaleFile(file,
" Total ink density: %.*g%%\n",
1144 GetMagickPrecision(),100.0*GetImageTotalInkDensity(image,exception)/
1145 (
double) QuantumRange);
1147 if (image->alpha_trait != UndefinedPixelTrait)
1150 found = MagickFalse;
1152 p=(
const Quantum *) NULL;
1153 for (y=0; y < (ssize_t) image->rows; y++)
1155 p=GetVirtualPixels(image,0,y,image->columns,1,exception);
1156 if (p == (
const Quantum *) NULL)
1158 for (x=0; x < (ssize_t) image->columns; x++)
1160 if (GetPixelAlpha(image,p) == (Quantum) TransparentAlpha)
1165 p+=(ptrdiff_t) GetPixelChannels(image);
1167 if (found != MagickFalse)
1170 if (found != MagickFalse)
1173 tuple[MagickPathExtent];
1178 GetPixelInfo(image,&pixel);
1179 GetPixelInfoPixel(image,p,&pixel);
1180 (void) QueryColorname(image,&pixel,SVGCompliance,tuple,
1182 (void) FormatLocaleFile(file,
" Alpha: %s ",tuple);
1183 GetColorTuple(&pixel,MagickTrue,tuple);
1184 (void) FormatLocaleFile(file,
" %s\n",tuple);
1187 if (IsHistogramImage(image,exception) != MagickFalse)
1189 (void) FormatLocaleFile(file,
" Colors: %.17g\n",(
double)
1190 GetNumberColors(image,(FILE *) NULL,exception));
1191 (void) FormatLocaleFile(file,
" Histogram:\n");
1192 (void) GetNumberColors(image,file,exception);
1196 artifact=GetImageArtifact(image,
"identify:unique-colors");
1197 if (IsStringTrue(artifact) != MagickFalse)
1198 (void) FormatLocaleFile(file,
" Colors: %.17g\n",(
double)
1199 GetNumberColors(image,(FILE *) NULL,exception));
1202 if (image->storage_class == PseudoClass)
1204 (void) FormatLocaleFile(file,
" Colormap entries: %.17g\n",(
double)
1206 (void) FormatLocaleFile(file,
" Colormap:\n");
1207 if (image->colors <= 1024)
1210 hex[MagickPathExtent],
1211 tuple[MagickPathExtent];
1219 GetPixelInfo(image,&pixel);
1221 for (i=0; i < (ssize_t) image->colors; i++)
1224 (void) CopyMagickString(tuple,
"(",MagickPathExtent);
1225 ConcatenateColorComponent(&pixel,RedPixelChannel,X11Compliance,
1227 (void) ConcatenateMagickString(tuple,
",",MagickPathExtent);
1228 ConcatenateColorComponent(&pixel,GreenPixelChannel,X11Compliance,
1230 (void) ConcatenateMagickString(tuple,
",",MagickPathExtent);
1231 ConcatenateColorComponent(&pixel,BluePixelChannel,X11Compliance,
1233 if (pixel.colorspace == CMYKColorspace)
1235 (void) ConcatenateMagickString(tuple,
",",MagickPathExtent);
1236 ConcatenateColorComponent(&pixel,BlackPixelChannel,
1237 X11Compliance,tuple);
1239 if (pixel.alpha_trait != UndefinedPixelTrait)
1241 (void) ConcatenateMagickString(tuple,
",",MagickPathExtent);
1242 ConcatenateColorComponent(&pixel,AlphaPixelChannel,
1243 X11Compliance,tuple);
1245 (void) ConcatenateMagickString(tuple,
")",MagickPathExtent);
1246 (void) QueryColorname(image,&pixel,SVGCompliance,color,
1248 GetColorTuple(&pixel,MagickTrue,hex);
1249 (void) FormatLocaleFile(file,
" %g: %s %s %s\n",(
double) i,tuple,
1255 if (image->error.mean_error_per_pixel != 0.0)
1256 (void) FormatLocaleFile(file,
" Mean error per pixel: %g\n",
1257 image->error.mean_error_per_pixel);
1258 if (image->error.normalized_mean_error != 0.0)
1259 (void) FormatLocaleFile(file,
" Normalized mean error: %g\n",
1260 image->error.normalized_mean_error);
1261 if (image->error.normalized_maximum_error != 0.0)
1262 (void) FormatLocaleFile(file,
" Normalized maximum error: %g\n",
1263 image->error.normalized_maximum_error);
1264 (void) FormatLocaleFile(file,
" Rendering intent: %s\n",
1265 CommandOptionToMnemonic(MagickIntentOptions,(ssize_t)
1266 image->rendering_intent));
1267 if (image->gamma != 0.0)
1268 (void) FormatLocaleFile(file,
" Gamma: %g\n",image->gamma);
1269 if ((image->chromaticity.red_primary.x != 0.0) ||
1270 (image->chromaticity.green_primary.x != 0.0) ||
1271 (image->chromaticity.blue_primary.x != 0.0) ||
1272 (image->chromaticity.white_point.x != 0.0))
1277 (void) FormatLocaleFile(file,
" Chromaticity:\n");
1278 (void) FormatLocaleFile(file,
" red primary: (%g,%g,%g)\n",
1279 image->chromaticity.red_primary.x,image->chromaticity.red_primary.y,
1280 image->chromaticity.red_primary.z);
1281 (void) FormatLocaleFile(file,
" green primary: (%g,%g,%g)\n",
1282 image->chromaticity.green_primary.x,image->chromaticity.green_primary.y,
1283 image->chromaticity.green_primary.z);
1284 (void) FormatLocaleFile(file,
" blue primary: (%g,%g,%g)\n",
1285 image->chromaticity.blue_primary.x,image->chromaticity.blue_primary.y,
1286 image->chromaticity.blue_primary.z);
1287 (void) FormatLocaleFile(file,
" white point: (%g,%g,%g)\n",
1288 image->chromaticity.white_point.x,image->chromaticity.white_point.y,
1289 image->chromaticity.white_point.z);
1291 if ((image->extract_info.width*image->extract_info.height) != 0)
1292 (void) FormatLocaleFile(file,
" Tile geometry: %.17gx%.17g%+.20g%+.20g\n",
1293 (
double) image->extract_info.width,(
double) image->extract_info.height,
1294 (
double) image->extract_info.x,(
double) image->extract_info.y);
1295 (void) QueryColorname(image,&image->matte_color,SVGCompliance,color,
1297 (void) FormatLocaleFile(file,
" Matte color: %s\n",color);
1298 (void) QueryColorname(image,&image->background_color,SVGCompliance,color,
1300 (void) FormatLocaleFile(file,
" Background color: %s\n",color);
1301 (void) QueryColorname(image,&image->border_color,SVGCompliance,color,
1303 (void) FormatLocaleFile(file,
" Border color: %s\n",color);
1304 (void) QueryColorname(image,&image->transparent_color,SVGCompliance,color,
1306 (void) FormatLocaleFile(file,
" Transparent color: %s\n",color);
1307 (void) FormatLocaleFile(file,
" Interlace: %s\n",CommandOptionToMnemonic(
1308 MagickInterlaceOptions,(ssize_t) image->interlace));
1309 (void) FormatLocaleFile(file,
" Intensity: %s\n",CommandOptionToMnemonic(
1310 MagickPixelIntensityOptions,(ssize_t) image->intensity));
1311 (void) FormatLocaleFile(file,
" Compose: %s\n",CommandOptionToMnemonic(
1312 MagickComposeOptions,(ssize_t) image->compose));
1313 if ((image->page.width != 0) || (image->page.height != 0) ||
1314 (image->page.x != 0) || (image->page.y != 0))
1315 (void) FormatLocaleFile(file,
" Page geometry: %.17gx%.17g%+.20g%+.20g\n",
1316 (
double) image->page.width,(
double) image->page.height,(
double)
1317 image->page.x,(
double) image->page.y);
1318 if ((image->page.x != 0) || (image->page.y != 0))
1319 (void) FormatLocaleFile(file,
" Origin geometry: %+.20g%+.20g\n",(
double)
1320 image->page.x,(
double) image->page.y);
1321 (void) FormatLocaleFile(file,
" Dispose: %s\n",CommandOptionToMnemonic(
1322 MagickDisposeOptions,(ssize_t) image->dispose));
1323 if (image->delay != 0)
1324 (void) FormatLocaleFile(file,
" Delay: %.17gx%.17g\n",(
double) image->delay,
1325 (
double) image->ticks_per_second);
1326 if (image->iterations != 1)
1327 (void) FormatLocaleFile(file,
" Iterations: %.17g\n",(
double)
1329 if (image->duration != 0)
1330 (void) FormatLocaleFile(file,
" Duration: %.17g\n",(
double)
1332 if ((image->next != (Image *) NULL) || (image->previous != (Image *) NULL))
1333 (void) FormatLocaleFile(file,
" Scene: %.17g of %.17g\n",(
double)
1334 image->scene,(
double) GetImageListLength(image));
1336 if (image->scene != 0)
1337 (void) FormatLocaleFile(file,
" Scene: %.17g\n",(
double) image->scene);
1338 (void) FormatLocaleFile(file,
" Compression: %s\n",CommandOptionToMnemonic(
1339 MagickCompressOptions,(ssize_t) image->compression));
1340 if (image->quality != UndefinedCompressionQuality)
1341 (void) FormatLocaleFile(file,
" Quality: %.17g\n",(
double) image->quality);
1342 (void) FormatLocaleFile(file,
" Orientation: %s\n",CommandOptionToMnemonic(
1343 MagickOrientationOptions,(ssize_t) image->orientation));
1344 if (image->montage != (
char *) NULL)
1345 (void) FormatLocaleFile(file,
" Montage: %s\n",image->montage);
1346 if (image->directory != (
char *) NULL)
1364 image_info=AcquireImageInfo();
1365 (void) CloneString(&image_info->size,
"64x64");
1366 (void) FormatLocaleFile(file,
" Directory:\n");
1367 for (d=image->directory; *d !=
'\0'; d++)
1370 while ((*q !=
'\xff') && (*q !=
'\0') &&
1371 ((
size_t) (q-d+1) <
sizeof(image_info->filename)))
1373 (void) CopyMagickString(image_info->filename,d,(
size_t) (q-d+1));
1375 (void) FormatLocaleFile(file,
" %s",image_info->filename);
1376 handler=SetWarningHandler((WarningHandler) NULL);
1377 tile=StrictReadImage(image_info,exception);
1378 (void) SetWarningHandler(handler);
1379 if (tile == (Image *) NULL)
1381 (void) FormatLocaleFile(file,
"\n");
1384 (void) FormatLocaleFile(file,
" %.17gx%.17g %s\n",(
double)
1385 tile->magick_columns,(
double) tile->magick_rows,tile->magick);
1386 (void) SignatureImage(tile,exception);
1387 ResetImagePropertyIterator(tile);
1388 property=GetNextImageProperty(tile);
1389 while (property != (
const char *) NULL)
1391 (void) FormatLocaleFile(file,
" %s:\n",property);
1392 value=GetImageProperty(tile,property,exception);
1393 if (value != (
const char *) NULL)
1394 (void) FormatLocaleFile(file,
"%s\n",value);
1395 property=GetNextImageProperty(tile);
1397 tile=DestroyImage(tile);
1399 image_info=DestroyImageInfo(image_info);
1401 (void) FormatLocaleString(key,MagickPathExtent,
"8BIM:1999,2998:#1");
1402 value=GetImageProperty(image,key,exception);
1403 if (value != (
const char *) NULL)
1408 (void) FormatLocaleFile(file,
" Clipping path: ");
1409 if (strlen(value) > 80)
1410 (void) fputc(
'\n',file);
1411 (void) FormatLocaleFile(file,
"%s\n",value);
1413 artifact=GetImageArtifact(image,
"identify:convex-hull");
1414 if (IsStringTrue(artifact) != MagickFalse)
1432 convex_hull=GetImageConvexHull(image,&number_points,exception);
1433 if (convex_hull != (PointInfo *) NULL)
1435 points=AcquireString(
"");
1436 for (n=0; n < (ssize_t) number_points; n++)
1438 (void) FormatLocaleString(buffer,MagickPathExtent,
"%g,%g ",
1439 convex_hull[n].x,convex_hull[n].y);
1440 (void) ConcatenateString(&points,buffer);
1442 convex_hull=(PointInfo *) RelinquishMagickMemory(convex_hull);
1443 (void) FormatLocaleFile(file,
" Convex hull: ");
1444 (void) FormatLocaleFile(file,
"%s\n",points);
1445 points=DestroyString(points);
1447 bounding_box=GetImageMinimumBoundingBox(image,&number_points,exception);
1448 if (bounding_box != (PointInfo *) NULL)
1450 points=AcquireString(
"");
1451 for (n=0; n < (ssize_t) number_points; n++)
1453 (void) FormatLocaleString(buffer,MagickPathExtent,
"%g,%g ",
1454 bounding_box[n].x,bounding_box[n].y);
1455 (void) ConcatenateString(&points,buffer);
1457 bounding_box=(PointInfo *) RelinquishMagickMemory(bounding_box);
1458 (void) FormatLocaleFile(file,
" Minimum bounding box: ");
1459 (void) FormatLocaleFile(file,
"%s\n",points);
1460 points=DestroyString(points);
1463 ResetImageProfileIterator(image);
1464 name=GetNextImageProfile(image);
1465 if (name != (
char *) NULL)
1473 (void) FormatLocaleFile(file,
" Profiles:\n");
1474 while (name != (
char *) NULL)
1476 profile=GetImageProfile(image,name);
1477 if (profile == (StringInfo *) NULL)
1479 (void) FormatLocaleFile(file,
" Profile-%s: %.17g bytes\n",name,
1480 (
double) GetStringInfoLength(profile));
1481 if (LocaleCompare(name,
"iptc") == 0)
1502 profile_length=GetStringInfoLength(profile);
1503 for (i=0; i < (ssize_t) profile_length-5; i+=(ssize_t) length)
1506 sentinel=GetStringInfoDatum(profile)[i++];
1507 if (sentinel != 0x1c)
1509 dataset=GetStringInfoDatum(profile)[i++];
1510 record=GetStringInfoDatum(profile)[i++];
1513 case 5: tag=
"Image Name";
break;
1514 case 7: tag=
"Edit Status";
break;
1515 case 10: tag=
"Priority";
break;
1516 case 15: tag=
"Category";
break;
1517 case 20: tag=
"Supplemental Category";
break;
1518 case 22: tag=
"Fixture Identifier";
break;
1519 case 25: tag=
"Keyword";
break;
1520 case 30: tag=
"Release Date";
break;
1521 case 35: tag=
"Release Time";
break;
1522 case 40: tag=
"Special Instructions";
break;
1523 case 45: tag=
"Reference Service";
break;
1524 case 47: tag=
"Reference Date";
break;
1525 case 50: tag=
"Reference Number";
break;
1526 case 55: tag=
"Created Date";
break;
1527 case 60: tag=
"Created Time";
break;
1528 case 65: tag=
"Originating Program";
break;
1529 case 70: tag=
"Program Version";
break;
1530 case 75: tag=
"Object Cycle";
break;
1531 case 80: tag=
"Byline";
break;
1532 case 85: tag=
"Byline Title";
break;
1533 case 90: tag=
"City";
break;
1534 case 92: tag=
"Sub-Location";
break;
1535 case 95: tag=
"Province State";
break;
1536 case 100: tag=
"Country Code";
break;
1537 case 101: tag=
"Country";
break;
1538 case 103: tag=
"Original Transmission Reference";
break;
1539 case 105: tag=
"Headline";
break;
1540 case 110: tag=
"Credit";
break;
1541 case 115: tag=
"Src";
break;
1542 case 116: tag=
"Copyright String";
break;
1543 case 120: tag=
"Caption";
break;
1544 case 121: tag=
"Local Caption";
break;
1545 case 122: tag=
"Caption Writer";
break;
1546 case 200: tag=
"Custom Field 1";
break;
1547 case 201: tag=
"Custom Field 2";
break;
1548 case 202: tag=
"Custom Field 3";
break;
1549 case 203: tag=
"Custom Field 4";
break;
1550 case 204: tag=
"Custom Field 5";
break;
1551 case 205: tag=
"Custom Field 6";
break;
1552 case 206: tag=
"Custom Field 7";
break;
1553 case 207: tag=
"Custom Field 8";
break;
1554 case 208: tag=
"Custom Field 9";
break;
1555 case 209: tag=
"Custom Field 10";
break;
1556 case 210: tag=
"Custom Field 11";
break;
1557 case 211: tag=
"Custom Field 12";
break;
1558 case 212: tag=
"Custom Field 13";
break;
1559 case 213: tag=
"Custom Field 14";
break;
1560 case 214: tag=
"Custom Field 15";
break;
1561 case 215: tag=
"Custom Field 16";
break;
1562 case 216: tag=
"Custom Field 17";
break;
1563 case 217: tag=
"Custom Field 18";
break;
1564 case 218: tag=
"Custom Field 19";
break;
1565 case 219: tag=
"Custom Field 20";
break;
1566 default: tag=
"unknown";
break;
1568 (void) FormatLocaleFile(file,
" %s[%.17g,%.17g]: ",tag,
1569 (
double) dataset,(
double) record);
1570 length=(size_t) (GetStringInfoDatum(profile)[i++] << 8);
1571 length|=GetStringInfoDatum(profile)[i++];
1572 length=MagickMin(length,profile_length-(
size_t) i);
1573 attribute=(
char *) NULL;
1574 if (~length >= (MagickPathExtent-1))
1575 attribute=(
char *) AcquireQuantumMemory(length+MagickPathExtent,
1576 sizeof(*attribute));
1577 if (attribute != (
char *) NULL)
1579 (void) CopyMagickString(attribute,(
char *)
1580 GetStringInfoDatum(profile)+i,length+1);
1581 attribute_list=StringToList(attribute);
1582 if (attribute_list != (
char **) NULL)
1584 for (j=0; attribute_list[j] != (
char *) NULL; j++)
1586 (void) fputs(attribute_list[j],file);
1587 (void) fputs(
"\n",file);
1588 attribute_list[j]=(
char *) RelinquishMagickMemory(
1591 attribute_list=(
char **) RelinquishMagickMemory(
1594 attribute=DestroyString(attribute);
1598 if (image->debug != MagickFalse)
1599 PrintStringInfo(file,name,profile);
1600 name=GetNextImageProfile(image);
1603 ResetImagePropertyIterator(image);
1604 property=GetNextImageProperty(image);
1605 if (property != (
const char *) NULL)
1610 (void) FormatLocaleFile(file,
" Properties:\n");
1611 while (property != (
const char *) NULL)
1613 (void) FormatLocaleFile(file,
" %s: ",property);
1614 value=GetImageProperty(image,property,exception);
1615 if (value != (
const char *) NULL)
1616 (void) FormatLocaleFile(file,
"%s\n",value);
1617 property=GetNextImageProperty(image);
1620 ResetImageArtifactIterator(image);
1621 artifact=GetNextImageArtifact(image);
1622 if (artifact != (
const char *) NULL)
1627 (void) FormatLocaleFile(file,
" Artifacts:\n");
1628 while (artifact != (
const char *) NULL)
1630 (void) FormatLocaleFile(file,
" %s: ",artifact);
1631 value=GetImageArtifact(image,artifact);
1632 if (value != (
const char *) NULL)
1633 (void) FormatLocaleFile(file,
"%s\n",value);
1634 artifact=GetNextImageArtifact(image);
1637 ResetImageRegistryIterator();
1638 registry=GetNextImageRegistry();
1639 if (registry != (
const char *) NULL)
1644 (void) FormatLocaleFile(file,
" Registry:\n");
1645 while (registry != (
const char *) NULL)
1647 (void) FormatLocaleFile(file,
" %s: ",registry);
1648 value=(
const char *) GetImageRegistry(StringRegistryType,registry,
1650 if (value != (
const char *) NULL)
1651 (void) FormatLocaleFile(file,
"%s\n",value);
1652 registry=GetNextImageRegistry();
1655 (void) FormatLocaleFile(file,
" Tainted: %s\n",CommandOptionToMnemonic(
1656 MagickBooleanOptions,(ssize_t) image->taint));
1657 (void) FormatMagickSize(image->extent,MagickTrue,
"B",MagickPathExtent,buffer);
1658 (void) FormatLocaleFile(file,
" Filesize: %s\n",buffer);
1659 (void) FormatMagickSize((MagickSizeType) image->columns*image->rows,
1660 MagickFalse,
"P",MagickPathExtent,buffer);
1661 if (strlen(buffer) > 1)
1662 buffer[strlen(buffer)-1]=
'\0';
1663 (void) FormatLocaleFile(file,
" Number pixels: %s\n",buffer);
1664 (void) FormatLocaleString(buffer,MagickPathExtent,
"%s",
1665 CommandOptionToMnemonic(MagickCacheOptions,(ssize_t)
1666 GetImagePixelCacheType(image)));
1667 (void) FormatLocaleFile(file,
" Pixel cache type: %s\n",buffer);
1668 if (elapsed_time > MagickEpsilon)
1670 (void) FormatMagickSize((MagickSizeType) ((
double) image->columns*
1671 image->rows/elapsed_time+0.5),MagickFalse,
"P",MagickPathExtent,buffer);
1672 (void) FormatLocaleFile(file,
" Pixels per second: %s\n",buffer);
1674 if (image->ttl != (time_t) 0)
1677 iso8601[
sizeof(
"9999-99-99T99:99:99Z")];
1685 (void) GetMagickUTCTime(&image->ttl,×tamp);
1686 (void) strftime(iso8601,
sizeof(iso8601),
"%Y-%m-%dT%H:%M:%SZ",×tamp);
1687 seconds=MagickMax((
int)(image->ttl-GetMagickTime()),0);
1691 (void) FormatLocaleFile(file,
" Time-to-live: %g:%02g:%02g:%02g%c %s\n",
1692 ceil((
double) (seconds/(3600*24))),
1693 ceil((
double) ((seconds % (24*3600))/3600)),
1694 ceil((
double) ((seconds % 3600)/60)),
1695 ceil((
double) ((seconds % 3600) % 60)),expired,iso8601);
1697 (void) FormatLocaleFile(file,
" User time: %0.3fu\n",user_time);
1698 (void) FormatLocaleFile(file,
" Elapsed time: %lu:%02lu.%03lu\n",
1699 (
unsigned long) (elapsed_time/60.0),(
unsigned long) ceil(fmod(elapsed_time,
1700 60.0)),(
unsigned long) (1000.0*(elapsed_time-floor(elapsed_time))));
1701 (void) FormatLocaleFile(file,
" Version: %s\n",GetMagickVersion((
size_t *)
1703 (void) fflush(file);
1704 return(ferror(file) != 0 ? MagickFalse : MagickTrue);