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[%lu] ",image->filename,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,"%lux%lu=>",image->magick_columns,
331 (void) fprintf(file,"%lux%lu ",image->columns,image->rows);
332 if ((image->page.width != 0) || (image->page.height != 0) ||
333 (image->page.x != 0) || (image->page.y != 0))
334 (void) fprintf(file,"%lux%lu%+ld%+ld ",image->page.width,
335 image->page.height,image->page.x,image->page.y);
336 (void) fprintf(file,"%lu-bit ",image->depth);
337 if (image->type != UndefinedType)
338 (void) fprintf(file,"%s ",MagickOptionToMnemonic(MagickTypeOptions,
339 (long) image->type));
340 if (image->storage_class == DirectClass)
342 (void) fprintf(file,"DirectClass ");
343 if (image->total_colors != 0)
345 (void) FormatMagickSize(image->total_colors,MagickFalse,format);
346 (void) fprintf(file,"%s ",format);
350 if (image->total_colors <= image->colors)
351 (void) fprintf(file,"PseudoClass %luc ",image->colors);
353 (void) fprintf(file,"PseudoClass %lu=>%luc ",image->total_colors,
355 if (image->error.mean_error_per_pixel != 0.0)
356 (void) fprintf(file,"%ld/%f/%fdb ",(long)
357 (image->error.mean_error_per_pixel+0.5),
358 image->error.normalized_mean_error,
359 image->error.normalized_maximum_error);
360 if (GetBlobSize(image) != 0)
362 (void) FormatMagickSize(GetBlobSize(image),MagickFalse,format);
363 (void) fprintf(file,"%sB ",format);
365 (void) fprintf(file,"%0.3fu %ld:%02ld.%03ld",user_time,(long)
366 (elapsed_time/60.0),(long) floor(fmod(elapsed_time,60.0)),
367 (long) (1000.0*(elapsed_time-floor(elapsed_time))));
368 (void) fprintf(file,"\n");
370 return(ferror(file) != 0 ? MagickFalse : MagickTrue);
373 Display verbose info about the image.
375 exception=AcquireExceptionInfo();
376 pixels=GetVirtualPixels(image,0,0,1,1,exception);
377 exception=DestroyExceptionInfo(exception);
378 ping=pixels == (const PixelPacket *) NULL ? MagickTrue : MagickFalse;
379 type=GetImageType(image,&image->exception);
380 (void) SignatureImage(image);
381 (void) fprintf(file,"Image: %s\n",image->filename);
382 if (*image->magick_filename != '\0')
383 if (LocaleCompare(image->magick_filename,image->filename) != 0)
386 filename[MaxTextExtent];
388 GetPathComponent(image->magick_filename,TailPath,filename);
389 (void) fprintf(file," Base filename: %s\n",filename);
391 magick_info=GetMagickInfo(image->magick,&image->exception);
392 if ((magick_info == (const MagickInfo *) NULL) ||
393 (*GetMagickDescription(magick_info) == '\0'))
394 (void) fprintf(file," Format: %s\n",image->magick);
396 (void) fprintf(file," Format: %s (%s)\n",image->magick,
397 GetMagickDescription(magick_info));
398 (void) fprintf(file," Class: %s\n",MagickOptionToMnemonic(MagickClassOptions,
399 (long) image->storage_class));
400 (void) fprintf(file," Geometry: %lux%lu%+ld%+ld\n",image->columns,
401 image->rows,image->tile_offset.x,image->tile_offset.y);
402 if ((image->magick_columns != 0) || (image->magick_rows != 0))
403 if ((image->magick_columns != image->columns) ||
404 (image->magick_rows != image->rows))
405 (void) fprintf(file," Base geometry: %lux%lu\n",image->magick_columns,
407 if ((image->x_resolution != 0.0) && (image->y_resolution != 0.0))
409 (void) fprintf(file," Resolution: %gx%g\n",image->x_resolution,
410 image->y_resolution);
411 (void) fprintf(file," Print size: %gx%g\n",(double) image->columns/
412 image->x_resolution,(double) image->rows/image->y_resolution);
414 (void) fprintf(file," Units: %s\n",MagickOptionToMnemonic(
415 MagickResolutionOptions,(long) image->units));
416 (void) fprintf(file," Type: %s\n",MagickOptionToMnemonic(MagickTypeOptions,
418 if (image->type != UndefinedType)
419 (void) fprintf(file," Base type: %s\n",MagickOptionToMnemonic(
420 MagickTypeOptions,(long) image->type));
421 (void) fprintf(file," Endianess: %s\n",MagickOptionToMnemonic(
422 MagickEndianOptions,(long) image->endian));
424 Detail channel depth and extrema.
426 (void) fprintf(file," Colorspace: %s\n",MagickOptionToMnemonic(
427 MagickColorspaceOptions,(long) image->colorspace));
428 channel_statistics=(ChannelStatistics *) NULL;
429 channel_features=(ChannelFeatures *) NULL;
430 colorspace=image->colorspace;
431 if (ping == MagickFalse)
436 channel_statistics=GetImageChannelStatistics(image,&image->exception);
437 artifact=GetImageArtifact(image,"identify:features");
438 if (artifact != (const char *) NULL)
440 distance=StringToUnsignedLong(artifact);
441 channel_features=GetImageChannelFeatures(image,distance,
444 depth=GetImageDepth(image,&image->exception);
445 if (image->depth == depth)
446 (void) fprintf(file," Depth: %lu-bit\n",image->depth);
448 (void) fprintf(file," Depth: %lu/%lu-bit\n",image->depth,depth);
449 (void) fprintf(file," Channel depth:\n");
450 if (IsGrayImage(image,&image->exception) != MagickFalse)
451 colorspace=GRAYColorspace;
457 (void) fprintf(file," red: %lu-bit\n",
458 channel_statistics[RedChannel].depth);
459 (void) fprintf(file," green: %lu-bit\n",
460 channel_statistics[GreenChannel].depth);
461 (void) fprintf(file," blue: %lu-bit\n",
462 channel_statistics[BlueChannel].depth);
463 if (image->matte != MagickFalse)
464 (void) fprintf(file," alpha: %lu-bit\n",
465 channel_statistics[OpacityChannel].depth);
470 (void) fprintf(file," cyan: %lu-bit\n",
471 channel_statistics[CyanChannel].depth);
472 (void) fprintf(file," magenta: %lu-bit\n",
473 channel_statistics[MagentaChannel].depth);
474 (void) fprintf(file," yellow: %lu-bit\n",
475 channel_statistics[YellowChannel].depth);
476 (void) fprintf(file," black: %lu-bit\n",
477 channel_statistics[BlackChannel].depth);
478 if (image->matte != MagickFalse)
479 (void) fprintf(file," alpha: %lu-bit\n",
480 channel_statistics[OpacityChannel].depth);
485 (void) fprintf(file," gray: %lu-bit\n",
486 channel_statistics[GrayChannel].depth);
487 if (image->matte != MagickFalse)
488 (void) fprintf(file," alpha: %lu-bit\n",
489 channel_statistics[OpacityChannel].depth);
494 if (image->depth <= MAGICKCORE_QUANTUM_DEPTH)
495 scale=QuantumRange/((unsigned long) QuantumRange >> ((unsigned long)
496 MAGICKCORE_QUANTUM_DEPTH-image->depth));
498 if (channel_statistics != (ChannelStatistics *) NULL)
500 (void) fprintf(file," Channel statistics:\n");
506 (void) PrintChannelStatistics(file,RedChannel,"Red",1.0/scale,
508 (void) PrintChannelStatistics(file,GreenChannel,"Green",1.0/scale,
510 (void) PrintChannelStatistics(file,BlueChannel,"Blue",1.0/scale,
516 (void) PrintChannelStatistics(file,CyanChannel,"Cyan",1.0/scale,
518 (void) PrintChannelStatistics(file,MagentaChannel,"Magenta",1.0/scale,
520 (void) PrintChannelStatistics(file,YellowChannel,"Yellow",1.0/scale,
522 (void) PrintChannelStatistics(file,BlackChannel,"Black",1.0/scale,
528 (void) PrintChannelStatistics(file,GrayChannel,"Gray",1.0/scale,
533 if (image->matte != MagickFalse)
534 (void) PrintChannelStatistics(file,AlphaChannel,"Alpha",1.0/scale,
536 if (colorspace != GRAYColorspace)
538 (void) fprintf(file," Image statistics:\n");
539 (void) PrintChannelStatistics(file,AllChannels,"Overall",1.0/scale,
542 channel_statistics=(ChannelStatistics *) RelinquishMagickMemory(
545 if (channel_features != (ChannelFeatures *) NULL)
547 (void) fprintf(file," Channel features (horizontal, vertical, left and right diagonals, average):\n");
553 (void) PrintChannelFeatures(file,RedChannel,"Red",channel_features);
554 (void) PrintChannelFeatures(file,GreenChannel,"Green",
556 (void) PrintChannelFeatures(file,BlueChannel,"Blue",channel_features);
561 (void) PrintChannelFeatures(file,CyanChannel,"Cyan",channel_features);
562 (void) PrintChannelFeatures(file,MagentaChannel,"Magenta",
564 (void) PrintChannelFeatures(file,YellowChannel,"Yellow",
566 (void) PrintChannelFeatures(file,BlackChannel,"Black",
572 (void) PrintChannelFeatures(file,GrayChannel,"Gray",channel_features);
576 if (image->matte != MagickFalse)
577 (void) PrintChannelFeatures(file,AlphaChannel,"Alpha",channel_features);
578 channel_features=(ChannelFeatures *) RelinquishMagickMemory(
581 if (ping == MagickFalse)
583 if (image->colorspace == CMYKColorspace)
584 (void) fprintf(file," Total ink density: %.0f%%\n",100.0*
585 GetImageTotalInkDensity(image)/(double) QuantumRange);
587 if (image->matte != MagickFalse)
589 register const IndexPacket
592 register const PixelPacket
595 p=(PixelPacket *) NULL;
596 indexes=(IndexPacket *) NULL;
597 for (y=0; y < (long) image->rows; y++)
599 p=GetVirtualPixels(image,0,y,image->columns,1,exception);
600 if (p == (const PixelPacket *) NULL)
602 indexes=GetVirtualIndexQueue(image);
603 for (x=0; x < (long) image->columns; x++)
605 if (p->opacity == (Quantum) TransparentOpacity)
609 if (x < (long) image->columns)
612 if ((x < (long) image->columns) || (y < (long) image->rows))
615 tuple[MaxTextExtent];
620 GetMagickPixelPacket(image,&pixel);
621 SetMagickPixelPacket(image,p,indexes+x,&pixel);
622 (void) QueryMagickColorname(image,&pixel,SVGCompliance,tuple,
624 (void) fprintf(file," Alpha: %s ",tuple);
625 GetColorTuple(&pixel,MagickTrue,tuple);
626 (void) fprintf(file," %s\n",tuple);
629 artifact=GetImageArtifact(image,"identify:unique-colors");
630 if ((artifact != (const char *) NULL) &&
631 (IsMagickTrue(artifact) != MagickFalse))
632 (void) fprintf(file," Colors: %lu\n",GetNumberColors(image,
633 (FILE *) NULL,&image->exception));
634 if (IsHistogramImage(image,&image->exception) != MagickFalse)
636 (void) fprintf(file," Histogram:\n");
637 (void) GetNumberColors(image,file,&image->exception);
640 if (image->storage_class == PseudoClass)
642 (void) fprintf(file," Colormap: %lu\n",image->colors);
643 if (image->colors <= 1024)
646 color[MaxTextExtent],
648 tuple[MaxTextExtent];
656 GetMagickPixelPacket(image,&pixel);
658 for (i=0; i < (long) image->colors; i++)
660 SetMagickPixelPacket(image,p,(IndexPacket *) NULL,&pixel);
661 (void) CopyMagickString(tuple,"(",MaxTextExtent);
662 ConcatenateColorComponent(&pixel,RedChannel,X11Compliance,tuple);
663 (void) ConcatenateMagickString(tuple,",",MaxTextExtent);
664 ConcatenateColorComponent(&pixel,GreenChannel,X11Compliance,tuple);
665 (void) ConcatenateMagickString(tuple,",",MaxTextExtent);
666 ConcatenateColorComponent(&pixel,BlueChannel,X11Compliance,tuple);
667 if (pixel.colorspace == CMYKColorspace)
669 (void) ConcatenateMagickString(tuple,",",MaxTextExtent);
670 ConcatenateColorComponent(&pixel,IndexChannel,X11Compliance,
673 if (pixel.matte != MagickFalse)
675 (void) ConcatenateMagickString(tuple,",",MaxTextExtent);
676 ConcatenateColorComponent(&pixel,AlphaChannel,X11Compliance,
679 (void) ConcatenateMagickString(tuple,")",MaxTextExtent);
680 (void) QueryMagickColorname(image,&pixel,SVGCompliance,color,
682 GetColorTuple(&pixel,MagickTrue,hex);
683 (void) fprintf(file," %8ld: %s %s %s\n",i,tuple,hex,color);
688 if (image->error.mean_error_per_pixel != 0.0)
689 (void) fprintf(file," Mean error per pixel: %g\n",
690 image->error.mean_error_per_pixel);
691 if (image->error.normalized_mean_error != 0.0)
692 (void) fprintf(file," Normalized mean error: %g\n",
693 image->error.normalized_mean_error);
694 if (image->error.normalized_maximum_error != 0.0)
695 (void) fprintf(file," Normalized maximum error: %g\n",
696 image->error.normalized_maximum_error);
697 (void) fprintf(file," Rendering intent: %s\n",MagickOptionToMnemonic(
698 MagickIntentOptions,(long) image->rendering_intent));
699 if (image->gamma != 0.0)
700 (void) fprintf(file," Gamma: %g\n",image->gamma);
701 if ((image->chromaticity.red_primary.x != 0.0) ||
702 (image->chromaticity.green_primary.x != 0.0) ||
703 (image->chromaticity.blue_primary.x != 0.0) ||
704 (image->chromaticity.white_point.x != 0.0))
707 Display image chromaticity.
709 (void) fprintf(file," Chromaticity:\n");
710 (void) fprintf(file," red primary: (%g,%g)\n",
711 image->chromaticity.red_primary.x,image->chromaticity.red_primary.y);
712 (void) fprintf(file," green primary: (%g,%g)\n",
713 image->chromaticity.green_primary.x,
714 image->chromaticity.green_primary.y);
715 (void) fprintf(file," blue primary: (%g,%g)\n",
716 image->chromaticity.blue_primary.x,image->chromaticity.blue_primary.y);
717 (void) fprintf(file," white point: (%g,%g)\n",
718 image->chromaticity.white_point.x,image->chromaticity.white_point.y);
720 if ((image->extract_info.width*image->extract_info.height) != 0)
721 (void) fprintf(file," Tile geometry: %lux%lu%+ld%+ld\n",
722 image->extract_info.width,image->extract_info.height,
723 image->extract_info.x,image->extract_info.y);
724 (void) fprintf(file," Interlace: %s\n",MagickOptionToMnemonic(
725 MagickInterlaceOptions,(long) image->interlace));
726 (void) QueryColorname(image,&image->background_color,SVGCompliance,color,
728 (void) fprintf(file," Background color: %s\n",color);
729 (void) QueryColorname(image,&image->border_color,SVGCompliance,color,
731 (void) fprintf(file," Border color: %s\n",color);
732 (void) QueryColorname(image,&image->matte_color,SVGCompliance,color,
734 (void) fprintf(file," Matte color: %s\n",color);
735 (void) QueryColorname(image,&image->transparent_color,SVGCompliance,color,
737 (void) fprintf(file," Transparent color: %s\n",color);
738 (void) fprintf(file," Compose: %s\n",MagickOptionToMnemonic(
739 MagickComposeOptions,(long) image->compose));
740 if ((image->page.width != 0) || (image->page.height != 0) ||
741 (image->page.x != 0) || (image->page.y != 0))
742 (void) fprintf(file," Page geometry: %lux%lu%+ld%+ld\n",image->page.width,
743 image->page.height,image->page.x,image->page.y);
744 if ((image->page.x != 0) || (image->page.y != 0))
745 (void) fprintf(file," Origin geometry: %+ld%+ld\n",image->page.x,
747 (void) fprintf(file," Dispose: %s\n",MagickOptionToMnemonic(
748 MagickDisposeOptions,(long) image->dispose));
749 if (image->delay != 0)
750 (void) fprintf(file," Delay: %lux%ld\n",image->delay,
751 image->ticks_per_second);
752 if (image->iterations != 1)
753 (void) fprintf(file," Iterations: %lu\n",image->iterations);
754 if ((image->next != (Image *) NULL) || (image->previous != (Image *) NULL))
755 (void) fprintf(file," Scene: %lu of %lu\n",image->scene,
756 GetImageListLength(image));
758 if (image->scene != 0)
759 (void) fprintf(file," Scene: %lu\n",image->scene);
760 (void) fprintf(file," Compression: %s\n",MagickOptionToMnemonic(
761 MagickCompressOptions,(long) image->compression));
762 if (image->quality != UndefinedCompressionQuality)
763 (void) fprintf(file," Quality: %lu\n",image->quality);
764 (void) fprintf(file," Orientation: %s\n",MagickOptionToMnemonic(
765 MagickOrientationOptions,(long) image->orientation));
766 if (image->montage != (char *) NULL)
767 (void) fprintf(file," Montage: %s\n",image->montage);
768 if (image->directory != (char *) NULL)
784 Display visual image directory.
786 image_info=AcquireImageInfo();
787 (void) CloneString(&image_info->size,"64x64");
788 (void) fprintf(file," Directory:\n");
789 for (p=image->directory; *p != '\0'; p++)
792 while ((*q != '\n') && (*q != '\0'))
794 (void) CopyMagickString(image_info->filename,p,(size_t) (q-p+1));
796 (void) fprintf(file," %s",image_info->filename);
797 handler=SetWarningHandler((WarningHandler) NULL);
798 tile=ReadImage(image_info,&image->exception);
799 (void) SetWarningHandler(handler);
800 if (tile == (Image *) NULL)
802 (void) fprintf(file,"\n");
805 (void) fprintf(file," %lux%lu %s\n",tile->magick_columns,
806 tile->magick_rows,tile->magick);
807 (void) SignatureImage(tile);
808 ResetImagePropertyIterator(tile);
809 property=GetNextImageProperty(tile);
810 while (property != (const char *) NULL)
812 (void) fprintf(file," %s:\n",property);
813 value=GetImageProperty(tile,property);
814 if (value != (const char *) NULL)
815 (void) fprintf(file,"%s\n",value);
816 property=GetNextImageProperty(tile);
818 tile=DestroyImage(tile);
820 image_info=DestroyImageInfo(image_info);
822 (void) GetImageProperty(image,"exif:*");
823 ResetImagePropertyIterator(image);
824 property=GetNextImageProperty(image);
825 if (property != (const char *) NULL)
828 Display image properties.
830 (void) fprintf(file," Properties:\n");
831 while (property != (const char *) NULL)
833 (void) fprintf(file," %c",*property);
834 if (strlen(property) > 1)
835 (void) fprintf(file,"%s: ",property+1);
836 if (strlen(property) > 80)
837 (void) fputc('\n',file);
838 value=GetImageProperty(image,property);
839 if (value != (const char *) NULL)
840 (void) fprintf(file,"%s\n",value);
841 property=GetNextImageProperty(image);
844 (void) FormatMagickString(key,MaxTextExtent,"8BIM:1999,2998:#1");
845 value=GetImageProperty(image,key);
846 if (value != (const char *) NULL)
849 Display clipping path.
851 (void) fprintf(file," Clipping path: ");
852 if (strlen(value) > 80)
853 (void) fputc('\n',file);
854 (void) fprintf(file,"%s\n",value);
856 ResetImageProfileIterator(image);
857 name=GetNextImageProfile(image);
858 if (name != (char *) NULL)
864 Identify image profiles.
866 (void) fprintf(file," Profiles:\n");
867 while (name != (char *) NULL)
869 profile=GetImageProfile(image,name);
870 if (profile == (StringInfo *) NULL)
872 (void) fprintf(file," Profile-%s: %lu bytes\n",name,(unsigned long)
873 GetStringInfoLength(profile));
874 #if defined(MAGICKCORE_LCMS_DELEGATE)
875 if ((LocaleCompare(name,"icc") == 0) ||
876 (LocaleCompare(name,"icm") == 0))
881 icc_profile=cmsOpenProfileFromMem(GetStringInfoDatum(profile),
882 (cmsUInt32Number) GetStringInfoLength(profile));
883 if (icc_profile != (cmsHPROFILE *) NULL)
885 #if defined(LCMS_VERSION) && (LCMS_VERSION < 2000)
889 name=cmsTakeProductName(icc_profile);
890 if (name != (const char *) NULL)
891 (void) fprintf(file," %s\n",name);
896 (void) cmsGetProfileInfoASCII(icc_profile,cmsInfoDescription,
897 "en","US",info,MaxTextExtent);
898 (void) fprintf(file," Description: %s\n",info);
899 (void) cmsGetProfileInfoASCII(icc_profile,cmsInfoManufacturer,
900 "en","US",info,MaxTextExtent);
901 (void) fprintf(file," Manufacturer: %s\n",info);
902 (void) cmsGetProfileInfoASCII(icc_profile,cmsInfoModel,"en",
903 "US",info,MaxTextExtent);
904 (void) fprintf(file," Model: %s\n",info);
905 (void) cmsGetProfileInfoASCII(icc_profile,cmsInfoCopyright,
906 "en","US",info,MaxTextExtent);
907 (void) fprintf(file," Copyright: %s\n",info);
909 (void) cmsCloseProfile(icc_profile);
913 if (LocaleCompare(name,"iptc") == 0)
934 profile_length=GetStringInfoLength(profile);
935 for (i=0; i < (long) profile_length; i+=(long) length)
938 sentinel=GetStringInfoDatum(profile)[i++];
939 if (sentinel != 0x1c)
941 dataset=GetStringInfoDatum(profile)[i++];
942 record=GetStringInfoDatum(profile)[i++];
945 case 5: tag="Image Name"; break;
946 case 7: tag="Edit Status"; break;
947 case 10: tag="Priority"; break;
948 case 15: tag="Category"; break;
949 case 20: tag="Supplemental Category"; break;
950 case 22: tag="Fixture Identifier"; break;
951 case 25: tag="Keyword"; break;
952 case 30: tag="Release Date"; break;
953 case 35: tag="Release Time"; break;
954 case 40: tag="Special Instructions"; break;
955 case 45: tag="Reference Service"; break;
956 case 47: tag="Reference Date"; break;
957 case 50: tag="Reference Number"; break;
958 case 55: tag="Created Date"; break;
959 case 60: tag="Created Time"; break;
960 case 65: tag="Originating Program"; break;
961 case 70: tag="Program Version"; break;
962 case 75: tag="Object Cycle"; break;
963 case 80: tag="Byline"; break;
964 case 85: tag="Byline Title"; break;
965 case 90: tag="City"; break;
966 case 95: tag="Province State"; break;
967 case 100: tag="Country Code"; break;
968 case 101: tag="Country"; break;
969 case 103: tag="Original Transmission Reference"; break;
970 case 105: tag="Headline"; break;
971 case 110: tag="Credit"; break;
972 case 115: tag="Src"; break;
973 case 116: tag="Copyright String"; break;
974 case 120: tag="Caption"; break;
975 case 121: tag="Local Caption"; break;
976 case 122: tag="Caption Writer"; break;
977 case 200: tag="Custom Field 1"; break;
978 case 201: tag="Custom Field 2"; break;
979 case 202: tag="Custom Field 3"; break;
980 case 203: tag="Custom Field 4"; break;
981 case 204: tag="Custom Field 5"; break;
982 case 205: tag="Custom Field 6"; break;
983 case 206: tag="Custom Field 7"; break;
984 case 207: tag="Custom Field 8"; break;
985 case 208: tag="Custom Field 9"; break;
986 case 209: tag="Custom Field 10"; break;
987 case 210: tag="Custom Field 11"; break;
988 case 211: tag="Custom Field 12"; break;
989 case 212: tag="Custom Field 13"; break;
990 case 213: tag="Custom Field 14"; break;
991 case 214: tag="Custom Field 15"; break;
992 case 215: tag="Custom Field 16"; break;
993 case 216: tag="Custom Field 17"; break;
994 case 217: tag="Custom Field 18"; break;
995 case 218: tag="Custom Field 19"; break;
996 case 219: tag="Custom Field 20"; break;
997 default: tag="unknown"; break;
999 (void) fprintf(file," %s[%ld,%ld]: ",tag,dataset,record);
1000 length=(size_t) (GetStringInfoDatum(profile)[i++] << 8);
1001 length|=GetStringInfoDatum(profile)[i++];
1002 attribute=(char *) NULL;
1003 if (~length >= MaxTextExtent)
1004 attribute=(char *) AcquireQuantumMemory(length+
1005 MaxTextExtent,sizeof(*attribute));
1006 if (attribute != (char *) NULL)
1008 (void) CopyMagickString(attribute,(char *)
1009 GetStringInfoDatum(profile)+i,length+1);
1010 attribute_list=StringToList(attribute);
1011 if (attribute_list != (char **) NULL)
1013 for (j=0; attribute_list[j] != (char *) NULL; j++)
1015 (void) fputs(attribute_list[j],file);
1016 (void) fputs("\n",file);
1017 attribute_list[j]=(char *) RelinquishMagickMemory(
1020 attribute_list=(char **) RelinquishMagickMemory(
1023 attribute=DestroyString(attribute);
1027 if (image->debug != MagickFalse)
1028 PrintStringInfo(file,name,profile);
1029 name=GetNextImageProfile(image);
1032 ResetImageArtifactIterator(image);
1033 artifact=GetNextImageArtifact(image);
1034 if (artifact != (const char *) NULL)
1037 Display image artifacts.
1039 (void) fprintf(file," Artifacts:\n");
1040 while (artifact != (const char *) NULL)
1042 (void) fprintf(file," %c",*artifact);
1043 if (strlen(artifact) > 1)
1044 (void) fprintf(file,"%s: ",artifact+1);
1045 if (strlen(artifact) > 80)
1046 (void) fputc('\n',file);
1047 value=GetImageArtifact(image,artifact);
1048 if (value != (const char *) NULL)
1049 (void) fprintf(file,"%s\n",value);
1050 artifact=GetNextImageArtifact(image);
1053 ResetImageRegistryIterator();
1054 registry=GetNextImageRegistry();
1055 if (registry != (const char *) NULL)
1058 Display image registry.
1060 (void) fprintf(file," Registry:\n");
1061 while (registry != (const char *) NULL)
1063 (void) fprintf(file," %c",*registry);
1064 if (strlen(registry) > 1)
1065 (void) fprintf(file,"%s: ",registry+1);
1066 if (strlen(registry) > 80)
1067 (void) fputc('\n',file);
1068 value=(const char *) GetImageRegistry(StringRegistryType,registry,
1070 if (value != (const char *) NULL)
1071 (void) fprintf(file,"%s\n",value);
1072 registry=GetNextImageRegistry();
1075 (void) fprintf(file," Tainted: %s\n",MagickOptionToMnemonic(
1076 MagickBooleanOptions,(long) image->taint));
1077 (void) FormatMagickSize(GetBlobSize(image),MagickFalse,format);
1078 (void) fprintf(file," Filesize: %sB\n",format);
1079 (void) FormatMagickSize((MagickSizeType) image->columns*image->rows,
1080 MagickFalse,format);
1081 (void) fprintf(file," Number pixels: %s\n",format);
1082 (void) FormatMagickSize((MagickSizeType) ((double) image->columns*image->rows/
1083 elapsed_time+0.5),MagickFalse,format);
1084 (void) fprintf(file," Pixels per second: %s\n",format);
1085 (void) fprintf(file," User time: %0.3fu\n",user_time);
1086 (void) fprintf(file," Elapsed time: %ld:%02ld.%03ld\n",(long)
1087 (elapsed_time/60.0),(long) ceil(fmod(elapsed_time,60.0)),(long)
1088 (1000.0*(elapsed_time-floor(elapsed_time))));
1089 (void) fprintf(file," Version: %s\n",GetMagickVersion((unsigned long *)
1091 (void) fflush(file);
1092 return(ferror(file) != 0 ? MagickFalse : MagickTrue);