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-2008 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 "magick/studio.h"
46 #include "magick/annotate.h"
47 #include "magick/artifact.h"
48 #include "magick/attribute.h"
49 #include "magick/blob.h"
50 #include "magick/cache.h"
51 #include "magick/client.h"
52 #include "magick/coder.h"
53 #include "magick/color.h"
54 #include "magick/configure.h"
55 #include "magick/constitute.h"
56 #include "magick/decorate.h"
57 #include "magick/delegate.h"
58 #include "magick/draw.h"
59 #include "magick/effect.h"
60 #include "magick/exception.h"
61 #include "magick/exception-private.h"
62 #include "magick/feature.h"
63 #include "magick/gem.h"
64 #include "magick/geometry.h"
65 #include "magick/histogram.h"
66 #include "magick/identify.h"
67 #include "magick/image.h"
68 #include "magick/image-private.h"
69 #include "magick/list.h"
70 #include "magick/locale_.h"
71 #include "magick/log.h"
72 #include "magick/magic.h"
73 #include "magick/magick.h"
74 #include "magick/memory_.h"
75 #include "magick/module.h"
76 #include "magick/monitor.h"
77 #include "magick/montage.h"
78 #include "magick/option.h"
79 #include "magick/pixel-private.h"
80 #include "magick/prepress.h"
81 #include "magick/profile.h"
82 #include "magick/property.h"
83 #include "magick/quantize.h"
84 #include "magick/quantum.h"
85 #include "magick/random_.h"
86 #include "magick/registry.h"
87 #include "magick/resize.h"
88 #include "magick/resource_.h"
89 #include "magick/signature.h"
90 #include "magick/statistic.h"
91 #include "magick/string_.h"
92 #include "magick/string-private.h"
93 #include "magick/timer.h"
94 #include "magick/utility.h"
95 #include "magick/version.h"
96 #if defined(MAGICKCORE_LCMS_DELEGATE)
97 #if defined(MAGICKCORE_HAVE_LCMS_LCMS2_H)
98 #include <lcms/lcms2.h>
99 #elif defined(MAGICKCORE_HAVE_LCMS2_H)
101 #elif defined(MAGICKCORE_HAVE_LCMS_LCMS_H)
102 #include <lcms/lcms.h>
111 #if defined(MAGICKCORE_LCMS_DELEGATE)
112 #if defined(LCMS_VERSION) && (LCMS_VERSION < 2000)
113 #define cmsUInt32Number DWORD
118 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
122 % I d e n t i f y I m a g e %
126 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
128 % IdentifyImage() identifies an image by printing its attributes to the file.
129 % Attributes include the image width, height, size, and others.
131 % The format of the IdentifyImage method is:
133 % MagickBooleanType IdentifyImage(Image *image,FILE *file,
134 % const MagickBooleanType verbose)
136 % A description of each parameter follows:
138 % o image: the image.
140 % o file: the file, typically stdout.
142 % o verbose: A value other than zero prints more detailed information
147 static int PrintChannelFeatures(FILE *file,const ChannelType channel,
148 const char *name,const ChannelFeatures *channel_features)
150 #define PrintFeature(feature) \
151 GetMagickPrecision(),(feature)[0], \
152 GetMagickPrecision(),(feature)[1], \
153 GetMagickPrecision(),(feature)[2], \
154 GetMagickPrecision(),(feature)[3], \
155 GetMagickPrecision(),((feature)[0]+(feature)[1]+(feature)[2]+(feature)[3])/4.0 \
157 #define FeaturesFormat " %s:\n" \
158 " Angular Second Moment:\n" \
159 " %.*g, %.*g, %.*g, %.*g, %.*g\n" \
161 " %.*g, %.*g, %.*g, %.*g, %.*g\n" \
163 " %.*g, %.*g, %.*g, %.*g, %.*g\n" \
164 " Sum of Squares: Variance:\n" \
165 " %.*g, %.*g, %.*g, %.*g, %.*g\n" \
166 " Inverse Difference Moment:\n" \
167 " %.*g, %.*g, %.*g, %.*g, %.*g\n" \
169 " %.*g, %.*g, %.*g, %.*g, %.*g\n" \
171 " %.*g, %.*g, %.*g, %.*g, %.*g\n" \
173 " %.*g, %.*g, %.*g, %.*g, %.*g\n" \
175 " %.*g, %.*g, %.*g, %.*g, %.*g\n" \
176 " Difference Variance:\n" \
177 " %.*g, %.*g, %.*g, %.*g, %.*g\n" \
178 " Difference Entropy:\n" \
179 " %.*g, %.*g, %.*g, %.*g, %.*g\n" \
180 " Information Measure of Correlation 1:\n" \
181 " %.*g, %.*g, %.*g, %.*g, %.*g\n" \
182 " Information Measure of Correlation 2:\n" \
183 " %.*g, %.*g, %.*g, %.*g, %.*g\n" \
184 " Maximum Correlation Coefficient:\n" \
185 " %.*g, %.*g, %.*g, %.*g, %.*g\n"
190 status=fprintf(file,FeaturesFormat,name,
191 PrintFeature(channel_features[channel].angular_second_moment),
192 PrintFeature(channel_features[channel].contrast),
193 PrintFeature(channel_features[channel].correlation),
194 PrintFeature(channel_features[channel].variance_sum_of_squares),
195 PrintFeature(channel_features[channel].inverse_difference_moment),
196 PrintFeature(channel_features[channel].sum_average),
197 PrintFeature(channel_features[channel].sum_variance),
198 PrintFeature(channel_features[channel].sum_entropy),
199 PrintFeature(channel_features[channel].entropy),
200 PrintFeature(channel_features[channel].difference_variance),
201 PrintFeature(channel_features[channel].difference_entropy),
202 PrintFeature(channel_features[channel].measure_of_correlation_1),
203 PrintFeature(channel_features[channel].measure_of_correlation_2),
204 PrintFeature(channel_features[channel].maximum_correlation_coefficient));
208 static int PrintChannelStatistics(FILE *file,const ChannelType channel,
209 const char *name,const double scale,
210 const ChannelStatistics *channel_statistics)
212 #define StatisticsFormat " %s:\n min: " QuantumFormat \
213 " (%g)\n max: " QuantumFormat " (%g)\n" \
214 " mean: %g (%g)\n standard deviation: %g (%g)\n" \
215 " kurtosis: %g\n skewness: %g\n"
220 if (channel == AlphaChannel)
222 status=fprintf(file,StatisticsFormat,name,ClampToQuantum(scale*
223 (QuantumRange-channel_statistics[channel].maxima)),
224 (QuantumRange-channel_statistics[channel].maxima)/(double) QuantumRange,
225 ClampToQuantum(scale*(QuantumRange-channel_statistics[channel].minima)),
226 (QuantumRange-channel_statistics[channel].minima)/(double) QuantumRange,
227 scale*(QuantumRange-channel_statistics[channel].mean),(QuantumRange-
228 channel_statistics[channel].mean)/(double) QuantumRange,scale*
229 channel_statistics[channel].standard_deviation,
230 channel_statistics[channel].standard_deviation/(double) QuantumRange,
231 channel_statistics[channel].kurtosis,
232 channel_statistics[channel].skewness);
235 status=fprintf(file,StatisticsFormat,name,ClampToQuantum(scale*
236 channel_statistics[channel].minima),channel_statistics[channel].minima/
237 (double) QuantumRange,ClampToQuantum(scale*
238 channel_statistics[channel].maxima),channel_statistics[channel].maxima/
239 (double) QuantumRange,scale*channel_statistics[channel].mean,
240 channel_statistics[channel].mean/(double) QuantumRange,scale*
241 channel_statistics[channel].standard_deviation,
242 channel_statistics[channel].standard_deviation/(double) QuantumRange,
243 channel_statistics[channel].kurtosis,channel_statistics[channel].skewness);
247 MagickExport MagickBooleanType IdentifyImage(Image *image,FILE *file,
248 const MagickBooleanType verbose)
251 color[MaxTextExtent],
252 format[MaxTextExtent],
301 assert(image != (Image *) NULL);
302 assert(image->signature == MagickSignature);
303 if (image->debug != MagickFalse)
304 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
305 if (file == (FILE *) NULL)
308 elapsed_time=GetElapsedTime(&image->timer);
309 user_time=GetUserTime(&image->timer);
310 GetTimerInfo(&image->timer);
311 if (verbose == MagickFalse)
314 Display summary info about the image.
316 if (*image->magick_filename != '\0')
317 if (LocaleCompare(image->magick_filename,image->filename) != 0)
318 (void) fprintf(file,"%s=>",image->magick_filename);
319 if ((GetPreviousImageInList(image) == (Image *) NULL) &&
320 (GetNextImageInList(image) == (Image *) NULL) &&
322 (void) fprintf(file,"%s ",image->filename);
324 (void) fprintf(file,"%s[%.20g] ",image->filename,(double) image->scene);
325 (void) fprintf(file,"%s ",image->magick);
326 if ((image->magick_columns != 0) || (image->magick_rows != 0))
327 if ((image->magick_columns != image->columns) ||
328 (image->magick_rows != image->rows))
329 (void) fprintf(file,"%.20gx%.20g=>",(double) image->magick_columns,
330 (double) image->magick_rows);
331 (void) fprintf(file,"%.20gx%.20g ",(double) image->columns,(double)
333 if ((image->page.width != 0) || (image->page.height != 0) ||
334 (image->page.x != 0) || (image->page.y != 0))
335 (void) fprintf(file,"%.20gx%.20g%+.20g%+.20g ",(double)
336 image->page.width,(double) image->page.height,(double) image->page.x,
337 (double) image->page.y);
338 (void) fprintf(file,"%.20g-bit ",(double) image->depth);
339 if (image->type != UndefinedColorType)
340 (void) fprintf(file,"%s ",MagickOptionToMnemonic(MagickTypeOptions,
341 (ssize_t) image->type));
342 if (image->storage_class == DirectClass)
344 (void) fprintf(file,"DirectClass ");
345 if (image->total_colors != 0)
347 (void) FormatMagickSize(image->total_colors,MagickFalse,format);
348 (void) fprintf(file,"%s ",format);
352 if (image->total_colors <= image->colors)
353 (void) fprintf(file,"PseudoClass %.20gc ",(double) image->colors);
355 (void) fprintf(file,"PseudoClass %.20g=>%.20gc ",(double)
356 image->total_colors,(double) image->colors);
357 if (image->error.mean_error_per_pixel != 0.0)
358 (void) fprintf(file,"%.20g/%f/%fdb ",(double)
359 (image->error.mean_error_per_pixel+0.5),
360 image->error.normalized_mean_error,
361 image->error.normalized_maximum_error);
362 if (GetBlobSize(image) != 0)
364 (void) FormatMagickSize(GetBlobSize(image),MagickFalse,format);
365 (void) fprintf(file,"%s ",format);
367 (void) fprintf(file,"%0.3fu %lu:%02lu.%03lu",user_time,(unsigned long)
368 (elapsed_time/60.0),(unsigned long) floor(fmod(elapsed_time,60.0)),
369 (unsigned long) (1000.0*(elapsed_time-floor(elapsed_time))));
370 (void) fprintf(file,"\n");
372 return(ferror(file) != 0 ? MagickFalse : MagickTrue);
375 Display verbose info about the image.
377 exception=AcquireExceptionInfo();
378 pixels=GetVirtualPixels(image,0,0,1,1,exception);
379 exception=DestroyExceptionInfo(exception);
380 ping=pixels == (const PixelPacket *) NULL ? MagickTrue : MagickFalse;
381 type=GetImageType(image,&image->exception);
382 (void) SignatureImage(image);
383 (void) fprintf(file,"Image: %s\n",image->filename);
384 if (*image->magick_filename != '\0')
385 if (LocaleCompare(image->magick_filename,image->filename) != 0)
388 filename[MaxTextExtent];
390 GetPathComponent(image->magick_filename,TailPath,filename);
391 (void) fprintf(file," Base filename: %s\n",filename);
393 magick_info=GetMagickInfo(image->magick,&image->exception);
394 if ((magick_info == (const MagickInfo *) NULL) ||
395 (*GetMagickDescription(magick_info) == '\0'))
396 (void) fprintf(file," Format: %s\n",image->magick);
398 (void) fprintf(file," Format: %s (%s)\n",image->magick,
399 GetMagickDescription(magick_info));
400 (void) fprintf(file," Class: %s\n",MagickOptionToMnemonic(MagickClassOptions,
401 (ssize_t) image->storage_class));
402 (void) fprintf(file," Geometry: %.20gx%.20g%+.20g%+.20g\n",(double)
403 image->columns,(double) image->rows,(double) image->tile_offset.x,(double)
404 image->tile_offset.y);
405 if ((image->magick_columns != 0) || (image->magick_rows != 0))
406 if ((image->magick_columns != image->columns) ||
407 (image->magick_rows != image->rows))
408 (void) fprintf(file," Base geometry: %.20gx%.20g\n",(double)
409 image->magick_columns,(double) image->magick_rows);
410 if ((image->x_resolution != 0.0) && (image->y_resolution != 0.0))
412 (void) fprintf(file," Resolution: %gx%g\n",image->x_resolution,
413 image->y_resolution);
414 (void) fprintf(file," Print size: %gx%g\n",(double) image->columns/
415 image->x_resolution,(double) image->rows/image->y_resolution);
417 (void) fprintf(file," Units: %s\n",MagickOptionToMnemonic(
418 MagickResolutionOptions,(ssize_t) image->units));
419 (void) fprintf(file," Type: %s\n",MagickOptionToMnemonic(MagickTypeOptions,
421 if (image->type != UndefinedColorType)
422 (void) fprintf(file," Base type: %s\n",MagickOptionToMnemonic(
423 MagickTypeOptions,(ssize_t) image->type));
424 (void) fprintf(file," Endianess: %s\n",MagickOptionToMnemonic(
425 MagickEndianOptions,(ssize_t) image->endian));
427 Detail channel depth and extrema.
429 (void) fprintf(file," Colorspace: %s\n",MagickOptionToMnemonic(
430 MagickColorspaceOptions,(ssize_t) image->colorspace));
431 channel_statistics=(ChannelStatistics *) NULL;
432 channel_features=(ChannelFeatures *) NULL;
433 colorspace=image->colorspace;
434 if (ping == MagickFalse)
439 channel_statistics=GetImageChannelStatistics(image,&image->exception);
440 artifact=GetImageArtifact(image,"identify:features");
441 if (artifact != (const char *) NULL)
443 distance=StringToUnsignedLong(artifact);
444 channel_features=GetImageChannelFeatures(image,distance,
447 depth=GetImageDepth(image,&image->exception);
448 if (image->depth == depth)
449 (void) fprintf(file," Depth: %.20g-bit\n",(double) image->depth);
451 (void) fprintf(file," Depth: %.20g/%.20g-bit\n",(double)
452 image->depth,(double) depth);
453 (void) fprintf(file," Channel depth:\n");
454 if (IsGrayImage(image,&image->exception) != MagickFalse)
455 colorspace=GRAYColorspace;
461 (void) fprintf(file," red: %.20g-bit\n",(double)
462 channel_statistics[RedChannel].depth);
463 (void) fprintf(file," green: %.20g-bit\n",(double)
464 channel_statistics[GreenChannel].depth);
465 (void) fprintf(file," blue: %.20g-bit\n",(double)
466 channel_statistics[BlueChannel].depth);
471 (void) fprintf(file," cyan: %.20g-bit\n",(double)
472 channel_statistics[CyanChannel].depth);
473 (void) fprintf(file," magenta: %.20g-bit\n",(double)
474 channel_statistics[MagentaChannel].depth);
475 (void) fprintf(file," yellow: %.20g-bit\n",(double)
476 channel_statistics[YellowChannel].depth);
477 (void) fprintf(file," black: %.20g-bit\n",(double)
478 channel_statistics[BlackChannel].depth);
483 (void) fprintf(file," gray: %.20g-bit\n",(double)
484 channel_statistics[GrayChannel].depth);
488 if (image->matte != MagickFalse)
489 (void) fprintf(file," alpha: %.20g-bit\n",(double)
490 channel_statistics[OpacityChannel].depth);
492 if (image->depth <= MAGICKCORE_QUANTUM_DEPTH)
493 scale=QuantumRange/((size_t) QuantumRange >> ((size_t)
494 MAGICKCORE_QUANTUM_DEPTH-image->depth));
496 if (channel_statistics != (ChannelStatistics *) NULL)
498 (void) fprintf(file," Channel statistics:\n");
504 (void) PrintChannelStatistics(file,RedChannel,"Red",1.0/scale,
506 (void) PrintChannelStatistics(file,GreenChannel,"Green",1.0/scale,
508 (void) PrintChannelStatistics(file,BlueChannel,"Blue",1.0/scale,
514 (void) PrintChannelStatistics(file,CyanChannel,"Cyan",1.0/scale,
516 (void) PrintChannelStatistics(file,MagentaChannel,"Magenta",1.0/scale,
518 (void) PrintChannelStatistics(file,YellowChannel,"Yellow",1.0/scale,
520 (void) PrintChannelStatistics(file,BlackChannel,"Black",1.0/scale,
526 (void) PrintChannelStatistics(file,GrayChannel,"Gray",1.0/scale,
531 if (image->matte != MagickFalse)
532 (void) PrintChannelStatistics(file,AlphaChannel,"Alpha",1.0/scale,
534 if (colorspace != GRAYColorspace)
536 (void) fprintf(file," Image statistics:\n");
537 (void) PrintChannelStatistics(file,AllChannels,"Overall",1.0/scale,
540 channel_statistics=(ChannelStatistics *) RelinquishMagickMemory(
543 if (channel_features != (ChannelFeatures *) NULL)
545 (void) fprintf(file," Channel features (horizontal, vertical, left and right diagonals, average):\n");
551 (void) PrintChannelFeatures(file,RedChannel,"Red",channel_features);
552 (void) PrintChannelFeatures(file,GreenChannel,"Green",
554 (void) PrintChannelFeatures(file,BlueChannel,"Blue",channel_features);
559 (void) PrintChannelFeatures(file,CyanChannel,"Cyan",channel_features);
560 (void) PrintChannelFeatures(file,MagentaChannel,"Magenta",
562 (void) PrintChannelFeatures(file,YellowChannel,"Yellow",
564 (void) PrintChannelFeatures(file,BlackChannel,"Black",
570 (void) PrintChannelFeatures(file,GrayChannel,"Gray",channel_features);
574 if (image->matte != MagickFalse)
575 (void) PrintChannelFeatures(file,AlphaChannel,"Alpha",channel_features);
576 channel_features=(ChannelFeatures *) RelinquishMagickMemory(
579 if (ping == MagickFalse)
581 if (image->colorspace == CMYKColorspace)
582 (void) fprintf(file," Total ink density: %.0f%%\n",100.0*
583 GetImageTotalInkDensity(image)/(double) QuantumRange);
585 if (image->matte != MagickFalse)
587 register const IndexPacket
590 register const PixelPacket
593 p=(PixelPacket *) NULL;
594 indexes=(IndexPacket *) NULL;
595 for (y=0; y < (ssize_t) image->rows; y++)
597 p=GetVirtualPixels(image,0,y,image->columns,1,exception);
598 if (p == (const PixelPacket *) NULL)
600 indexes=GetVirtualIndexQueue(image);
601 for (x=0; x < (ssize_t) image->columns; x++)
603 if (p->opacity == (Quantum) TransparentOpacity)
607 if (x < (ssize_t) image->columns)
610 if ((x < (ssize_t) image->columns) || (y < (ssize_t) image->rows))
613 tuple[MaxTextExtent];
618 GetMagickPixelPacket(image,&pixel);
619 SetMagickPixelPacket(image,p,indexes+x,&pixel);
620 (void) QueryMagickColorname(image,&pixel,SVGCompliance,tuple,
622 (void) fprintf(file," Alpha: %s ",tuple);
623 GetColorTuple(&pixel,MagickTrue,tuple);
624 (void) fprintf(file," %s\n",tuple);
627 artifact=GetImageArtifact(image,"identify:unique-colors");
628 if ((artifact != (const char *) NULL) &&
629 (IsMagickTrue(artifact) != MagickFalse))
630 (void) fprintf(file," Colors: %.20g\n",(double)
631 GetNumberColors(image,(FILE *) NULL,&image->exception));
632 if (IsHistogramImage(image,&image->exception) != MagickFalse)
634 (void) fprintf(file," Histogram:\n");
635 (void) GetNumberColors(image,file,&image->exception);
638 if (image->storage_class == PseudoClass)
640 (void) fprintf(file," Colormap: %.20g\n",(double) image->colors);
641 if (image->colors <= 1024)
644 color[MaxTextExtent],
646 tuple[MaxTextExtent];
654 GetMagickPixelPacket(image,&pixel);
656 for (i=0; i < (ssize_t) image->colors; i++)
658 SetMagickPixelPacket(image,p,(IndexPacket *) NULL,&pixel);
659 (void) CopyMagickString(tuple,"(",MaxTextExtent);
660 ConcatenateColorComponent(&pixel,RedChannel,X11Compliance,tuple);
661 (void) ConcatenateMagickString(tuple,",",MaxTextExtent);
662 ConcatenateColorComponent(&pixel,GreenChannel,X11Compliance,tuple);
663 (void) ConcatenateMagickString(tuple,",",MaxTextExtent);
664 ConcatenateColorComponent(&pixel,BlueChannel,X11Compliance,tuple);
665 if (pixel.colorspace == CMYKColorspace)
667 (void) ConcatenateMagickString(tuple,",",MaxTextExtent);
668 ConcatenateColorComponent(&pixel,IndexChannel,X11Compliance,
671 if (pixel.matte != MagickFalse)
673 (void) ConcatenateMagickString(tuple,",",MaxTextExtent);
674 ConcatenateColorComponent(&pixel,AlphaChannel,X11Compliance,
677 (void) ConcatenateMagickString(tuple,")",MaxTextExtent);
678 (void) QueryMagickColorname(image,&pixel,SVGCompliance,color,
680 GetColorTuple(&pixel,MagickTrue,hex);
681 (void) fprintf(file," %8ld: %s %s %s\n",(long) i,tuple,hex,color);
686 if (image->error.mean_error_per_pixel != 0.0)
687 (void) fprintf(file," Mean error per pixel: %g\n",
688 image->error.mean_error_per_pixel);
689 if (image->error.normalized_mean_error != 0.0)
690 (void) fprintf(file," Normalized mean error: %g\n",
691 image->error.normalized_mean_error);
692 if (image->error.normalized_maximum_error != 0.0)
693 (void) fprintf(file," Normalized maximum error: %g\n",
694 image->error.normalized_maximum_error);
695 (void) fprintf(file," Rendering intent: %s\n",MagickOptionToMnemonic(
696 MagickIntentOptions,(ssize_t) image->rendering_intent));
697 if (image->gamma != 0.0)
698 (void) fprintf(file," Gamma: %g\n",image->gamma);
699 if ((image->chromaticity.red_primary.x != 0.0) ||
700 (image->chromaticity.green_primary.x != 0.0) ||
701 (image->chromaticity.blue_primary.x != 0.0) ||
702 (image->chromaticity.white_point.x != 0.0))
705 Display image chromaticity.
707 (void) fprintf(file," Chromaticity:\n");
708 (void) fprintf(file," red primary: (%g,%g)\n",
709 image->chromaticity.red_primary.x,image->chromaticity.red_primary.y);
710 (void) fprintf(file," green primary: (%g,%g)\n",
711 image->chromaticity.green_primary.x,
712 image->chromaticity.green_primary.y);
713 (void) fprintf(file," blue primary: (%g,%g)\n",
714 image->chromaticity.blue_primary.x,image->chromaticity.blue_primary.y);
715 (void) fprintf(file," white point: (%g,%g)\n",
716 image->chromaticity.white_point.x,image->chromaticity.white_point.y);
718 if ((image->extract_info.width*image->extract_info.height) != 0)
719 (void) fprintf(file," Tile geometry: %.20gx%.20g%+.20g%+.20g\n",(double)
720 image->extract_info.width,(double) image->extract_info.height,(double)
721 image->extract_info.x,(double) image->extract_info.y);
722 (void) fprintf(file," Interlace: %s\n",MagickOptionToMnemonic(
723 MagickInterlaceOptions,(ssize_t) image->interlace));
724 (void) QueryColorname(image,&image->background_color,SVGCompliance,color,
726 (void) fprintf(file," Background color: %s\n",color);
727 (void) QueryColorname(image,&image->border_color,SVGCompliance,color,
729 (void) fprintf(file," Border color: %s\n",color);
730 (void) QueryColorname(image,&image->matte_color,SVGCompliance,color,
732 (void) fprintf(file," Matte color: %s\n",color);
733 (void) QueryColorname(image,&image->transparent_color,SVGCompliance,color,
735 (void) fprintf(file," Transparent color: %s\n",color);
736 (void) fprintf(file," Compose: %s\n",MagickOptionToMnemonic(
737 MagickComposeOptions,(ssize_t) image->compose));
738 if ((image->page.width != 0) || (image->page.height != 0) ||
739 (image->page.x != 0) || (image->page.y != 0))
740 (void) fprintf(file," Page geometry: %.20gx%.20g%+.20g%+.20g\n",(double)
741 image->page.width,(double) image->page.height,(double)
742 image->page.x,(double) image->page.y);
743 if ((image->page.x != 0) || (image->page.y != 0))
744 (void) fprintf(file," Origin geometry: %+.20g%+.20g\n",(double)
745 image->page.x,(double) image->page.y);
746 (void) fprintf(file," Dispose: %s\n",MagickOptionToMnemonic(
747 MagickDisposeOptions,(ssize_t) image->dispose));
748 if (image->delay != 0)
749 (void) fprintf(file," Delay: %.20gx%.20g\n",(double) image->delay,
750 (double) image->ticks_per_second);
751 if (image->iterations != 1)
752 (void) fprintf(file," Iterations: %.20g\n",(double) image->iterations);
753 if ((image->next != (Image *) NULL) || (image->previous != (Image *) NULL))
754 (void) fprintf(file," Scene: %.20g of %.20g\n",(double) image->scene,
755 (double) GetImageListLength(image));
757 if (image->scene != 0)
758 (void) fprintf(file," Scene: %.20g\n",(double) image->scene);
759 (void) fprintf(file," Compression: %s\n",MagickOptionToMnemonic(
760 MagickCompressOptions,(ssize_t) image->compression));
761 if (image->quality != UndefinedCompressionQuality)
762 (void) fprintf(file," Quality: %.20g\n",(double) image->quality);
763 (void) fprintf(file," Orientation: %s\n",MagickOptionToMnemonic(
764 MagickOrientationOptions,(ssize_t) image->orientation));
765 if (image->montage != (char *) NULL)
766 (void) fprintf(file," Montage: %s\n",image->montage);
767 if (image->directory != (char *) NULL)
783 Display visual image directory.
785 image_info=AcquireImageInfo();
786 (void) CloneString(&image_info->size,"64x64");
787 (void) fprintf(file," Directory:\n");
788 for (p=image->directory; *p != '\0'; p++)
791 while ((*q != '\n') && (*q != '\0'))
793 (void) CopyMagickString(image_info->filename,p,(size_t) (q-p+1));
795 (void) fprintf(file," %s",image_info->filename);
796 handler=SetWarningHandler((WarningHandler) NULL);
797 tile=ReadImage(image_info,&image->exception);
798 (void) SetWarningHandler(handler);
799 if (tile == (Image *) NULL)
801 (void) fprintf(file,"\n");
804 (void) fprintf(file," %.20gx%.20g %s\n",(double) tile->magick_columns,
805 (double) tile->magick_rows,tile->magick);
806 (void) SignatureImage(tile);
807 ResetImagePropertyIterator(tile);
808 property=GetNextImageProperty(tile);
809 while (property != (const char *) NULL)
811 (void) fprintf(file," %s:\n",property);
812 value=GetImageProperty(tile,property);
813 if (value != (const char *) NULL)
814 (void) fprintf(file,"%s\n",value);
815 property=GetNextImageProperty(tile);
817 tile=DestroyImage(tile);
819 image_info=DestroyImageInfo(image_info);
821 (void) GetImageProperty(image,"exif:*");
822 ResetImagePropertyIterator(image);
823 property=GetNextImageProperty(image);
824 if (property != (const char *) NULL)
827 Display image properties.
829 (void) fprintf(file," Properties:\n");
830 while (property != (const char *) NULL)
832 (void) fprintf(file," %s: ",property);
833 value=GetImageProperty(image,property);
834 if (value != (const char *) NULL)
835 (void) fprintf(file,"%s\n",value);
836 property=GetNextImageProperty(image);
839 (void) FormatMagickString(key,MaxTextExtent,"8BIM:1999,2998:#1");
840 value=GetImageProperty(image,key);
841 if (value != (const char *) NULL)
844 Display clipping path.
846 (void) fprintf(file," Clipping path: ");
847 if (strlen(value) > 80)
848 (void) fputc('\n',file);
849 (void) fprintf(file,"%s\n",value);
851 ResetImageProfileIterator(image);
852 name=GetNextImageProfile(image);
853 if (name != (char *) NULL)
859 Identify image profiles.
861 (void) fprintf(file," Profiles:\n");
862 while (name != (char *) NULL)
864 profile=GetImageProfile(image,name);
865 if (profile == (StringInfo *) NULL)
867 (void) fprintf(file," Profile-%s: %.20g bytes\n",name,(double)
868 GetStringInfoLength(profile));
869 #if defined(MAGICKCORE_LCMS_DELEGATE)
870 if ((LocaleCompare(name,"icc") == 0) ||
871 (LocaleCompare(name,"icm") == 0))
876 icc_profile=cmsOpenProfileFromMem(GetStringInfoDatum(profile),
877 (cmsUInt32Number) GetStringInfoLength(profile));
878 if (icc_profile != (cmsHPROFILE *) NULL)
880 #if defined(LCMS_VERSION) && (LCMS_VERSION < 2000)
884 name=cmsTakeProductName(icc_profile);
885 if (name != (const char *) NULL)
886 (void) fprintf(file," %s\n",name);
891 (void) cmsGetProfileInfoASCII(icc_profile,cmsInfoDescription,
892 "en","US",info,MaxTextExtent);
893 (void) fprintf(file," Description: %s\n",info);
894 (void) cmsGetProfileInfoASCII(icc_profile,cmsInfoManufacturer,
895 "en","US",info,MaxTextExtent);
896 (void) fprintf(file," Manufacturer: %s\n",info);
897 (void) cmsGetProfileInfoASCII(icc_profile,cmsInfoModel,"en",
898 "US",info,MaxTextExtent);
899 (void) fprintf(file," Model: %s\n",info);
900 (void) cmsGetProfileInfoASCII(icc_profile,cmsInfoCopyright,
901 "en","US",info,MaxTextExtent);
902 (void) fprintf(file," Copyright: %s\n",info);
904 (void) cmsCloseProfile(icc_profile);
908 if (LocaleCompare(name,"iptc") == 0)
929 profile_length=GetStringInfoLength(profile);
930 for (i=0; i < (ssize_t) profile_length; i+=(ssize_t) length)
933 sentinel=GetStringInfoDatum(profile)[i++];
934 if (sentinel != 0x1c)
936 dataset=GetStringInfoDatum(profile)[i++];
937 record=GetStringInfoDatum(profile)[i++];
940 case 5: tag="Image Name"; break;
941 case 7: tag="Edit Status"; break;
942 case 10: tag="Priority"; break;
943 case 15: tag="Category"; break;
944 case 20: tag="Supplemental Category"; break;
945 case 22: tag="Fixture Identifier"; break;
946 case 25: tag="Keyword"; break;
947 case 30: tag="Release Date"; break;
948 case 35: tag="Release Time"; break;
949 case 40: tag="Special Instructions"; break;
950 case 45: tag="Reference Service"; break;
951 case 47: tag="Reference Date"; break;
952 case 50: tag="Reference Number"; break;
953 case 55: tag="Created Date"; break;
954 case 60: tag="Created Time"; break;
955 case 65: tag="Originating Program"; break;
956 case 70: tag="Program Version"; break;
957 case 75: tag="Object Cycle"; break;
958 case 80: tag="Byline"; break;
959 case 85: tag="Byline Title"; break;
960 case 90: tag="City"; break;
961 case 95: tag="Province State"; break;
962 case 100: tag="Country Code"; break;
963 case 101: tag="Country"; break;
964 case 103: tag="Original Transmission Reference"; break;
965 case 105: tag="Headline"; break;
966 case 110: tag="Credit"; break;
967 case 115: tag="Src"; break;
968 case 116: tag="Copyright String"; break;
969 case 120: tag="Caption"; break;
970 case 121: tag="Local Caption"; break;
971 case 122: tag="Caption Writer"; break;
972 case 200: tag="Custom Field 1"; break;
973 case 201: tag="Custom Field 2"; break;
974 case 202: tag="Custom Field 3"; break;
975 case 203: tag="Custom Field 4"; break;
976 case 204: tag="Custom Field 5"; break;
977 case 205: tag="Custom Field 6"; break;
978 case 206: tag="Custom Field 7"; break;
979 case 207: tag="Custom Field 8"; break;
980 case 208: tag="Custom Field 9"; break;
981 case 209: tag="Custom Field 10"; break;
982 case 210: tag="Custom Field 11"; break;
983 case 211: tag="Custom Field 12"; break;
984 case 212: tag="Custom Field 13"; break;
985 case 213: tag="Custom Field 14"; break;
986 case 214: tag="Custom Field 15"; break;
987 case 215: tag="Custom Field 16"; break;
988 case 216: tag="Custom Field 17"; break;
989 case 217: tag="Custom Field 18"; break;
990 case 218: tag="Custom Field 19"; break;
991 case 219: tag="Custom Field 20"; break;
992 default: tag="unknown"; break;
994 (void) fprintf(file," %s[%.20g,%.20g]: ",tag,(double)
995 dataset,(double) record);
996 length=(size_t) (GetStringInfoDatum(profile)[i++] << 8);
997 length|=GetStringInfoDatum(profile)[i++];
998 attribute=(char *) NULL;
999 if (~length >= MaxTextExtent)
1000 attribute=(char *) AcquireQuantumMemory(length+
1001 MaxTextExtent,sizeof(*attribute));
1002 if (attribute != (char *) NULL)
1004 (void) CopyMagickString(attribute,(char *)
1005 GetStringInfoDatum(profile)+i,length+1);
1006 attribute_list=StringToList(attribute);
1007 if (attribute_list != (char **) NULL)
1009 for (j=0; attribute_list[j] != (char *) NULL; j++)
1011 (void) fputs(attribute_list[j],file);
1012 (void) fputs("\n",file);
1013 attribute_list[j]=(char *) RelinquishMagickMemory(
1016 attribute_list=(char **) RelinquishMagickMemory(
1019 attribute=DestroyString(attribute);
1023 if (image->debug != MagickFalse)
1024 PrintStringInfo(file,name,profile);
1025 name=GetNextImageProfile(image);
1028 ResetImageArtifactIterator(image);
1029 artifact=GetNextImageArtifact(image);
1030 if (artifact != (const char *) NULL)
1033 Display image artifacts.
1035 (void) fprintf(file," Artifacts:\n");
1036 while (artifact != (const char *) NULL)
1038 (void) fprintf(file," %s: ",artifact);
1039 value=GetImageArtifact(image,artifact);
1040 if (value != (const char *) NULL)
1041 (void) fprintf(file,"%s\n",value);
1042 artifact=GetNextImageArtifact(image);
1045 ResetImageRegistryIterator();
1046 registry=GetNextImageRegistry();
1047 if (registry != (const char *) NULL)
1050 Display image registry.
1052 (void) fprintf(file," Registry:\n");
1053 while (registry != (const char *) NULL)
1055 (void) fprintf(file," %s: ",registry);
1056 value=(const char *) GetImageRegistry(StringRegistryType,registry,
1058 if (value != (const char *) NULL)
1059 (void) fprintf(file,"%s\n",value);
1060 registry=GetNextImageRegistry();
1063 (void) fprintf(file," Tainted: %s\n",MagickOptionToMnemonic(
1064 MagickBooleanOptions,(ssize_t) image->taint));
1065 (void) FormatMagickSize(GetBlobSize(image),MagickFalse,format);
1066 (void) fprintf(file," Filesize: %sB\n",format);
1067 (void) FormatMagickSize((MagickSizeType) image->columns*image->rows,
1068 MagickFalse,format);
1069 (void) fprintf(file," Number pixels: %s\n",format);
1070 (void) FormatMagickSize((MagickSizeType) ((double) image->columns*image->rows/
1071 elapsed_time+0.5),MagickFalse,format);
1072 (void) fprintf(file," Pixels per second: %s\n",format);
1073 (void) fprintf(file," User time: %0.3fu\n",user_time);
1074 (void) fprintf(file," Elapsed time: %lu:%02lu.%03lu\n",(unsigned long)
1075 (elapsed_time/60.0),(unsigned long) ceil(fmod(elapsed_time,60.0)),
1076 (unsigned long) (1000.0*(elapsed_time-floor(elapsed_time))));
1077 (void) fprintf(file," Version: %s\n",GetMagickVersion((size_t *)
1079 (void) fflush(file);
1080 return(ferror(file) != 0 ? MagickFalse : MagickTrue);