MagickCore 7.1.1-43
Convert, Edit, Or Compose Bitmap Images
Loading...
Searching...
No Matches
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/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"
102␌
103/*
104%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
105% %
106% %
107% %
108% I d e n t i f y I m a g e %
109% %
110% %
111% %
112%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
113%
114% IdentifyImage() identifies an image by printing its attributes to the file.
115% Attributes include the image width, height, size, and others.
116%
117% The format of the IdentifyImage method is:
118%
119% MagickBooleanType IdentifyImage(Image *image,FILE *file,
120% const MagickBooleanType verbose,ExceptionInfo *exception)
121%
122% A description of each parameter follows:
123%
124% o image: the image.
125%
126% o file: the file, typically stdout.
127%
128% o verbose: A value other than zero prints more detailed information
129% about the image.
130%
131% o exception: return any errors or warnings in this structure.
132%
133*/
134
135static ChannelStatistics *GetLocationStatistics(const Image *image,
136 const StatisticType type,ExceptionInfo *exception)
137{
139 *channel_statistics;
140
141 ssize_t
142 i;
143
144 ssize_t
145 y;
146
147 assert(image != (Image *) NULL);
148 assert(image->signature == MagickCoreSignature);
149 if (IsEventLogging() != MagickFalse)
150 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
151 channel_statistics=(ChannelStatistics *) AcquireQuantumMemory(
152 MaxPixelChannels+1,sizeof(*channel_statistics));
153 if (channel_statistics == (ChannelStatistics *) NULL)
154 {
155 (void) ThrowMagickException(exception,GetMagickModule(),
156 ResourceLimitError,"MemoryAllocationFailed","`%s'",image->filename);
157 return(channel_statistics);
158 }
159 (void) memset(channel_statistics,0,(MaxPixelChannels+1)*
160 sizeof(*channel_statistics));
161 for (i=0; i <= (ssize_t) MaxPixelChannels; i++)
162 {
163 switch (type)
164 {
165 case MaximumStatistic:
166 default:
167 {
168 channel_statistics[i].maxima=(-MagickMaximumValue);
169 break;
170 }
171 case MinimumStatistic:
172 {
173 channel_statistics[i].minima=MagickMaximumValue;
174 break;
175 }
176 }
177 }
178 for (y=0; y < (ssize_t) image->rows; y++)
179 {
180 const Quantum
181 *magick_restrict p;
182
183 ssize_t
184 x;
185
186 p=GetVirtualPixels(image,0,y,image->columns,1,exception);
187 if (p == (const Quantum *) NULL)
188 break;
189 for (x=0; x < (ssize_t) image->columns; x++)
190 {
191 if (GetPixelReadMask(image,p) <= (QuantumRange/2))
192 {
193 p+=(ptrdiff_t) GetPixelChannels(image);
194 continue;
195 }
196 for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
197 {
198 PixelChannel channel = GetPixelChannelChannel(image,i);
199 PixelTrait traits = GetPixelChannelTraits(image,channel);
200 if (traits == UndefinedPixelTrait)
201 continue;
202 switch (type)
203 {
204 case MaximumStatistic:
205 default:
206 {
207 if ((double) p[i] > channel_statistics[channel].maxima)
208 channel_statistics[channel].maxima=(double) p[i];
209 break;
210 }
211 case MinimumStatistic:
212 {
213 if ((double) p[i] < channel_statistics[channel].minima)
214 channel_statistics[channel].minima=(double) p[i];
215 break;
216 }
217 }
218 }
219 p+=(ptrdiff_t) GetPixelChannels(image);
220 }
221 }
222 return(channel_statistics);
223}
224
225static ssize_t PrintChannelFeatures(FILE *file,const PixelChannel channel,
226 const char *name,const ChannelFeatures *channel_features)
227{
228#define PrintFeature(feature) \
229 GetMagickPrecision(),(feature)[0], \
230 GetMagickPrecision(),(feature)[1], \
231 GetMagickPrecision(),(feature)[2], \
232 GetMagickPrecision(),(feature)[3], \
233 GetMagickPrecision(),((feature)[0]+(feature)[1]+(feature)[2]+(feature)[3])/4.0 \
234
235#define FeaturesFormat " %s:\n" \
236 " Angular Second Moment:\n" \
237 " %.*g, %.*g, %.*g, %.*g, %.*g\n" \
238 " Contrast:\n" \
239 " %.*g, %.*g, %.*g, %.*g, %.*g\n" \
240 " Correlation:\n" \
241 " %.*g, %.*g, %.*g, %.*g, %.*g\n" \
242 " Sum of Squares Variance:\n" \
243 " %.*g, %.*g, %.*g, %.*g, %.*g\n" \
244 " Inverse Difference Moment:\n" \
245 " %.*g, %.*g, %.*g, %.*g, %.*g\n" \
246 " Sum Average:\n" \
247 " %.*g, %.*g, %.*g, %.*g, %.*g\n" \
248 " Sum Variance:\n" \
249 " %.*g, %.*g, %.*g, %.*g, %.*g\n" \
250 " Sum Entropy:\n" \
251 " %.*g, %.*g, %.*g, %.*g, %.*g\n" \
252 " Entropy:\n" \
253 " %.*g, %.*g, %.*g, %.*g, %.*g\n" \
254 " Difference Variance:\n" \
255 " %.*g, %.*g, %.*g, %.*g, %.*g\n" \
256 " Difference Entropy:\n" \
257 " %.*g, %.*g, %.*g, %.*g, %.*g\n" \
258 " Information Measure of Correlation 1:\n" \
259 " %.*g, %.*g, %.*g, %.*g, %.*g\n" \
260 " Information Measure of Correlation 2:\n" \
261 " %.*g, %.*g, %.*g, %.*g, %.*g\n" \
262 " Maximum Correlation Coefficient:\n" \
263 " %.*g, %.*g, %.*g, %.*g, %.*g\n"
264
265 ssize_t
266 n;
267
268 n=FormatLocaleFile(file,FeaturesFormat,name,
269 PrintFeature(channel_features[channel].angular_second_moment),
270 PrintFeature(channel_features[channel].contrast),
271 PrintFeature(channel_features[channel].correlation),
272 PrintFeature(channel_features[channel].variance_sum_of_squares),
273 PrintFeature(channel_features[channel].inverse_difference_moment),
274 PrintFeature(channel_features[channel].sum_average),
275 PrintFeature(channel_features[channel].sum_variance),
276 PrintFeature(channel_features[channel].sum_entropy),
277 PrintFeature(channel_features[channel].entropy),
278 PrintFeature(channel_features[channel].difference_variance),
279 PrintFeature(channel_features[channel].difference_entropy),
280 PrintFeature(channel_features[channel].measure_of_correlation_1),
281 PrintFeature(channel_features[channel].measure_of_correlation_2),
282 PrintFeature(channel_features[channel].maximum_correlation_coefficient));
283 return(n);
284}
285
286static ssize_t PrintChannelLocations(FILE *file,const Image *image,
287 const PixelChannel channel,const char *name,const StatisticType type,
288 const size_t max_locations,const ChannelStatistics *channel_statistics)
289{
290 double
291 target;
292
294 *exception;
295
296 ssize_t
297 n,
298 y;
299
300 switch (type)
301 {
302 case MaximumStatistic:
303 default:
304 {
305 target=channel_statistics[channel].maxima;
306 break;
307 }
308 case MinimumStatistic:
309 {
310 target=channel_statistics[channel].minima;
311 break;
312 }
313 }
314 (void) FormatLocaleFile(file," %s: %.*g (%.*g)",name,GetMagickPrecision(),
315 target,GetMagickPrecision(),QuantumScale*target);
316 exception=AcquireExceptionInfo();
317 n=0;
318 for (y=0; y < (ssize_t) image->rows; y++)
319 {
320 const Quantum
321 *p;
322
323 ssize_t
324 offset,
325 x;
326
327 p=GetVirtualPixels(image,0,y,image->columns,1,exception);
328 if (p == (const Quantum *) NULL)
329 break;
330 for (x=0; x < (ssize_t) image->columns; x++)
331 {
332 MagickBooleanType
333 match;
334
335 PixelTrait traits = GetPixelChannelTraits(image,channel);
336 if (traits == UndefinedPixelTrait)
337 continue;
338 offset=GetPixelChannelOffset(image,channel);
339 match=fabs((double) p[offset]-target) < 0.5 ? MagickTrue : MagickFalse;
340 if (match != MagickFalse)
341 {
342 if ((max_locations != 0) && (n >= (ssize_t) max_locations))
343 break;
344 (void) FormatLocaleFile(file," %.20g,%.20g",(double) x,(double) y);
345 n++;
346 }
347 p+=(ptrdiff_t) GetPixelChannels(image);
348 }
349 if (x < (ssize_t) image->columns)
350 break;
351 }
352 (void) FormatLocaleFile(file,"\n");
353 return(n);
354}
355
356static ssize_t PrintChannelMoments(FILE *file,const PixelChannel channel,
357 const char *name,const double scale,const ChannelMoments *channel_moments)
358{
359 double
360 powers[MaximumNumberOfImageMoments] =
361 { 1.0, 2.0, 3.0, 3.0, 6.0, 4.0, 6.0, 4.0 };
362
363 ssize_t
364 i;
365
366 ssize_t
367 n;
368
369 n=FormatLocaleFile(file," %s:\n",name);
370 n+=FormatLocaleFile(file," Centroid: %.*g,%.*g\n",
371 GetMagickPrecision(),channel_moments[channel].centroid.x,
372 GetMagickPrecision(),channel_moments[channel].centroid.y);
373 n+=FormatLocaleFile(file," Ellipse Semi-Major/Minor axis: %.*g,%.*g\n",
374 GetMagickPrecision(),channel_moments[channel].ellipse_axis.x,
375 GetMagickPrecision(),channel_moments[channel].ellipse_axis.y);
376 n+=FormatLocaleFile(file," Ellipse angle: %.*g\n",
377 GetMagickPrecision(),channel_moments[channel].ellipse_angle);
378 n+=FormatLocaleFile(file," Ellipse eccentricity: %.*g\n",
379 GetMagickPrecision(),channel_moments[channel].ellipse_eccentricity);
380 n+=FormatLocaleFile(file," Ellipse intensity: %.*g (%.*g)\n",
381 GetMagickPrecision(),pow(scale,powers[0])*
382 channel_moments[channel].ellipse_intensity,GetMagickPrecision(),
383 channel_moments[channel].ellipse_intensity);
384 for (i=0; i < MaximumNumberOfImageMoments; i++)
385 n+=FormatLocaleFile(file," I%.20g: %.*g (%.*g)\n",i+1.0,
386 GetMagickPrecision(),channel_moments[channel].invariant[i]/pow(scale,
387 powers[i]),GetMagickPrecision(),channel_moments[channel].invariant[i]);
388 return(n);
389}
390
391static ssize_t PrintChannelPerceptualHash(Image *image,FILE *file,
392 const ChannelPerceptualHash *channel_phash)
393{
394 ssize_t
395 i;
396
397 ssize_t
398 n;
399
400 (void) FormatLocaleFile(file," Channel perceptual hash: ");
401 for (i=0; i < (ssize_t) channel_phash[0].number_colorspaces; i++)
402 {
403 (void) FormatLocaleFile(file,"%s",CommandOptionToMnemonic(
404 MagickColorspaceOptions,(ssize_t) channel_phash[0].colorspace[i]));
405 if (i < (ssize_t) (channel_phash[0].number_colorspaces-1))
406 (void) FormatLocaleFile(file,", ");
407 }
408 (void) FormatLocaleFile(file,"\n");
409 n=0;
410 for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
411 {
412 PixelChannel
413 channel;
414
415 PixelTrait
416 traits;
417
418 ssize_t
419 j;
420
421 channel=GetPixelChannelChannel(image,i);
422 if (channel == IndexPixelChannel)
423 continue;
424 traits=GetPixelChannelTraits(image,channel);
425 if (traits == UndefinedPixelTrait)
426 continue;
427 n=FormatLocaleFile(file," Channel %.20g:\n",(double) channel);
428 for (j=0; j < MaximumNumberOfPerceptualHashes; j++)
429 {
430 ssize_t
431 k;
432
433 n+=FormatLocaleFile(file," PH%.20g: ",(double) j+1);
434 for (k=0; k < (ssize_t) channel_phash[0].number_colorspaces; k++)
435 {
436 n+=FormatLocaleFile(file,"%.*g",GetMagickPrecision(),
437 channel_phash[channel].phash[k][j]);
438 if (k < (ssize_t) (channel_phash[0].number_colorspaces-1))
439 n+=FormatLocaleFile(file,", ");
440 }
441 n+=FormatLocaleFile(file,"\n");
442 }
443 }
444 return(n);
445}
446
447static ssize_t PrintChannelStatistics(FILE *file,const PixelChannel channel,
448 const char *name,const double scale,
449 const ChannelStatistics *channel_statistics)
450{
451#define StatisticsFormat " %s:\n min: %.*g (%.*g)\n " \
452 "max: %.*g (%.*g)\n mean: %.*g (%.*g)\n median: %.*g (%.*g)\n " \
453 "standard deviation: %.*g (%.*g)\n kurtosis: %.*g\n " \
454 "skewness: %.*g\n entropy: %.*g\n"
455
456 ssize_t
457 n;
458
459 n=FormatLocaleFile(file,StatisticsFormat,name,GetMagickPrecision(),
460 (double) ClampToQuantum((MagickRealType) (scale*
461 channel_statistics[channel].minima)),GetMagickPrecision(),
462 channel_statistics[channel].minima/(double) QuantumRange,
463 GetMagickPrecision(),(double) ClampToQuantum((MagickRealType) (scale*
464 channel_statistics[channel].maxima)),GetMagickPrecision(),
465 channel_statistics[channel].maxima/(double) QuantumRange,
466 GetMagickPrecision(),scale*channel_statistics[channel].mean,
467 GetMagickPrecision(),channel_statistics[channel].mean/(double) QuantumRange,
468 GetMagickPrecision(),scale*channel_statistics[channel].median,
469 GetMagickPrecision(),channel_statistics[channel].median/(double) QuantumRange,
470 GetMagickPrecision(),scale*channel_statistics[channel].standard_deviation,
471 GetMagickPrecision(),channel_statistics[channel].standard_deviation/
472 (double) QuantumRange,GetMagickPrecision(),
473 channel_statistics[channel].kurtosis,GetMagickPrecision(),
474 channel_statistics[channel].skewness,GetMagickPrecision(),
475 channel_statistics[channel].entropy);
476 return(n);
477}
478
479MagickExport MagickBooleanType IdentifyImage(Image *image,FILE *file,
480 const MagickBooleanType verbose,ExceptionInfo *exception)
481{
482 char
483 buffer[MagickPathExtent],
484 color[MagickPathExtent],
485 key[MagickPathExtent];
486
488 *channel_features;
489
491 *channel_moments;
492
494 *channel_phash;
495
497 *channel_statistics;
498
499 ColorspaceType
500 colorspace;
501
502 const char
503 *artifact,
504 *locate,
505 *name,
506 *property,
507 *registry,
508 *value;
509
510 const MagickInfo
511 *magick_info;
512
513 const Quantum
514 *p;
515
516 double
517 elapsed_time,
518 scale,
519 user_time;
520
521 ImageType
522 type;
523
524 int
525 expired;
526
527 MagickBooleanType
528 ping;
529
530 size_t
531 depth,
532 distance;
533
534 ssize_t
535 i,
536 x,
537 y;
538
539 struct stat
540 properties;
541
542 assert(image != (Image *) NULL);
543 assert(image->signature == MagickCoreSignature);
544 if (IsEventLogging() != MagickFalse)
545 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
546 if (file == (FILE *) NULL)
547 file=stdout;
548 colorspace=image->colorspace;
549 locate=GetImageArtifact(image,"identify:locate");
550 if (locate != (const char *) NULL)
551 {
552 const char
553 *limit;
554
555 size_t
556 max_locations;
557
558 StatisticType
559 statistic_type;
560
561 /*
562 Display minimum, maximum, or mean pixel locations.
563 */
564 statistic_type=(StatisticType) ParseCommandOption(MagickStatisticOptions,
565 MagickFalse,locate);
566 limit=GetImageArtifact(image,"identify:limit");
567 max_locations=0;
568 if (limit != (const char *) NULL)
569 max_locations=StringToUnsignedLong(limit);
570 channel_statistics=GetLocationStatistics(image,statistic_type,exception);
571 if (channel_statistics == (ChannelStatistics *) NULL)
572 return(MagickFalse);
573 (void) FormatLocaleFile(file,"Channel %s locations:\n",locate);
574 switch (colorspace)
575 {
576 case RGBColorspace:
577 case sRGBColorspace:
578 {
579 if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0)
580 (void) PrintChannelLocations(file,image,RedPixelChannel,"Red",
581 statistic_type,max_locations,channel_statistics);
582 if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0)
583 (void) PrintChannelLocations(file,image,GreenPixelChannel,"Green",
584 statistic_type,max_locations,channel_statistics);
585 if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0)
586 (void) PrintChannelLocations(file,image,BluePixelChannel,"Blue",
587 statistic_type,max_locations,channel_statistics);
588 break;
589 }
590 case CMYKColorspace:
591 {
592 if ((GetPixelCyanTraits(image) & UpdatePixelTrait) != 0)
593 (void) PrintChannelLocations(file,image,CyanPixelChannel,"Cyan",
594 statistic_type,max_locations,channel_statistics);
595 if ((GetPixelMagentaTraits(image) & UpdatePixelTrait) != 0)
596 (void) PrintChannelLocations(file,image,MagentaPixelChannel,
597 "Magenta",statistic_type,max_locations,channel_statistics);
598 if ((GetPixelYellowTraits(image) & UpdatePixelTrait) != 0)
599 (void) PrintChannelLocations(file,image,YellowPixelChannel,"Yellow",
600 statistic_type,max_locations,channel_statistics);
601 if ((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0)
602 (void) PrintChannelLocations(file,image,BlackPixelChannel,"Black",
603 statistic_type,max_locations,channel_statistics);
604 break;
605 }
606 case LinearGRAYColorspace:
607 case GRAYColorspace:
608 {
609 if ((GetPixelGrayTraits(image) & UpdatePixelTrait) != 0)
610 (void) PrintChannelLocations(file,image,GrayPixelChannel,"Gray",
611 statistic_type,max_locations,channel_statistics);
612 break;
613 }
614 default:
615 {
616 for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
617 {
618 PixelChannel channel = GetPixelChannelChannel(image,i);
619 PixelTrait traits = GetPixelChannelTraits(image,channel);
620 if ((traits & UpdatePixelTrait) != 0)
621 (void) PrintChannelLocations(file,image,channel,"Channel",
622 statistic_type,max_locations,channel_statistics);
623 }
624 break;
625 }
626 }
627 if (image->alpha_trait != UndefinedPixelTrait)
628 (void) PrintChannelLocations(file,image,AlphaPixelChannel,"Alpha",
629 statistic_type,max_locations,channel_statistics);
630 channel_statistics=(ChannelStatistics *) RelinquishMagickMemory(
631 channel_statistics);
632 return(ferror(file) != 0 ? MagickFalse : MagickTrue);
633 }
634 elapsed_time=GetElapsedTime(&image->timer);
635 user_time=GetUserTime(&image->timer);
636 GetTimerInfo(&image->timer);
637 if (verbose == MagickFalse)
638 {
639 /*
640 Display summary info about the image.
641 */
642 if (*image->magick_filename != '\0')
643 if (LocaleCompare(image->magick_filename,image->filename) != 0)
644 (void) FormatLocaleFile(file,"%s=>",image->magick_filename);
645 if ((GetPreviousImageInList(image) == (Image *) NULL) &&
646 (GetNextImageInList(image) == (Image *) NULL) &&
647 (image->scene == 0))
648 (void) FormatLocaleFile(file,"%s ",image->filename);
649 else
650 (void) FormatLocaleFile(file,"%s[%.20g] ",image->filename,(double)
651 image->scene);
652 (void) FormatLocaleFile(file,"%s ",image->magick);
653 if ((image->magick_columns != 0) || (image->magick_rows != 0))
654 if ((image->magick_columns != image->columns) ||
655 (image->magick_rows != image->rows))
656 (void) FormatLocaleFile(file,"%.20gx%.20g=>",(double)
657 image->magick_columns,(double) image->magick_rows);
658 (void) FormatLocaleFile(file,"%.20gx%.20g ",(double) image->columns,
659 (double) image->rows);
660 if ((image->page.width != 0) || (image->page.height != 0) ||
661 (image->page.x != 0) || (image->page.y != 0))
662 (void) FormatLocaleFile(file,"%.20gx%.20g%+.20g%+.20g ",(double)
663 image->page.width,(double) image->page.height,(double) image->page.x,
664 (double) image->page.y);
665 (void) FormatLocaleFile(file,"%.20g-bit ",(double) image->depth);
666 if (image->type != UndefinedType)
667 (void) FormatLocaleFile(file,"%s ",CommandOptionToMnemonic(
668 MagickTypeOptions,(ssize_t) image->type));
669 if (colorspace != UndefinedColorspace)
670 (void) FormatLocaleFile(file,"%s ",CommandOptionToMnemonic(
671 MagickColorspaceOptions,(ssize_t) colorspace));
672 if (image->storage_class == DirectClass)
673 {
674 if (image->total_colors != 0)
675 {
676 (void) FormatMagickSize(image->total_colors,MagickFalse,"B",
677 MagickPathExtent,buffer);
678 (void) FormatLocaleFile(file,"%s ",buffer);
679 }
680 }
681 else
682 if (image->total_colors <= image->colors)
683 (void) FormatLocaleFile(file,"%.20gc ",(double)
684 image->colors);
685 else
686 (void) FormatLocaleFile(file,"%.20g=>%.20gc ",(double)
687 image->total_colors,(double) image->colors);
688 if (image->error.mean_error_per_pixel != 0.0)
689 (void) FormatLocaleFile(file,"%.20g/%f/%fdb ",(double)
690 (image->error.mean_error_per_pixel+0.5),
691 image->error.normalized_mean_error,
692 image->error.normalized_maximum_error);
693 if (image->extent != 0)
694 {
695 (void) FormatMagickSize(image->extent,MagickTrue,"B",
696 MagickPathExtent,buffer);
697 (void) FormatLocaleFile(file,"%s ",buffer);
698 }
699 (void) FormatLocaleFile(file,"%0.3fu %lu:%02lu.%03lu",user_time,
700 (unsigned long) (elapsed_time/60.0),(unsigned long) floor(fmod(
701 elapsed_time,60.0)),(unsigned long) (1000.0*(elapsed_time-
702 floor(elapsed_time))));
703 (void) FormatLocaleFile(file,"\n");
704 (void) fflush(file);
705 return(ferror(file) != 0 ? MagickFalse : MagickTrue);
706 }
707 /*
708 Display verbose info about the image.
709 */
710 p=GetVirtualPixels(image,0,0,1,1,exception);
711 ping=p == (const Quantum *) NULL ? MagickTrue : MagickFalse;
712 (void) SignatureImage(image,exception);
713 channel_statistics=(ChannelStatistics *) NULL;
714 channel_moments=(ChannelMoments *) NULL;
715 channel_phash=(ChannelPerceptualHash *) NULL;
716 channel_features=(ChannelFeatures *) NULL;
717 depth=0;
718 if (ping == MagickFalse)
719 {
720 depth=GetImageDepth(image,exception);
721 channel_statistics=GetImageStatistics(image,exception);
722 artifact=GetImageArtifact(image,"identify:moments");
723 if (artifact != (const char *) NULL)
724 {
725 channel_moments=GetImageMoments(image,exception);
726 channel_phash=GetImagePerceptualHash(image,exception);
727 }
728 artifact=GetImageArtifact(image,"identify:features");
729 if (artifact != (const char *) NULL)
730 {
731 distance=StringToUnsignedLong(artifact);
732 channel_features=GetImageFeatures(image,distance,exception);
733 }
734 }
735 (void) FormatLocaleFile(file,"Image:\n Filename: %s\n",image->filename);
736 if (*image->magick_filename != '\0')
737 if (LocaleCompare(image->magick_filename,image->filename) != 0)
738 {
739 char
740 filename[MagickPathExtent];
741
742 GetPathComponent(image->magick_filename,TailPath,filename);
743 (void) FormatLocaleFile(file," Base filename: %s\n",filename);
744 }
745 properties=(*GetBlobProperties(image));
746 if (properties.st_mode != 0)
747 {
748 static const char *rwx[] =
749 { "---", "--x", "-w-", "-wx", "r--", "r-x", "rw-", "rwx"};
750 (void) FormatLocaleFile(file," Permissions: %s%s%s\n",
751 rwx[(properties.st_mode >> 6) & 0x07],
752 rwx[(properties.st_mode >> 3) & 0x07],
753 rwx[(properties.st_mode >> 0) & 0x07]);
754 }
755 magick_info=GetMagickInfo(image->magick,exception);
756 if ((magick_info == (const MagickInfo *) NULL) ||
757 (GetMagickDescription(magick_info) == (const char *) NULL))
758 (void) FormatLocaleFile(file," Format: %s\n",image->magick);
759 else
760 (void) FormatLocaleFile(file," Format: %s (%s)\n",image->magick,
761 GetMagickDescription(magick_info));
762 if ((magick_info != (const MagickInfo *) NULL) &&
763 (GetMagickMimeType(magick_info) != (const char *) NULL))
764 (void) FormatLocaleFile(file," Mime type: %s\n",GetMagickMimeType(
765 magick_info));
766 (void) FormatLocaleFile(file," Class: %s\n",CommandOptionToMnemonic(
767 MagickClassOptions,(ssize_t) image->storage_class));
768 (void) FormatLocaleFile(file," Geometry: %.20gx%.20g%+.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: %.20gx%.20g\n",(double)
775 image->magick_columns,(double) image->magick_rows);
776 if ((image->resolution.x != 0.0) && (image->resolution.y != 0.0))
777 {
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);
783 }
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));
796 if (depth != 0)
797 {
798 if (image->depth == depth)
799 (void) FormatLocaleFile(file," Depth: %.20g-bit\n",(double)
800 image->depth);
801 else
802 (void) FormatLocaleFile(file," Depth: %.20g/%.20g-bit\n",(double)
803 image->depth,(double) depth);
804 }
805 (void) FormatLocaleFile(file," Channels: %g.%g\n",(double)
806 image->number_channels,(double) image->number_meta_channels);
807 if (channel_statistics != (ChannelStatistics *) NULL)
808 {
809 /*
810 Detail channel depth and extrema.
811 */
812 (void) FormatLocaleFile(file," Channel depth:\n");
813 switch (colorspace)
814 {
815 case RGBColorspace:
816 case sRGBColorspace:
817 {
818 if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0)
819 (void) FormatLocaleFile(file," Red: %.20g-bit\n",(double)
820 channel_statistics[RedPixelChannel].depth);
821 if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0)
822 (void) FormatLocaleFile(file," Green: %.20g-bit\n",(double)
823 channel_statistics[GreenPixelChannel].depth);
824 if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0)
825 (void) FormatLocaleFile(file," Blue: %.20g-bit\n",(double)
826 channel_statistics[BluePixelChannel].depth);
827 break;
828 }
829 case CMYKColorspace:
830 {
831 if ((GetPixelCyanTraits(image) & UpdatePixelTrait) != 0)
832 (void) FormatLocaleFile(file," Cyan: %.20g-bit\n",(double)
833 channel_statistics[CyanPixelChannel].depth);
834 if ((GetPixelMagentaTraits(image) & UpdatePixelTrait) != 0)
835 (void) FormatLocaleFile(file," Magenta: %.20g-bit\n",(double)
836 channel_statistics[MagentaPixelChannel].depth);
837 if ((GetPixelYellowTraits(image) & UpdatePixelTrait) != 0)
838 (void) FormatLocaleFile(file," Yellow: %.20g-bit\n",(double)
839 channel_statistics[YellowPixelChannel].depth);
840 if ((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0)
841 (void) FormatLocaleFile(file," Black: %.20g-bit\n",(double)
842 channel_statistics[BlackPixelChannel].depth);
843 break;
844 }
845 case LinearGRAYColorspace:
846 case GRAYColorspace:
847 {
848 if ((GetPixelGrayTraits(image) & UpdatePixelTrait) != 0)
849 (void) FormatLocaleFile(file," Gray: %.20g-bit\n",(double)
850 channel_statistics[GrayPixelChannel].depth);
851 break;
852 }
853 default:
854 {
855 for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
856 {
857 PixelChannel channel = GetPixelChannelChannel(image,i);
858 PixelTrait traits = GetPixelChannelTraits(image,channel);
859 if ((traits & UpdatePixelTrait) != 0)
860 (void) FormatLocaleFile(file," Channel %.20g: %.20g-bit\n",
861 (double) i,(double) channel_statistics[channel].depth);
862 }
863 break;
864 }
865 }
866 if (image->alpha_trait != UndefinedPixelTrait)
867 (void) FormatLocaleFile(file," Alpha: %.20g-bit\n",(double)
868 channel_statistics[AlphaPixelChannel].depth);
869 if ((image->channels & ReadMaskChannel) != 0)
870 (void) FormatLocaleFile(file," Read mask: %.20g-bit\n",(double)
871 channel_statistics[ReadMaskPixelChannel].depth);
872 if ((image->channels & WriteMaskChannel) != 0)
873 (void) FormatLocaleFile(file," Write mask: %.20g-bit\n",(double)
874 channel_statistics[WriteMaskPixelChannel].depth);
875 if ((image->channels & CompositeMaskChannel) != 0)
876 (void) FormatLocaleFile(file," Composite mask: %.20g-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++)
880 {
881 PixelChannel
882 channel = (PixelChannel) (MetaPixelChannels+i);
883
884 (void) FormatLocaleFile(file," Meta channel[%.20g]: %.20g-bit\n",
885 (double) i,(double) channel_statistics[channel].depth);
886 }
887 scale=1.0;
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: %.20g\n",(double)
893 image->columns*image->rows);
894 switch (colorspace)
895 {
896 case RGBColorspace:
897 case sRGBColorspace:
898 {
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);
908 break;
909 }
910 case CMYKColorspace:
911 {
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);
924 break;
925 }
926 case LinearGRAYColorspace:
927 case GRAYColorspace:
928 {
929 if ((GetPixelGrayTraits(image) & UpdatePixelTrait) != 0)
930 (void) PrintChannelStatistics(file,GrayPixelChannel,"Gray",1.0/
931 scale,channel_statistics);
932 break;
933 }
934 default:
935 {
936 for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
937 {
938 char
939 label[MagickPathExtent];
940
941 PixelChannel channel = GetPixelChannelChannel(image,i);
942 PixelTrait traits = GetPixelChannelTraits(image,channel);
943 if ((traits & UpdatePixelTrait) != 0)
944 {
945 (void) FormatLocaleString(label,MagickPathExtent,
946 "Channel %.20g",(double) i);
947 (void) PrintChannelStatistics(file,channel,label,1.0/scale,
948 channel_statistics);
949 }
950 }
951 break;
952 }
953 }
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++)
968 {
969 char
970 label[MagickPathExtent];
971
972 PixelChannel
973 channel = (PixelChannel) (MetaPixelChannels+i);
974
975 (void) FormatLocaleString(label,MagickPathExtent,
976 "Meta channel[%.20g]",(double) i);
977 (void) PrintChannelStatistics(file,channel,label,1.0/scale,
978 channel_statistics);
979 }
980 if ((colorspace != LinearGRAYColorspace) &&
981 (colorspace != GRAYColorspace))
982 {
983 (void) FormatLocaleFile(file," Image statistics:\n");
984 (void) PrintChannelStatistics(file,CompositePixelChannel,"Overall",
985 1.0/scale,channel_statistics);
986 }
987 channel_statistics=(ChannelStatistics *) RelinquishMagickMemory(
988 channel_statistics);
989 }
990 if (channel_moments != (ChannelMoments *) NULL)
991 {
992 scale=(double) ((1UL << image->depth)-1);
993 (void) FormatLocaleFile(file," Channel moments:\n");
994 switch (colorspace)
995 {
996 case RGBColorspace:
997 case sRGBColorspace:
998 {
999 if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0)
1000 (void) PrintChannelMoments(file,RedPixelChannel,"Red",scale,
1001 channel_moments);
1002 if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0)
1003 (void) PrintChannelMoments(file,GreenPixelChannel,"Green",scale,
1004 channel_moments);
1005 if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0)
1006 (void) PrintChannelMoments(file,BluePixelChannel,"Blue",scale,
1007 channel_moments);
1008 break;
1009 }
1010 case CMYKColorspace:
1011 {
1012 if ((GetPixelCyanTraits(image) & UpdatePixelTrait) != 0)
1013 (void) PrintChannelMoments(file,CyanPixelChannel,"Cyan",scale,
1014 channel_moments);
1015 if ((GetPixelMagentaTraits(image) & UpdatePixelTrait) != 0)
1016 (void) PrintChannelMoments(file,MagentaPixelChannel,"Magenta",scale,
1017 channel_moments);
1018 if ((GetPixelYellowTraits(image) & UpdatePixelTrait) != 0)
1019 (void) PrintChannelMoments(file,YellowPixelChannel,"Yellow",scale,
1020 channel_moments);
1021 if ((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0)
1022 (void) PrintChannelMoments(file,BlackPixelChannel,"Black",scale,
1023 channel_moments);
1024 break;
1025 }
1026 case GRAYColorspace:
1027 {
1028 if ((GetPixelGrayTraits(image) & UpdatePixelTrait) != 0)
1029 (void) PrintChannelMoments(file,GrayPixelChannel,"Gray",scale,
1030 channel_moments);
1031 break;
1032 }
1033 default:
1034 {
1035 for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
1036 {
1037 char
1038 label[MagickPathExtent];
1039
1040 PixelChannel channel = GetPixelChannelChannel(image,i);
1041 PixelTrait traits = GetPixelChannelTraits(image,channel);
1042 if ((traits & UpdatePixelTrait) != 0)
1043 {
1044 (void) FormatLocaleString(label,MagickPathExtent,
1045 "Channel %.20g",(double) i);
1046 (void) PrintChannelMoments(file,channel,label,scale,
1047 channel_moments);
1048 }
1049 }
1050 break;
1051 }
1052 }
1053 if (image->alpha_trait != UndefinedPixelTrait)
1054 (void) PrintChannelMoments(file,AlphaPixelChannel,"Alpha",scale,
1055 channel_moments);
1056 if (colorspace != GRAYColorspace)
1057 {
1058 (void) FormatLocaleFile(file," Image moments:\n");
1059 (void) PrintChannelMoments(file,CompositePixelChannel,"Overall",scale,
1060 channel_moments);
1061 }
1062 channel_moments=(ChannelMoments *) RelinquishMagickMemory(
1063 channel_moments);
1064 }
1065 if (channel_phash != (ChannelPerceptualHash *) NULL)
1066 {
1067 (void) PrintChannelPerceptualHash(image,file,channel_phash);
1068 channel_phash=(ChannelPerceptualHash *) RelinquishMagickMemory(
1069 channel_phash);
1070 }
1071 if (channel_features != (ChannelFeatures *) NULL)
1072 {
1073 (void) FormatLocaleFile(file," Channel features (horizontal, vertical, "
1074 "left and right diagonals, average):\n");
1075 switch (colorspace)
1076 {
1077 case RGBColorspace:
1078 case sRGBColorspace:
1079 {
1080 if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0)
1081 (void) PrintChannelFeatures(file,RedPixelChannel,"Red",
1082 channel_features);
1083 if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0)
1084 (void) PrintChannelFeatures(file,GreenPixelChannel,"Green",
1085 channel_features);
1086 if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0)
1087 (void) PrintChannelFeatures(file,BluePixelChannel,"Blue",
1088 channel_features);
1089 break;
1090 }
1091 case CMYKColorspace:
1092 {
1093 if ((GetPixelCyanTraits(image) & UpdatePixelTrait) != 0)
1094 (void) PrintChannelFeatures(file,CyanPixelChannel,"Cyan",
1095 channel_features);
1096 if ((GetPixelMagentaTraits(image) & UpdatePixelTrait) != 0)
1097 (void) PrintChannelFeatures(file,MagentaPixelChannel,"Magenta",
1098 channel_features);
1099 if ((GetPixelYellowTraits(image) & UpdatePixelTrait) != 0)
1100 (void) PrintChannelFeatures(file,YellowPixelChannel,"Yellow",
1101 channel_features);
1102 if ((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0)
1103 (void) PrintChannelFeatures(file,BlackPixelChannel,"Black",
1104 channel_features);
1105 break;
1106 }
1107 case GRAYColorspace:
1108 {
1109 if ((GetPixelGrayTraits(image) & UpdatePixelTrait) != 0)
1110 (void) PrintChannelFeatures(file,GrayPixelChannel,"Gray",
1111 channel_features);
1112 break;
1113 }
1114 default:
1115 {
1116 for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
1117 {
1118 char
1119 label[MagickPathExtent];
1120
1121 PixelChannel channel = GetPixelChannelChannel(image,i);
1122 PixelTrait traits = GetPixelChannelTraits(image,channel);
1123 if ((traits & UpdatePixelTrait) != 0)
1124 {
1125 (void) FormatLocaleString(label,MagickPathExtent,
1126 "Channel %.20g",(double) i);
1127 (void) PrintChannelFeatures(file,channel,label,
1128 channel_features);
1129 }
1130 }
1131 break;
1132 }
1133 }
1134 if (image->alpha_trait != UndefinedPixelTrait)
1135 (void) PrintChannelFeatures(file,AlphaPixelChannel,"Alpha",
1136 channel_features);
1137 channel_features=(ChannelFeatures *) RelinquishMagickMemory(
1138 channel_features);
1139 }
1140 if (ping == MagickFalse)
1141 {
1142 if (colorspace == CMYKColorspace)
1143 (void) FormatLocaleFile(file," Total ink density: %.*g%%\n",
1144 GetMagickPrecision(),100.0*GetImageTotalInkDensity(image,exception)/
1145 (double) QuantumRange);
1146 x=0;
1147 if (image->alpha_trait != UndefinedPixelTrait)
1148 {
1149 MagickBooleanType
1150 found = MagickFalse;
1151
1152 p=(const Quantum *) NULL;
1153 for (y=0; y < (ssize_t) image->rows; y++)
1154 {
1155 p=GetVirtualPixels(image,0,y,image->columns,1,exception);
1156 if (p == (const Quantum *) NULL)
1157 break;
1158 for (x=0; x < (ssize_t) image->columns; x++)
1159 {
1160 if (GetPixelAlpha(image,p) == (Quantum) TransparentAlpha)
1161 {
1162 found=MagickTrue;
1163 break;
1164 }
1165 p+=(ptrdiff_t) GetPixelChannels(image);
1166 }
1167 if (found != MagickFalse)
1168 break;
1169 }
1170 if (found != MagickFalse)
1171 {
1172 char
1173 tuple[MagickPathExtent];
1174
1175 PixelInfo
1176 pixel;
1177
1178 GetPixelInfo(image,&pixel);
1179 GetPixelInfoPixel(image,p,&pixel);
1180 (void) QueryColorname(image,&pixel,SVGCompliance,tuple,
1181 exception);
1182 (void) FormatLocaleFile(file," Alpha: %s ",tuple);
1183 GetColorTuple(&pixel,MagickTrue,tuple);
1184 (void) FormatLocaleFile(file," %s\n",tuple);
1185 }
1186 }
1187 if (IsHistogramImage(image,exception) != MagickFalse)
1188 {
1189 (void) FormatLocaleFile(file," Colors: %.20g\n",(double)
1190 GetNumberColors(image,(FILE *) NULL,exception));
1191 (void) FormatLocaleFile(file," Histogram:\n");
1192 (void) GetNumberColors(image,file,exception);
1193 }
1194 else
1195 {
1196 artifact=GetImageArtifact(image,"identify:unique-colors");
1197 if (IsStringTrue(artifact) != MagickFalse)
1198 (void) FormatLocaleFile(file," Colors: %.20g\n",(double)
1199 GetNumberColors(image,(FILE *) NULL,exception));
1200 }
1201 }
1202 if (image->storage_class == PseudoClass)
1203 {
1204 (void) FormatLocaleFile(file," Colormap entries: %.20g\n",(double)
1205 image->colors);
1206 (void) FormatLocaleFile(file," Colormap:\n");
1207 if (image->colors <= 1024)
1208 {
1209 char
1210 hex[MagickPathExtent],
1211 tuple[MagickPathExtent];
1212
1213 PixelInfo
1214 pixel;
1215
1216 PixelInfo
1217 *magick_restrict c;
1218
1219 GetPixelInfo(image,&pixel);
1220 c=image->colormap;
1221 for (i=0; i < (ssize_t) image->colors; i++)
1222 {
1223 pixel=(*c);
1224 (void) CopyMagickString(tuple,"(",MagickPathExtent);
1225 ConcatenateColorComponent(&pixel,RedPixelChannel,X11Compliance,
1226 tuple);
1227 (void) ConcatenateMagickString(tuple,",",MagickPathExtent);
1228 ConcatenateColorComponent(&pixel,GreenPixelChannel,X11Compliance,
1229 tuple);
1230 (void) ConcatenateMagickString(tuple,",",MagickPathExtent);
1231 ConcatenateColorComponent(&pixel,BluePixelChannel,X11Compliance,
1232 tuple);
1233 if (pixel.colorspace == CMYKColorspace)
1234 {
1235 (void) ConcatenateMagickString(tuple,",",MagickPathExtent);
1236 ConcatenateColorComponent(&pixel,BlackPixelChannel,
1237 X11Compliance,tuple);
1238 }
1239 if (pixel.alpha_trait != UndefinedPixelTrait)
1240 {
1241 (void) ConcatenateMagickString(tuple,",",MagickPathExtent);
1242 ConcatenateColorComponent(&pixel,AlphaPixelChannel,
1243 X11Compliance,tuple);
1244 }
1245 (void) ConcatenateMagickString(tuple,")",MagickPathExtent);
1246 (void) QueryColorname(image,&pixel,SVGCompliance,color,
1247 exception);
1248 GetColorTuple(&pixel,MagickTrue,hex);
1249 (void) FormatLocaleFile(file," %g: %s %s %s\n",(double) i,tuple,
1250 hex,color);
1251 c++;
1252 }
1253 }
1254 }
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))
1273 {
1274 /*
1275 Display image chromaticity.
1276 */
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);
1290 }
1291 if ((image->extract_info.width*image->extract_info.height) != 0)
1292 (void) FormatLocaleFile(file," Tile geometry: %.20gx%.20g%+.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,
1296 exception);
1297 (void) FormatLocaleFile(file," Matte color: %s\n",color);
1298 (void) QueryColorname(image,&image->background_color,SVGCompliance,color,
1299 exception);
1300 (void) FormatLocaleFile(file," Background color: %s\n",color);
1301 (void) QueryColorname(image,&image->border_color,SVGCompliance,color,
1302 exception);
1303 (void) FormatLocaleFile(file," Border color: %s\n",color);
1304 (void) QueryColorname(image,&image->transparent_color,SVGCompliance,color,
1305 exception);
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: %.20gx%.20g%+.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: %.20gx%.20g\n",(double) image->delay,
1325 (double) image->ticks_per_second);
1326 if (image->iterations != 1)
1327 (void) FormatLocaleFile(file," Iterations: %.20g\n",(double)
1328 image->iterations);
1329 if (image->duration != 0)
1330 (void) FormatLocaleFile(file," Duration: %.20g\n",(double)
1331 image->duration);
1332 if ((image->next != (Image *) NULL) || (image->previous != (Image *) NULL))
1333 (void) FormatLocaleFile(file," Scene: %.20g of %.20g\n",(double)
1334 image->scene,(double) GetImageListLength(image));
1335 else
1336 if (image->scene != 0)
1337 (void) FormatLocaleFile(file," Scene: %.20g\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: %.20g\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)
1347 {
1348 Image
1349 *tile;
1350
1351 ImageInfo
1352 *image_info;
1353
1354 char
1355 *d,
1356 *q;
1357
1358 WarningHandler
1359 handler;
1360
1361 /*
1362 Display visual image directory.
1363 */
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++)
1368 {
1369 q=d;
1370 while ((*q != '\xff') && (*q != '\0') &&
1371 ((size_t) (q-d) < sizeof(image_info->filename)))
1372 q++;
1373 (void) CopyMagickString(image_info->filename,d,(size_t) (q-d+1));
1374 d=q;
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)
1380 {
1381 (void) FormatLocaleFile(file,"\n");
1382 continue;
1383 }
1384 (void) FormatLocaleFile(file," %.20gx%.20g %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)
1390 {
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);
1396 }
1397 tile=DestroyImage(tile);
1398 }
1399 image_info=DestroyImageInfo(image_info);
1400 }
1401 (void) FormatLocaleString(key,MagickPathExtent,"8BIM:1999,2998:#1");
1402 value=GetImageProperty(image,key,exception);
1403 if (value != (const char *) NULL)
1404 {
1405 /*
1406 Display clipping path.
1407 */
1408 (void) FormatLocaleFile(file," Clipping path: ");
1409 if (strlen(value) > 80)
1410 (void) fputc('\n',file);
1411 (void) FormatLocaleFile(file,"%s\n",value);
1412 }
1413 artifact=GetImageArtifact(image,"identify:convex-hull");
1414 if (IsStringTrue(artifact) != MagickFalse)
1415 {
1416 char
1417 *points;
1418
1419 PointInfo
1420 *bounding_box,
1421 *convex_hull;
1422
1423 ssize_t
1424 n;
1425
1426 size_t
1427 number_points;
1428
1429 /*
1430 Display convex hull & minimum bounding box.
1431 */
1432 convex_hull=GetImageConvexHull(image,&number_points,exception);
1433 if (convex_hull != (PointInfo *) NULL)
1434 {
1435 points=AcquireString("");
1436 for (n=0; n < (ssize_t) number_points; n++)
1437 {
1438 (void) FormatLocaleString(buffer,MagickPathExtent,"%g,%g ",
1439 convex_hull[n].x,convex_hull[n].y);
1440 (void) ConcatenateString(&points,buffer);
1441 }
1442 convex_hull=(PointInfo *) RelinquishMagickMemory(convex_hull);
1443 (void) FormatLocaleFile(file," Convex hull: ");
1444 (void) FormatLocaleFile(file,"%s\n",points);
1445 points=DestroyString(points);
1446 }
1447 bounding_box=GetImageMinimumBoundingBox(image,&number_points,exception);
1448 if (bounding_box != (PointInfo *) NULL)
1449 {
1450 points=AcquireString("");
1451 for (n=0; n < (ssize_t) number_points; n++)
1452 {
1453 (void) FormatLocaleString(buffer,MagickPathExtent,"%g,%g ",
1454 bounding_box[n].x,bounding_box[n].y);
1455 (void) ConcatenateString(&points,buffer);
1456 }
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);
1461 }
1462 }
1463 ResetImageProfileIterator(image);
1464 name=GetNextImageProfile(image);
1465 if (name != (char *) NULL)
1466 {
1467 const StringInfo
1468 *profile;
1469
1470 /*
1471 Identify image profiles.
1472 */
1473 (void) FormatLocaleFile(file," Profiles:\n");
1474 while (name != (char *) NULL)
1475 {
1476 profile=GetImageProfile(image,name);
1477 if (profile == (StringInfo *) NULL)
1478 continue;
1479 (void) FormatLocaleFile(file," Profile-%s: %.20g bytes\n",name,
1480 (double) GetStringInfoLength(profile));
1481 if (LocaleCompare(name,"iptc") == 0)
1482 {
1483 char
1484 *attribute,
1485 **attribute_list;
1486
1487 const char
1488 *tag;
1489
1490 long
1491 dataset,
1492 record,
1493 sentinel;
1494
1495 ssize_t
1496 j;
1497
1498 size_t
1499 length,
1500 profile_length;
1501
1502 profile_length=GetStringInfoLength(profile);
1503 for (i=0; i < (ssize_t) profile_length-5; i+=(ssize_t) length)
1504 {
1505 length=1;
1506 sentinel=GetStringInfoDatum(profile)[i++];
1507 if (sentinel != 0x1c)
1508 continue;
1509 dataset=GetStringInfoDatum(profile)[i++];
1510 record=GetStringInfoDatum(profile)[i++];
1511 switch (record)
1512 {
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;
1567 }
1568 (void) FormatLocaleFile(file," %s[%.20g,%.20g]: ",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)
1578 {
1579 (void) CopyMagickString(attribute,(char *)
1580 GetStringInfoDatum(profile)+i,length+1);
1581 attribute_list=StringToList(attribute);
1582 if (attribute_list != (char **) NULL)
1583 {
1584 for (j=0; attribute_list[j] != (char *) NULL; j++)
1585 {
1586 (void) fputs(attribute_list[j],file);
1587 (void) fputs("\n",file);
1588 attribute_list[j]=(char *) RelinquishMagickMemory(
1589 attribute_list[j]);
1590 }
1591 attribute_list=(char **) RelinquishMagickMemory(
1592 attribute_list);
1593 }
1594 attribute=DestroyString(attribute);
1595 }
1596 }
1597 }
1598 if (image->debug != MagickFalse)
1599 PrintStringInfo(file,name,profile);
1600 name=GetNextImageProfile(image);
1601 }
1602 }
1603 ResetImagePropertyIterator(image);
1604 property=GetNextImageProperty(image);
1605 if (property != (const char *) NULL)
1606 {
1607 /*
1608 Display image properties.
1609 */
1610 (void) FormatLocaleFile(file," Properties:\n");
1611 while (property != (const char *) NULL)
1612 {
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);
1618 }
1619 }
1620 ResetImageArtifactIterator(image);
1621 artifact=GetNextImageArtifact(image);
1622 if (artifact != (const char *) NULL)
1623 {
1624 /*
1625 Display image artifacts.
1626 */
1627 (void) FormatLocaleFile(file," Artifacts:\n");
1628 while (artifact != (const char *) NULL)
1629 {
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);
1635 }
1636 }
1637 ResetImageRegistryIterator();
1638 registry=GetNextImageRegistry();
1639 if (registry != (const char *) NULL)
1640 {
1641 /*
1642 Display image registry.
1643 */
1644 (void) FormatLocaleFile(file," Registry:\n");
1645 while (registry != (const char *) NULL)
1646 {
1647 (void) FormatLocaleFile(file," %s: ",registry);
1648 value=(const char *) GetImageRegistry(StringRegistryType,registry,
1649 exception);
1650 if (value != (const char *) NULL)
1651 (void) FormatLocaleFile(file,"%s\n",value);
1652 registry=GetNextImageRegistry();
1653 }
1654 }
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)
1669 {
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);
1673 }
1674 if (image->ttl != (time_t) 0)
1675 {
1676 char
1677 iso8601[sizeof("9999-99-99T99:99:99Z")];
1678
1679 int
1680 seconds;
1681
1682 struct tm
1683 timestamp;
1684
1685 (void) GetMagickUTCTime(&image->ttl,&timestamp);
1686 (void) strftime(iso8601,sizeof(iso8601),"%Y-%m-%dT%H:%M:%SZ",&timestamp);
1687 seconds=MagickMax((int)(image->ttl-GetMagickTime()),0);
1688 expired=' ';
1689 if (seconds == 0)
1690 expired='*';
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);
1696 }
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 *)
1702 NULL));
1703 (void) fflush(file);
1704 return(ferror(file) != 0 ? MagickFalse : MagickTrue);
1705}