2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
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 %
13 % Identify an Image Format and Characteristics. %
20 % Copyright 1999-2014 ImageMagick Studio LLC, a non-profit organization %
21 % dedicated to making software imaging solutions freely available. %
23 % You may not use this file except in compliance with the License. You may %
24 % obtain a copy of the License at %
26 % http://www.imagemagick.org/script/license.php %
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. %
34 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
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.
45 #include "MagickCore/studio.h"
46 #include "MagickCore/annotate.h"
47 #include "MagickCore/artifact.h"
48 #include "MagickCore/attribute.h"
49 #include "MagickCore/blob.h"
50 #include "MagickCore/cache.h"
51 #include "MagickCore/client.h"
52 #include "MagickCore/coder.h"
53 #include "MagickCore/color.h"
54 #include "MagickCore/configure.h"
55 #include "MagickCore/constitute.h"
56 #include "MagickCore/decorate.h"
57 #include "MagickCore/delegate.h"
58 #include "MagickCore/draw.h"
59 #include "MagickCore/effect.h"
60 #include "MagickCore/exception.h"
61 #include "MagickCore/exception-private.h"
62 #include "MagickCore/feature.h"
63 #include "MagickCore/gem.h"
64 #include "MagickCore/geometry.h"
65 #include "MagickCore/histogram.h"
66 #include "MagickCore/identify.h"
67 #include "MagickCore/image.h"
68 #include "MagickCore/image-private.h"
69 #include "MagickCore/list.h"
70 #include "MagickCore/locale_.h"
71 #include "MagickCore/log.h"
72 #include "MagickCore/magic.h"
73 #include "MagickCore/magick.h"
74 #include "MagickCore/memory_.h"
75 #include "MagickCore/module.h"
76 #include "MagickCore/monitor.h"
77 #include "MagickCore/montage.h"
78 #include "MagickCore/option.h"
79 #include "MagickCore/pixel-accessor.h"
80 #include "MagickCore/prepress.h"
81 #include "MagickCore/profile.h"
82 #include "MagickCore/property.h"
83 #include "MagickCore/quantize.h"
84 #include "MagickCore/quantum.h"
85 #include "MagickCore/random_.h"
86 #include "MagickCore/registry.h"
87 #include "MagickCore/resize.h"
88 #include "MagickCore/resource_.h"
89 #include "MagickCore/signature.h"
90 #include "MagickCore/statistic.h"
91 #include "MagickCore/string_.h"
92 #include "MagickCore/string-private.h"
93 #include "MagickCore/timer.h"
94 #include "MagickCore/token.h"
95 #include "MagickCore/utility.h"
96 #include "MagickCore/utility-private.h"
97 #include "MagickCore/version.h"
98 #if defined(MAGICKCORE_LCMS_DELEGATE)
99 #if defined(MAGICKCORE_HAVE_LCMS_LCMS2_H)
100 #include <lcms/lcms2.h>
101 #elif defined(MAGICKCORE_HAVE_LCMS2_H)
103 #elif defined(MAGICKCORE_HAVE_LCMS_LCMS_H)
104 #include <lcms/lcms.h>
113 #if defined(MAGICKCORE_LCMS_DELEGATE)
114 #if defined(LCMS_VERSION) && (LCMS_VERSION < 2000)
115 #define cmsUInt32Number DWORD
120 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
124 % I d e n t i f y I m a g e %
128 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
130 % IdentifyImage() identifies an image by printing its attributes to the file.
131 % Attributes include the image width, height, size, and others.
133 % The format of the IdentifyImage method is:
135 % MagickBooleanType IdentifyImage(Image *image,FILE *file,
136 % const MagickBooleanType verbose,ExceptionInfo *exception)
138 % A description of each parameter follows:
140 % o image: the image.
142 % o file: the file, typically stdout.
144 % o verbose: A value other than zero prints more detailed information
147 % o exception: return any errors or warnings in this structure.
151 static ChannelStatistics *GetLocationStatistics(const Image *image,
152 const StatisticType type,ExceptionInfo *exception)
163 assert(image != (Image *) NULL);
164 assert(image->signature == MagickSignature);
165 if (image->debug != MagickFalse)
166 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
167 channel_statistics=(ChannelStatistics *) AcquireQuantumMemory(
168 MaxPixelChannels+1,sizeof(*channel_statistics));
169 if (channel_statistics == (ChannelStatistics *) NULL)
170 ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed");
171 (void) ResetMagickMemory(channel_statistics,0,(MaxPixelChannels+1)*
172 sizeof(*channel_statistics));
173 for (i=0; i <= (ssize_t) MaxPixelChannels; i++)
177 case MaximumStatistic:
180 channel_statistics[i].maxima=(-MagickHuge);
183 case MinimumStatistic:
185 channel_statistics[i].minima=MagickHuge;
190 for (y=0; y < (ssize_t) image->rows; y++)
192 register const Quantum
198 p=GetVirtualPixels(image,0,y,image->columns,1,exception);
199 if (p == (const Quantum *) NULL)
201 for (x=0; x < (ssize_t) image->columns; x++)
206 if (GetPixelReadMask(image,p) == 0)
208 p+=GetPixelChannels(image);
211 for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
213 PixelChannel channel=GetPixelChannelChannel(image,i);
214 PixelTrait traits=GetPixelChannelTraits(image,channel);
215 if (traits == UndefinedPixelTrait)
219 case MaximumStatistic:
222 if ((double) p[i] > channel_statistics[channel].maxima)
223 channel_statistics[channel].maxima=(double) p[i];
226 case MinimumStatistic:
228 if ((double) p[i] < channel_statistics[channel].minima)
229 channel_statistics[channel].minima=(double) p[i];
234 p+=GetPixelChannels(image);
237 return(channel_statistics);
240 static ssize_t PrintChannelFeatures(FILE *file,const PixelChannel channel,
241 const char *name,const ChannelFeatures *channel_features)
243 #define PrintFeature(feature) \
244 GetMagickPrecision(),(feature)[0], \
245 GetMagickPrecision(),(feature)[1], \
246 GetMagickPrecision(),(feature)[2], \
247 GetMagickPrecision(),(feature)[3], \
248 GetMagickPrecision(),((feature)[0]+(feature)[1]+(feature)[2]+(feature)[3])/4.0 \
250 #define FeaturesFormat " %s:\n" \
251 " Angular Second Moment:\n" \
252 " %.*g, %.*g, %.*g, %.*g, %.*g\n" \
254 " %.*g, %.*g, %.*g, %.*g, %.*g\n" \
256 " %.*g, %.*g, %.*g, %.*g, %.*g\n" \
257 " Sum of Squares: Variance:\n" \
258 " %.*g, %.*g, %.*g, %.*g, %.*g\n" \
259 " Inverse Difference Moment:\n" \
260 " %.*g, %.*g, %.*g, %.*g, %.*g\n" \
262 " %.*g, %.*g, %.*g, %.*g, %.*g\n" \
264 " %.*g, %.*g, %.*g, %.*g, %.*g\n" \
266 " %.*g, %.*g, %.*g, %.*g, %.*g\n" \
268 " %.*g, %.*g, %.*g, %.*g, %.*g\n" \
269 " Difference Variance:\n" \
270 " %.*g, %.*g, %.*g, %.*g, %.*g\n" \
271 " Difference Entropy:\n" \
272 " %.*g, %.*g, %.*g, %.*g, %.*g\n" \
273 " Information Measure of Correlation 1:\n" \
274 " %.*g, %.*g, %.*g, %.*g, %.*g\n" \
275 " Information Measure of Correlation 2:\n" \
276 " %.*g, %.*g, %.*g, %.*g, %.*g\n" \
277 " Maximum Correlation Coefficient:\n" \
278 " %.*g, %.*g, %.*g, %.*g, %.*g\n"
283 n=FormatLocaleFile(file,FeaturesFormat,name,
284 PrintFeature(channel_features[channel].angular_second_moment),
285 PrintFeature(channel_features[channel].contrast),
286 PrintFeature(channel_features[channel].correlation),
287 PrintFeature(channel_features[channel].variance_sum_of_squares),
288 PrintFeature(channel_features[channel].inverse_difference_moment),
289 PrintFeature(channel_features[channel].sum_average),
290 PrintFeature(channel_features[channel].sum_variance),
291 PrintFeature(channel_features[channel].sum_entropy),
292 PrintFeature(channel_features[channel].entropy),
293 PrintFeature(channel_features[channel].difference_variance),
294 PrintFeature(channel_features[channel].difference_entropy),
295 PrintFeature(channel_features[channel].measure_of_correlation_1),
296 PrintFeature(channel_features[channel].measure_of_correlation_2),
297 PrintFeature(channel_features[channel].maximum_correlation_coefficient));
301 static ssize_t PrintChannelLocations(FILE *file,const Image *image,
302 const PixelChannel channel,const char *name,const StatisticType type,
303 const size_t max_locations,const ChannelStatistics *channel_statistics)
317 case MaximumStatistic:
320 target=channel_statistics[channel].maxima;
323 case MinimumStatistic:
325 target=channel_statistics[channel].minima;
329 (void) FormatLocaleFile(file," %s: %.*g (%.*g)",name,GetMagickPrecision(),
330 target,GetMagickPrecision(),QuantumScale*target);
331 exception=AcquireExceptionInfo();
333 for (y=0; y < (ssize_t) image->rows; y++)
335 register const Quantum
342 p=GetVirtualPixels(image,0,y,image->columns,1,exception);
343 if (p == (const Quantum *) NULL)
345 for (x=0; x < (ssize_t) image->columns; x++)
350 PixelTrait traits=GetPixelChannelTraits(image,channel);
351 if (traits == UndefinedPixelTrait)
353 offset=GetPixelChannelOffset(image,channel);
354 match=fabs((double) p[offset]-target) < 0.5 ? MagickTrue : MagickFalse;
355 if (match != MagickFalse)
357 if ((max_locations != 0) && (n >= max_locations))
359 (void) FormatLocaleFile(file," %.20g,%.20g",(double) x,(double) y);
362 p+=GetPixelChannels(image);
364 if (x < (ssize_t) image->columns)
367 (void) FormatLocaleFile(file,"\n");
371 static ssize_t PrintChannelStatistics(FILE *file,const PixelChannel channel,
372 const char *name,const double scale,
373 const ChannelStatistics *channel_statistics)
375 #define StatisticsFormat " %s:\n min: " QuantumFormat \
376 " (%g)\n max: " QuantumFormat " (%g)\n" \
377 " mean: %g (%g)\n standard deviation: %g (%g)\n" \
378 " kurtosis: %g\n skewness: %g\n"
383 n=FormatLocaleFile(file,StatisticsFormat,name,ClampToQuantum(scale*
384 channel_statistics[channel].minima),channel_statistics[channel].minima/
385 (double) QuantumRange,ClampToQuantum(scale*
386 channel_statistics[channel].maxima),channel_statistics[channel].maxima/
387 (double) QuantumRange,scale*channel_statistics[channel].mean,
388 channel_statistics[channel].mean/(double) QuantumRange,scale*
389 channel_statistics[channel].standard_deviation,
390 channel_statistics[channel].standard_deviation/(double) QuantumRange,
391 channel_statistics[channel].kurtosis,channel_statistics[channel].skewness);
395 MagickExport MagickBooleanType IdentifyImage(Image *image,FILE *file,
396 const MagickBooleanType verbose,ExceptionInfo *exception)
399 color[MaxTextExtent],
400 format[MaxTextExtent],
433 register const Quantum
447 assert(image != (Image *) NULL);
448 assert(image->signature == MagickSignature);
449 if (image->debug != MagickFalse)
450 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
451 if (file == (FILE *) NULL)
453 locate=GetImageArtifact(image,"identify:locate");
454 if (locate != (const char *) NULL)
466 Display minimum, maximum, or mean pixel locations.
468 type=(StatisticType) ParseCommandOption(MagickStatisticOptions,
470 limit=GetImageArtifact(image,"identify:limit");
472 if (limit != (const char *) NULL)
473 max_locations=StringToUnsignedLong(limit);
474 channel_statistics=GetLocationStatistics(image,type,exception);
475 if (channel_statistics == (ChannelStatistics *) NULL)
477 colorspace=image->colorspace;
478 if (IsImageGray(image,exception) != MagickFalse)
479 colorspace=GRAYColorspace;
480 (void) FormatLocaleFile(file,"Channel %s locations:\n",locate);
486 (void) PrintChannelLocations(file,image,RedPixelChannel,"Red",
487 type,max_locations,channel_statistics);
488 (void) PrintChannelLocations(file,image,GreenPixelChannel,"Green",
489 type,max_locations,channel_statistics);
490 (void) PrintChannelLocations(file,image,BluePixelChannel,"Blue",
491 type,max_locations,channel_statistics);
496 (void) PrintChannelLocations(file,image,CyanPixelChannel,"Cyan",
497 type,max_locations,channel_statistics);
498 (void) PrintChannelLocations(file,image,MagentaPixelChannel,"Magenta",
499 type,max_locations,channel_statistics);
500 (void) PrintChannelLocations(file,image,YellowPixelChannel,"Yellow",
501 type,max_locations,channel_statistics);
502 (void) PrintChannelLocations(file,image,BlackPixelChannel,"Black",
503 type,max_locations,channel_statistics);
508 (void) PrintChannelLocations(file,image,GrayPixelChannel,"Gray",
509 type,max_locations,channel_statistics);
513 if (image->alpha_trait == BlendPixelTrait)
514 (void) PrintChannelLocations(file,image,AlphaPixelChannel,"Alpha",
515 type,max_locations,channel_statistics);
516 channel_statistics=(ChannelStatistics *) RelinquishMagickMemory(
518 return(ferror(file) != 0 ? MagickFalse : MagickTrue);
521 elapsed_time=GetElapsedTime(&image->timer);
522 user_time=GetUserTime(&image->timer);
523 GetTimerInfo(&image->timer);
524 if (verbose == MagickFalse)
527 Display summary info about the image.
529 if (*image->magick_filename != '\0')
530 if (LocaleCompare(image->magick_filename,image->filename) != 0)
531 (void) FormatLocaleFile(file,"%s=>",image->magick_filename);
532 if ((GetPreviousImageInList(image) == (Image *) NULL) &&
533 (GetNextImageInList(image) == (Image *) NULL) &&
535 (void) FormatLocaleFile(file,"%s ",image->filename);
537 (void) FormatLocaleFile(file,"%s[%.20g] ",image->filename,(double)
539 (void) FormatLocaleFile(file,"%s ",image->magick);
540 if ((image->magick_columns != 0) || (image->magick_rows != 0))
541 if ((image->magick_columns != image->columns) ||
542 (image->magick_rows != image->rows))
543 (void) FormatLocaleFile(file,"%.20gx%.20g=>",(double)
544 image->magick_columns,(double) image->magick_rows);
545 (void) FormatLocaleFile(file,"%.20gx%.20g ",(double) image->columns,
546 (double) image->rows);
547 if ((image->page.width != 0) || (image->page.height != 0) ||
548 (image->page.x != 0) || (image->page.y != 0))
549 (void) FormatLocaleFile(file,"%.20gx%.20g%+.20g%+.20g ",(double)
550 image->page.width,(double) image->page.height,(double) image->page.x,
551 (double) image->page.y);
552 (void) FormatLocaleFile(file,"%.20g-bit ",(double) image->depth);
553 if (image->type != UndefinedType)
554 (void) FormatLocaleFile(file,"%s ",CommandOptionToMnemonic(
555 MagickTypeOptions,(ssize_t) image->type));
556 if (image->colorspace != UndefinedColorspace)
557 (void) FormatLocaleFile(file,"%s ",CommandOptionToMnemonic(
558 MagickColorspaceOptions,(ssize_t) image->colorspace));
559 if (image->storage_class == DirectClass)
561 if (image->total_colors != 0)
563 (void) FormatMagickSize(image->total_colors,MagickFalse,format);
564 (void) FormatLocaleFile(file,"%s ",format);
568 if (image->total_colors <= image->colors)
569 (void) FormatLocaleFile(file,"%.20gc ",(double)
572 (void) FormatLocaleFile(file,"%.20g=>%.20gc ",(double)
573 image->total_colors,(double) image->colors);
574 if (image->error.mean_error_per_pixel != 0.0)
575 (void) FormatLocaleFile(file,"%.20g/%f/%fdb ",(double)
576 (image->error.mean_error_per_pixel+0.5),
577 image->error.normalized_mean_error,
578 image->error.normalized_maximum_error);
579 if (GetBlobSize(image) != 0)
581 (void) FormatMagickSize(GetBlobSize(image),MagickFalse,format);
582 (void) FormatLocaleFile(file,"%s ",format);
584 (void) FormatLocaleFile(file,"%0.3fu %lu:%02lu.%03lu",user_time,
585 (unsigned long) (elapsed_time/60.0),(unsigned long) floor(fmod(
586 elapsed_time,60.0)),(unsigned long) (1000.0*(elapsed_time-
587 floor(elapsed_time))));
588 (void) FormatLocaleFile(file,"\n");
590 return(ferror(file) != 0 ? MagickFalse : MagickTrue);
593 Display verbose info about the image.
595 p=GetVirtualPixels(image,0,0,1,1,exception);
596 ping=p == (const Quantum *) NULL ? MagickTrue : MagickFalse;
597 type=GetImageType(image,exception);
598 (void) SignatureImage(image,exception);
599 (void) FormatLocaleFile(file,"Image: %s\n",image->filename);
600 if (*image->magick_filename != '\0')
601 if (LocaleCompare(image->magick_filename,image->filename) != 0)
604 filename[MaxTextExtent];
606 GetPathComponent(image->magick_filename,TailPath,filename);
607 (void) FormatLocaleFile(file," Base filename: %s\n",filename);
609 magick_info=GetMagickInfo(image->magick,exception);
610 if ((magick_info == (const MagickInfo *) NULL) ||
611 (GetMagickDescription(magick_info) == (const char *) NULL))
612 (void) FormatLocaleFile(file," Format: %s\n",image->magick);
614 (void) FormatLocaleFile(file," Format: %s (%s)\n",image->magick,
615 GetMagickDescription(magick_info));
616 if ((magick_info == (const MagickInfo *) NULL) ||
617 (GetMagickMimeType(magick_info) != (const char *) NULL))
618 (void) FormatLocaleFile(file," Mime type: %s\n",GetMagickMimeType(
620 (void) FormatLocaleFile(file," Class: %s\n",CommandOptionToMnemonic(
621 MagickClassOptions,(ssize_t) image->storage_class));
622 (void) FormatLocaleFile(file," Geometry: %.20gx%.20g%+.20g%+.20g\n",(double)
623 image->columns,(double) image->rows,(double) image->tile_offset.x,(double)
624 image->tile_offset.y);
625 if ((image->magick_columns != 0) || (image->magick_rows != 0))
626 if ((image->magick_columns != image->columns) ||
627 (image->magick_rows != image->rows))
628 (void) FormatLocaleFile(file," Base geometry: %.20gx%.20g\n",(double)
629 image->magick_columns,(double) image->magick_rows);
630 if ((image->resolution.x != 0.0) && (image->resolution.y != 0.0))
632 (void) FormatLocaleFile(file," Resolution: %gx%g\n",image->resolution.x,
633 image->resolution.y);
634 (void) FormatLocaleFile(file," Print size: %gx%g\n",(double)
635 image->columns/image->resolution.x,(double) image->rows/
636 image->resolution.y);
638 (void) FormatLocaleFile(file," Units: %s\n",CommandOptionToMnemonic(
639 MagickResolutionOptions,(ssize_t) image->units));
640 (void) FormatLocaleFile(file," Type: %s\n",CommandOptionToMnemonic(
641 MagickTypeOptions,(ssize_t) type));
642 if (image->type != UndefinedType)
643 (void) FormatLocaleFile(file," Base type: %s\n",CommandOptionToMnemonic(
644 MagickTypeOptions,(ssize_t) image->type));
645 (void) FormatLocaleFile(file," Endianess: %s\n",CommandOptionToMnemonic(
646 MagickEndianOptions,(ssize_t) image->endian));
648 Detail channel depth and extrema.
650 (void) FormatLocaleFile(file," Colorspace: %s\n",CommandOptionToMnemonic(
651 MagickColorspaceOptions,(ssize_t) image->colorspace));
652 channel_statistics=(ChannelStatistics *) NULL;
653 channel_features=(ChannelFeatures *) NULL;
654 colorspace=image->colorspace;
656 if (ping == MagickFalse)
661 channel_statistics=GetImageStatistics(image,exception);
662 if (channel_statistics == (ChannelStatistics *) NULL)
664 artifact=GetImageArtifact(image,"identify:features");
665 if (artifact != (const char *) NULL)
667 distance=StringToUnsignedLong(artifact);
668 channel_features=GetImageFeatures(image,distance,exception);
670 depth=GetImageDepth(image,exception);
671 if (image->depth == depth)
672 (void) FormatLocaleFile(file," Depth: %.20g-bit\n",(double)
675 (void) FormatLocaleFile(file," Depth: %.20g/%.20g-bit\n",(double)
676 image->depth,(double) depth);
677 (void) FormatLocaleFile(file," Channel depth:\n");
678 if (IsImageGray(image,exception) != MagickFalse)
679 colorspace=GRAYColorspace;
685 (void) FormatLocaleFile(file," Red: %.20g-bit\n",(double)
686 channel_statistics[RedPixelChannel].depth);
687 (void) FormatLocaleFile(file," Green: %.20g-bit\n",(double)
688 channel_statistics[GreenPixelChannel].depth);
689 (void) FormatLocaleFile(file," Blue: %.20g-bit\n",(double)
690 channel_statistics[BluePixelChannel].depth);
695 (void) FormatLocaleFile(file," Cyan: %.20g-bit\n",(double)
696 channel_statistics[CyanPixelChannel].depth);
697 (void) FormatLocaleFile(file," Magenta: %.20g-bit\n",(double)
698 channel_statistics[MagentaPixelChannel].depth);
699 (void) FormatLocaleFile(file," Yellow: %.20g-bit\n",(double)
700 channel_statistics[YellowPixelChannel].depth);
701 (void) FormatLocaleFile(file," Black: %.20g-bit\n",(double)
702 channel_statistics[BlackPixelChannel].depth);
707 (void) FormatLocaleFile(file," Gray: %.20g-bit\n",(double)
708 channel_statistics[GrayPixelChannel].depth);
712 if (image->alpha_trait == BlendPixelTrait)
713 (void) FormatLocaleFile(file," alpha: %.20g-bit\n",(double)
714 channel_statistics[AlphaPixelChannel].depth);
716 if (image->depth <= MAGICKCORE_QUANTUM_DEPTH)
717 scale=QuantumRange/((size_t) QuantumRange >> ((size_t)
718 MAGICKCORE_QUANTUM_DEPTH-image->depth));
720 if (channel_statistics != (ChannelStatistics *) NULL)
722 (void) FormatLocaleFile(file," Channel statistics:\n");
723 (void) FormatLocaleFile(file," Pixels: %.20g\n",
724 channel_statistics[CompositePixelChannel].area);
730 (void) PrintChannelStatistics(file,RedPixelChannel,"Red",1.0/
731 scale,channel_statistics);
732 (void) PrintChannelStatistics(file,GreenPixelChannel,"Green",1.0/
733 scale,channel_statistics);
734 (void) PrintChannelStatistics(file,BluePixelChannel,"Blue",1.0/
735 scale,channel_statistics);
740 (void) PrintChannelStatistics(file,CyanPixelChannel,"Cyan",1.0/
741 scale,channel_statistics);
742 (void) PrintChannelStatistics(file,MagentaPixelChannel,"Magenta",1.0/
743 scale,channel_statistics);
744 (void) PrintChannelStatistics(file,YellowPixelChannel,"Yellow",1.0/
745 scale,channel_statistics);
746 (void) PrintChannelStatistics(file,BlackPixelChannel,"Black",1.0/
747 scale,channel_statistics);
752 (void) PrintChannelStatistics(file,GrayPixelChannel,"Gray",1.0/
753 scale,channel_statistics);
757 if (image->alpha_trait == BlendPixelTrait)
758 (void) PrintChannelStatistics(file,AlphaPixelChannel,"Alpha",1.0/
759 scale,channel_statistics);
760 if (colorspace != GRAYColorspace)
762 (void) FormatLocaleFile(file," Image statistics:\n");
763 (void) PrintChannelStatistics(file,(PixelChannel) MaxPixelChannels,
764 "Overall",1.0/scale,channel_statistics);
766 channel_statistics=(ChannelStatistics *) RelinquishMagickMemory(
769 if (channel_features != (ChannelFeatures *) NULL)
771 (void) FormatLocaleFile(file," Channel features (horizontal, vertical, "
772 "left and right diagonals, average):\n");
778 (void) PrintChannelFeatures(file,RedPixelChannel,"Red",
780 (void) PrintChannelFeatures(file,GreenPixelChannel,"Green",
782 (void) PrintChannelFeatures(file,BluePixelChannel,"Blue",
788 (void) PrintChannelFeatures(file,CyanPixelChannel,"Cyan",
790 (void) PrintChannelFeatures(file,MagentaPixelChannel,"Magenta",
792 (void) PrintChannelFeatures(file,YellowPixelChannel,"Yellow",
794 (void) PrintChannelFeatures(file,BlackPixelChannel,"Black",
800 (void) PrintChannelFeatures(file,GrayPixelChannel,"Gray",
805 if (image->alpha_trait == BlendPixelTrait)
806 (void) PrintChannelFeatures(file,AlphaPixelChannel,"Alpha",
808 channel_features=(ChannelFeatures *) RelinquishMagickMemory(
811 if (ping == MagickFalse)
813 if (image->colorspace == CMYKColorspace)
814 (void) FormatLocaleFile(file," Total ink density: %.0f%%\n",100.0*
815 GetImageTotalInkDensity(image,exception)/(double) QuantumRange);
817 if (image->alpha_trait == BlendPixelTrait)
819 register const Quantum
822 p=(const Quantum *) NULL;
823 for (y=0; y < (ssize_t) image->rows; y++)
825 p=GetVirtualPixels(image,0,y,image->columns,1,exception);
826 if (p == (const Quantum *) NULL)
828 for (x=0; x < (ssize_t) image->columns; x++)
830 if (GetPixelAlpha(image,p) == (Quantum) TransparentAlpha)
832 p+=GetPixelChannels(image);
834 if (x < (ssize_t) image->columns)
837 if ((x < (ssize_t) image->columns) || (y < (ssize_t) image->rows))
840 tuple[MaxTextExtent];
845 GetPixelInfo(image,&pixel);
846 GetPixelInfoPixel(image,p,&pixel);
847 (void) QueryColorname(image,&pixel,SVGCompliance,tuple,
849 (void) FormatLocaleFile(file," Alpha: %s ",tuple);
850 GetColorTuple(&pixel,MagickTrue,tuple);
851 (void) FormatLocaleFile(file," %s\n",tuple);
854 if (IsHistogramImage(image,exception) != MagickFalse)
856 (void) FormatLocaleFile(file," Colors: %.20g\n",(double)
857 GetNumberColors(image,(FILE *) NULL,exception));
858 (void) FormatLocaleFile(file," Histogram:\n");
859 (void) GetNumberColors(image,file,exception);
863 artifact=GetImageArtifact(image,"identify:unique-colors");
864 if (IfMagickTrue(IsStringTrue(artifact)))
865 (void) FormatLocaleFile(file," Colors: %.20g\n",(double)
866 GetNumberColors(image,(FILE *) NULL,exception));
869 if (image->storage_class == PseudoClass)
871 (void) FormatLocaleFile(file," Colormap entries: %.20g\n",(double)
873 (void) FormatLocaleFile(file," Colormap:\n");
874 if (image->colors <= 1024)
877 color[MaxTextExtent],
879 tuple[MaxTextExtent];
887 GetPixelInfo(image,&pixel);
889 for (i=0; i < (ssize_t) image->colors; i++)
892 (void) CopyMagickString(tuple,"(",MaxTextExtent);
893 ConcatenateColorComponent(&pixel,RedPixelChannel,X11Compliance,
895 (void) ConcatenateMagickString(tuple,",",MaxTextExtent);
896 ConcatenateColorComponent(&pixel,GreenPixelChannel,X11Compliance,
898 (void) ConcatenateMagickString(tuple,",",MaxTextExtent);
899 ConcatenateColorComponent(&pixel,BluePixelChannel,X11Compliance,
901 if (pixel.colorspace == CMYKColorspace)
903 (void) ConcatenateMagickString(tuple,",",MaxTextExtent);
904 ConcatenateColorComponent(&pixel,BlackPixelChannel,
905 X11Compliance,tuple);
907 if (pixel.alpha_trait == BlendPixelTrait)
909 (void) ConcatenateMagickString(tuple,",",MaxTextExtent);
910 ConcatenateColorComponent(&pixel,AlphaPixelChannel,
911 X11Compliance,tuple);
913 (void) ConcatenateMagickString(tuple,")",MaxTextExtent);
914 (void) QueryColorname(image,&pixel,SVGCompliance,color,
916 GetColorTuple(&pixel,MagickTrue,hex);
917 (void) FormatLocaleFile(file," %8ld: %s %s %s\n",(long) i,tuple,
923 if (image->error.mean_error_per_pixel != 0.0)
924 (void) FormatLocaleFile(file," Mean error per pixel: %g\n",
925 image->error.mean_error_per_pixel);
926 if (image->error.normalized_mean_error != 0.0)
927 (void) FormatLocaleFile(file," Normalized mean error: %g\n",
928 image->error.normalized_mean_error);
929 if (image->error.normalized_maximum_error != 0.0)
930 (void) FormatLocaleFile(file," Normalized maximum error: %g\n",
931 image->error.normalized_maximum_error);
932 (void) FormatLocaleFile(file," Rendering intent: %s\n",
933 CommandOptionToMnemonic(MagickIntentOptions,(ssize_t)
934 image->rendering_intent));
935 if (image->gamma != 0.0)
936 (void) FormatLocaleFile(file," Gamma: %g\n",image->gamma);
937 if ((image->chromaticity.red_primary.x != 0.0) ||
938 (image->chromaticity.green_primary.x != 0.0) ||
939 (image->chromaticity.blue_primary.x != 0.0) ||
940 (image->chromaticity.white_point.x != 0.0))
943 Display image chromaticity.
945 (void) FormatLocaleFile(file," Chromaticity:\n");
946 (void) FormatLocaleFile(file," red primary: (%g,%g)\n",
947 image->chromaticity.red_primary.x,image->chromaticity.red_primary.y);
948 (void) FormatLocaleFile(file," green primary: (%g,%g)\n",
949 image->chromaticity.green_primary.x,
950 image->chromaticity.green_primary.y);
951 (void) FormatLocaleFile(file," blue primary: (%g,%g)\n",
952 image->chromaticity.blue_primary.x,image->chromaticity.blue_primary.y);
953 (void) FormatLocaleFile(file," white point: (%g,%g)\n",
954 image->chromaticity.white_point.x,image->chromaticity.white_point.y);
956 if ((image->extract_info.width*image->extract_info.height) != 0)
957 (void) FormatLocaleFile(file," Tile geometry: %.20gx%.20g%+.20g%+.20g\n",
958 (double) image->extract_info.width,(double) image->extract_info.height,
959 (double) image->extract_info.x,(double) image->extract_info.y);
960 (void) QueryColorname(image,&image->background_color,SVGCompliance,color,
962 (void) FormatLocaleFile(file," Background color: %s\n",color);
963 (void) QueryColorname(image,&image->border_color,SVGCompliance,color,
965 (void) FormatLocaleFile(file," Border color: %s\n",color);
966 (void) QueryColorname(image,&image->matte_color,SVGCompliance,color,
968 (void) FormatLocaleFile(file," Matte color: %s\n",color);
969 (void) QueryColorname(image,&image->transparent_color,SVGCompliance,color,
971 (void) FormatLocaleFile(file," Transparent color: %s\n",color);
972 (void) FormatLocaleFile(file," Interlace: %s\n",CommandOptionToMnemonic(
973 MagickInterlaceOptions,(ssize_t) image->interlace));
974 (void) FormatLocaleFile(file," Intensity: %s\n",CommandOptionToMnemonic(
975 MagickPixelIntensityOptions,(ssize_t) image->intensity));
976 (void) FormatLocaleFile(file," Compose: %s\n",CommandOptionToMnemonic(
977 MagickComposeOptions,(ssize_t) image->compose));
978 if ((image->page.width != 0) || (image->page.height != 0) ||
979 (image->page.x != 0) || (image->page.y != 0))
980 (void) FormatLocaleFile(file," Page geometry: %.20gx%.20g%+.20g%+.20g\n",
981 (double) image->page.width,(double) image->page.height,(double)
982 image->page.x,(double) image->page.y);
983 if ((image->page.x != 0) || (image->page.y != 0))
984 (void) FormatLocaleFile(file," Origin geometry: %+.20g%+.20g\n",(double)
985 image->page.x,(double) image->page.y);
986 (void) FormatLocaleFile(file," Dispose: %s\n",CommandOptionToMnemonic(
987 MagickDisposeOptions,(ssize_t) image->dispose));
988 if (image->delay != 0)
989 (void) FormatLocaleFile(file," Delay: %.20gx%.20g\n",(double) image->delay,
990 (double) image->ticks_per_second);
991 if (image->iterations != 1)
992 (void) FormatLocaleFile(file," Iterations: %.20g\n",(double)
994 if ((image->next != (Image *) NULL) || (image->previous != (Image *) NULL))
995 (void) FormatLocaleFile(file," Scene: %.20g of %.20g\n",(double)
996 image->scene,(double) GetImageListLength(image));
998 if (image->scene != 0)
999 (void) FormatLocaleFile(file," Scene: %.20g\n",(double) image->scene);
1000 (void) FormatLocaleFile(file," Compression: %s\n",CommandOptionToMnemonic(
1001 MagickCompressOptions,(ssize_t) image->compression));
1002 if (image->quality != UndefinedCompressionQuality)
1003 (void) FormatLocaleFile(file," Quality: %.20g\n",(double) image->quality);
1004 (void) FormatLocaleFile(file," Orientation: %s\n",CommandOptionToMnemonic(
1005 MagickOrientationOptions,(ssize_t) image->orientation));
1006 if (image->montage != (char *) NULL)
1007 (void) FormatLocaleFile(file," Montage: %s\n",image->montage);
1008 if (image->directory != (char *) NULL)
1024 Display visual image directory.
1026 image_info=AcquireImageInfo();
1027 (void) CloneString(&image_info->size,"64x64");
1028 (void) FormatLocaleFile(file," Directory:\n");
1029 for (p=image->directory; *p != '\0'; p++)
1032 while ((*q != '\n') && (*q != '\0'))
1034 (void) CopyMagickString(image_info->filename,p,(size_t) (q-p+1));
1036 (void) FormatLocaleFile(file," %s",image_info->filename);
1037 handler=SetWarningHandler((WarningHandler) NULL);
1038 tile=ReadImage(image_info,exception);
1039 (void) SetWarningHandler(handler);
1040 if (tile == (Image *) NULL)
1042 (void) FormatLocaleFile(file,"\n");
1045 (void) FormatLocaleFile(file," %.20gx%.20g %s\n",(double)
1046 tile->magick_columns,(double) tile->magick_rows,tile->magick);
1047 (void) SignatureImage(tile,exception);
1048 ResetImagePropertyIterator(tile);
1049 property=GetNextImageProperty(tile);
1050 while (property != (const char *) NULL)
1052 (void) FormatLocaleFile(file," %s:\n",property);
1053 value=GetImageProperty(tile,property,exception);
1054 if (value != (const char *) NULL)
1055 (void) FormatLocaleFile(file,"%s\n",value);
1056 property=GetNextImageProperty(tile);
1058 tile=DestroyImage(tile);
1060 image_info=DestroyImageInfo(image_info);
1062 (void) GetImageProperty(image,"exif:*",exception);
1063 ResetImagePropertyIterator(image);
1064 property=GetNextImageProperty(image);
1065 if (property != (const char *) NULL)
1068 Display image properties.
1070 (void) FormatLocaleFile(file," Properties:\n");
1071 while (property != (const char *) NULL)
1073 (void) FormatLocaleFile(file," %s: ",property);
1074 value=GetImageProperty(image,property,exception);
1075 if (value != (const char *) NULL)
1076 (void) FormatLocaleFile(file,"%s\n",value);
1077 property=GetNextImageProperty(image);
1080 (void) FormatLocaleString(key,MaxTextExtent,"8BIM:1999,2998:#1");
1081 value=GetImageProperty(image,key,exception);
1082 if (value != (const char *) NULL)
1085 Display clipping path.
1087 (void) FormatLocaleFile(file," Clipping path: ");
1088 if (strlen(value) > 80)
1089 (void) fputc('\n',file);
1090 (void) FormatLocaleFile(file,"%s\n",value);
1092 ResetImageProfileIterator(image);
1093 name=GetNextImageProfile(image);
1094 if (name != (char *) NULL)
1100 Identify image profiles.
1102 (void) FormatLocaleFile(file," Profiles:\n");
1103 while (name != (char *) NULL)
1105 profile=GetImageProfile(image,name);
1106 if (profile == (StringInfo *) NULL)
1108 (void) FormatLocaleFile(file," Profile-%s: %.20g bytes\n",name,
1109 (double) GetStringInfoLength(profile));
1110 #if defined(MAGICKCORE_LCMS_DELEGATE)
1111 if ((LocaleCompare(name,"icc") == 0) ||
1112 (LocaleCompare(name,"icm") == 0))
1117 icc_profile=cmsOpenProfileFromMem(GetStringInfoDatum(profile),
1118 (cmsUInt32Number) GetStringInfoLength(profile));
1119 if (icc_profile != (cmsHPROFILE *) NULL)
1121 #if defined(LCMS_VERSION) && (LCMS_VERSION < 2000)
1125 name=cmsTakeProductName(icc_profile);
1126 if (name != (const char *) NULL)
1127 (void) FormatLocaleFile(file," %s\n",name);
1130 info[MaxTextExtent];
1132 (void) cmsGetProfileInfoASCII(icc_profile,cmsInfoDescription,
1133 "en","US",info,MaxTextExtent);
1134 (void) FormatLocaleFile(file," Description: %s\n",info);
1135 (void) cmsGetProfileInfoASCII(icc_profile,cmsInfoManufacturer,
1136 "en","US",info,MaxTextExtent);
1137 (void) FormatLocaleFile(file," Manufacturer: %s\n",info);
1138 (void) cmsGetProfileInfoASCII(icc_profile,cmsInfoModel,"en",
1139 "US",info,MaxTextExtent);
1140 (void) FormatLocaleFile(file," Model: %s\n",info);
1141 (void) cmsGetProfileInfoASCII(icc_profile,cmsInfoCopyright,
1142 "en","US",info,MaxTextExtent);
1143 (void) FormatLocaleFile(file," Copyright: %s\n",info);
1145 (void) cmsCloseProfile(icc_profile);
1149 if (LocaleCompare(name,"iptc") == 0)
1170 profile_length=GetStringInfoLength(profile);
1171 for (i=0; i < (ssize_t) profile_length; i+=(ssize_t) length)
1174 sentinel=GetStringInfoDatum(profile)[i++];
1175 if (sentinel != 0x1c)
1177 dataset=GetStringInfoDatum(profile)[i++];
1178 record=GetStringInfoDatum(profile)[i++];
1181 case 5: tag="Image Name"; break;
1182 case 7: tag="Edit Status"; break;
1183 case 10: tag="Priority"; break;
1184 case 15: tag="Category"; break;
1185 case 20: tag="Supplemental Category"; break;
1186 case 22: tag="Fixture Identifier"; break;
1187 case 25: tag="Keyword"; break;
1188 case 30: tag="Release Date"; break;
1189 case 35: tag="Release Time"; break;
1190 case 40: tag="Special Instructions"; break;
1191 case 45: tag="Reference Service"; break;
1192 case 47: tag="Reference Date"; break;
1193 case 50: tag="Reference Number"; break;
1194 case 55: tag="Created Date"; break;
1195 case 60: tag="Created Time"; break;
1196 case 65: tag="Originating Program"; break;
1197 case 70: tag="Program Version"; break;
1198 case 75: tag="Object Cycle"; break;
1199 case 80: tag="Byline"; break;
1200 case 85: tag="Byline Title"; break;
1201 case 90: tag="City"; break;
1202 case 95: tag="Province State"; break;
1203 case 100: tag="Country Code"; break;
1204 case 101: tag="Country"; break;
1205 case 103: tag="Original Transmission Reference"; break;
1206 case 105: tag="Headline"; break;
1207 case 110: tag="Credit"; break;
1208 case 115: tag="Src"; break;
1209 case 116: tag="Copyright String"; break;
1210 case 120: tag="Caption"; break;
1211 case 121: tag="Local Caption"; break;
1212 case 122: tag="Caption Writer"; break;
1213 case 200: tag="Custom Field 1"; break;
1214 case 201: tag="Custom Field 2"; break;
1215 case 202: tag="Custom Field 3"; break;
1216 case 203: tag="Custom Field 4"; break;
1217 case 204: tag="Custom Field 5"; break;
1218 case 205: tag="Custom Field 6"; break;
1219 case 206: tag="Custom Field 7"; break;
1220 case 207: tag="Custom Field 8"; break;
1221 case 208: tag="Custom Field 9"; break;
1222 case 209: tag="Custom Field 10"; break;
1223 case 210: tag="Custom Field 11"; break;
1224 case 211: tag="Custom Field 12"; break;
1225 case 212: tag="Custom Field 13"; break;
1226 case 213: tag="Custom Field 14"; break;
1227 case 214: tag="Custom Field 15"; break;
1228 case 215: tag="Custom Field 16"; break;
1229 case 216: tag="Custom Field 17"; break;
1230 case 217: tag="Custom Field 18"; break;
1231 case 218: tag="Custom Field 19"; break;
1232 case 219: tag="Custom Field 20"; break;
1233 default: tag="unknown"; break;
1235 (void) FormatLocaleFile(file," %s[%.20g,%.20g]: ",tag,
1236 (double) dataset,(double) record);
1237 length=(size_t) (GetStringInfoDatum(profile)[i++] << 8);
1238 length|=GetStringInfoDatum(profile)[i++];
1239 attribute=(char *) NULL;
1240 if (~length >= (MaxTextExtent-1))
1241 attribute=(char *) AcquireQuantumMemory(length+MaxTextExtent,
1242 sizeof(*attribute));
1243 if (attribute != (char *) NULL)
1245 (void) CopyMagickString(attribute,(char *)
1246 GetStringInfoDatum(profile)+i,length+1);
1247 attribute_list=StringToList(attribute);
1248 if (attribute_list != (char **) NULL)
1250 for (j=0; attribute_list[j] != (char *) NULL; j++)
1252 (void) fputs(attribute_list[j],file);
1253 (void) fputs("\n",file);
1254 attribute_list[j]=(char *) RelinquishMagickMemory(
1257 attribute_list=(char **) RelinquishMagickMemory(
1260 attribute=DestroyString(attribute);
1264 if (image->debug != MagickFalse)
1265 PrintStringInfo(file,name,profile);
1266 name=GetNextImageProfile(image);
1269 ResetImageArtifactIterator(image);
1270 artifact=GetNextImageArtifact(image);
1271 if (artifact != (const char *) NULL)
1274 Display image artifacts.
1276 (void) FormatLocaleFile(file," Artifacts:\n");
1277 while (artifact != (const char *) NULL)
1279 (void) FormatLocaleFile(file," %s: ",artifact);
1280 value=GetImageArtifact(image,artifact);
1281 if (value != (const char *) NULL)
1282 (void) FormatLocaleFile(file,"%s\n",value);
1283 artifact=GetNextImageArtifact(image);
1286 ResetImageRegistryIterator();
1287 registry=GetNextImageRegistry();
1288 if (registry != (const char *) NULL)
1291 Display image registry.
1293 (void) FormatLocaleFile(file," Registry:\n");
1294 while (registry != (const char *) NULL)
1296 (void) FormatLocaleFile(file," %s: ",registry);
1297 value=(const char *) GetImageRegistry(StringRegistryType,registry,
1299 if (value != (const char *) NULL)
1300 (void) FormatLocaleFile(file,"%s\n",value);
1301 registry=GetNextImageRegistry();
1304 (void) FormatLocaleFile(file," Tainted: %s\n",CommandOptionToMnemonic(
1305 MagickBooleanOptions,(ssize_t) image->taint));
1306 (void) FormatMagickSize(GetBlobSize(image),MagickFalse,format);
1307 (void) FormatLocaleFile(file," Filesize: %s\n",format);
1308 (void) FormatMagickSize((MagickSizeType) image->columns*image->rows,
1309 MagickFalse,format);
1310 if (strlen(format) > 1)
1311 format[strlen(format)-1]='\0';
1312 (void) FormatLocaleFile(file," Number pixels: %s\n",format);
1313 (void) FormatMagickSize((MagickSizeType) ((double) image->columns*image->rows/
1314 elapsed_time+0.5),MagickFalse,format);
1315 (void) FormatLocaleFile(file," Pixels per second: %s\n",format);
1316 (void) FormatLocaleFile(file," User time: %0.3fu\n",user_time);
1317 (void) FormatLocaleFile(file," Elapsed time: %lu:%02lu.%03lu\n",
1318 (unsigned long) (elapsed_time/60.0),(unsigned long) ceil(fmod(elapsed_time,
1319 60.0)),(unsigned long) (1000.0*(elapsed_time-floor(elapsed_time))));
1320 (void) FormatLocaleFile(file," Version: %s\n",GetMagickVersion((size_t *)
1322 (void) fflush(file);
1323 return(ferror(file) != 0 ? MagickFalse : MagickTrue);