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 status=fprintf(file,StatisticsFormat,name,ClampToQuantum(scale*
221 channel_statistics[channel].minima),channel_statistics[channel].minima/
222 (double) QuantumRange,ClampToQuantum(scale*
223 channel_statistics[channel].maxima),channel_statistics[channel].maxima/
224 (double) QuantumRange,scale*channel_statistics[channel].mean,
225 channel_statistics[channel].mean/(double) QuantumRange,scale*
226 channel_statistics[channel].standard_deviation,
227 channel_statistics[channel].standard_deviation/(double) QuantumRange,
228 channel_statistics[channel].kurtosis,channel_statistics[channel].skewness);
232 MagickExport MagickBooleanType IdentifyImage(Image *image,FILE *file,
233 const MagickBooleanType verbose)
236 color[MaxTextExtent],
237 format[MaxTextExtent],
286 assert(image != (Image *) NULL);
287 assert(image->signature == MagickSignature);
288 if (image->debug != MagickFalse)
289 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
290 if (file == (FILE *) NULL)
293 elapsed_time=GetElapsedTime(&image->timer);
294 user_time=GetUserTime(&image->timer);
295 GetTimerInfo(&image->timer);
296 if (verbose == MagickFalse)
299 Display summary info about the image.
301 if (*image->magick_filename != '\0')
302 if (LocaleCompare(image->magick_filename,image->filename) != 0)
303 (void) fprintf(file,"%s=>",image->magick_filename);
304 if ((GetPreviousImageInList(image) == (Image *) NULL) &&
305 (GetNextImageInList(image) == (Image *) NULL) &&
307 (void) fprintf(file,"%s ",image->filename);
309 (void) fprintf(file,"%s[%lu] ",image->filename,image->scene);
310 (void) fprintf(file,"%s ",image->magick);
311 if ((image->magick_columns != 0) || (image->magick_rows != 0))
312 if ((image->magick_columns != image->columns) ||
313 (image->magick_rows != image->rows))
314 (void) fprintf(file,"%lux%lu=>",image->magick_columns,
316 (void) fprintf(file,"%lux%lu ",image->columns,image->rows);
317 if ((image->page.width != 0) || (image->page.height != 0) ||
318 (image->page.x != 0) || (image->page.y != 0))
319 (void) fprintf(file,"%lux%lu%+ld%+ld ",image->page.width,
320 image->page.height,image->page.x,image->page.y);
321 (void) fprintf(file,"%lu-bit ",image->depth);
322 if (image->type != UndefinedType)
323 (void) fprintf(file,"%s ",MagickOptionToMnemonic(MagickTypeOptions,
324 (long) image->type));
325 if (image->storage_class == DirectClass)
327 (void) fprintf(file,"DirectClass ");
328 if (image->total_colors != 0)
330 (void) FormatMagickSize(image->total_colors,MagickFalse,format);
331 (void) fprintf(file,"%s ",format);
335 if (image->total_colors <= image->colors)
336 (void) fprintf(file,"PseudoClass %luc ",image->colors);
338 (void) fprintf(file,"PseudoClass %lu=>%luc ",image->total_colors,
340 if (image->error.mean_error_per_pixel != 0.0)
341 (void) fprintf(file,"%ld/%f/%fdb ",(long)
342 (image->error.mean_error_per_pixel+0.5),
343 image->error.normalized_mean_error,
344 image->error.normalized_maximum_error);
345 if (GetBlobSize(image) != 0)
347 (void) FormatMagickSize(GetBlobSize(image),MagickFalse,format);
348 (void) fprintf(file,"%sB ",format);
350 (void) fprintf(file,"%0.3fu %ld:%02ld.%03ld",user_time,(long)
351 (elapsed_time/60.0),(long) floor(fmod(elapsed_time,60.0)),
352 (long) (1000.0*(elapsed_time-floor(elapsed_time))));
353 (void) fprintf(file,"\n");
355 return(ferror(file) != 0 ? MagickFalse : MagickTrue);
358 Display verbose info about the image.
360 exception=AcquireExceptionInfo();
361 pixels=GetVirtualPixels(image,0,0,1,1,exception);
362 exception=DestroyExceptionInfo(exception);
363 ping=pixels == (const PixelPacket *) NULL ? MagickTrue : MagickFalse;
364 type=GetImageType(image,&image->exception);
365 (void) SignatureImage(image);
366 (void) fprintf(file,"Image: %s\n",image->filename);
367 if (*image->magick_filename != '\0')
368 if (LocaleCompare(image->magick_filename,image->filename) != 0)
371 filename[MaxTextExtent];
373 GetPathComponent(image->magick_filename,TailPath,filename);
374 (void) fprintf(file," Base filename: %s\n",filename);
376 magick_info=GetMagickInfo(image->magick,&image->exception);
377 if ((magick_info == (const MagickInfo *) NULL) ||
378 (*GetMagickDescription(magick_info) == '\0'))
379 (void) fprintf(file," Format: %s\n",image->magick);
381 (void) fprintf(file," Format: %s (%s)\n",image->magick,
382 GetMagickDescription(magick_info));
383 (void) fprintf(file," Class: %s\n",MagickOptionToMnemonic(MagickClassOptions,
384 (long) image->storage_class));
385 (void) fprintf(file," Geometry: %lux%lu%+ld%+ld\n",image->columns,
386 image->rows,image->tile_offset.x,image->tile_offset.y);
387 if ((image->magick_columns != 0) || (image->magick_rows != 0))
388 if ((image->magick_columns != image->columns) ||
389 (image->magick_rows != image->rows))
390 (void) fprintf(file," Base geometry: %lux%lu\n",image->magick_columns,
392 if ((image->x_resolution != 0.0) && (image->y_resolution != 0.0))
394 (void) fprintf(file," Resolution: %gx%g\n",image->x_resolution,
395 image->y_resolution);
396 (void) fprintf(file," Print size: %gx%g\n",(double) image->columns/
397 image->x_resolution,(double) image->rows/image->y_resolution);
399 (void) fprintf(file," Units: %s\n",MagickOptionToMnemonic(
400 MagickResolutionOptions,(long) image->units));
401 (void) fprintf(file," Type: %s\n",MagickOptionToMnemonic(MagickTypeOptions,
403 if (image->type != UndefinedType)
404 (void) fprintf(file," Base type: %s\n",MagickOptionToMnemonic(
405 MagickTypeOptions,(long) image->type));
406 (void) fprintf(file," Endianess: %s\n",MagickOptionToMnemonic(
407 MagickEndianOptions,(long) image->endian));
409 Detail channel depth and extrema.
411 (void) fprintf(file," Colorspace: %s\n",MagickOptionToMnemonic(
412 MagickColorspaceOptions,(long) image->colorspace));
413 channel_statistics=(ChannelStatistics *) NULL;
414 channel_features=(ChannelFeatures *) NULL;
415 colorspace=image->colorspace;
416 if (ping == MagickFalse)
421 channel_statistics=GetImageChannelStatistics(image,&image->exception);
422 artifact=GetImageArtifact(image,"identify:features");
423 if (artifact != (const char *) NULL)
425 distance=StringToUnsignedLong(artifact);
426 channel_features=GetImageChannelFeatures(image,distance,
429 depth=GetImageDepth(image,&image->exception);
430 if (image->depth == depth)
431 (void) fprintf(file," Depth: %lu-bit\n",image->depth);
433 (void) fprintf(file," Depth: %lu/%lu-bit\n",image->depth,depth);
434 (void) fprintf(file," Channel depth:\n");
435 if (IsGrayImage(image,&image->exception) != MagickFalse)
436 colorspace=GRAYColorspace;
442 (void) fprintf(file," red: %lu-bit\n",
443 channel_statistics[RedChannel].depth);
444 (void) fprintf(file," green: %lu-bit\n",
445 channel_statistics[GreenChannel].depth);
446 (void) fprintf(file," blue: %lu-bit\n",
447 channel_statistics[BlueChannel].depth);
448 if (image->matte != MagickFalse)
449 (void) fprintf(file," alpha: %lu-bit\n",
450 channel_statistics[OpacityChannel].depth);
455 (void) fprintf(file," cyan: %lu-bit\n",
456 channel_statistics[CyanChannel].depth);
457 (void) fprintf(file," magenta: %lu-bit\n",
458 channel_statistics[MagentaChannel].depth);
459 (void) fprintf(file," yellow: %lu-bit\n",
460 channel_statistics[YellowChannel].depth);
461 (void) fprintf(file," black: %lu-bit\n",
462 channel_statistics[BlackChannel].depth);
463 if (image->matte != MagickFalse)
464 (void) fprintf(file," alpha: %lu-bit\n",
465 channel_statistics[OpacityChannel].depth);
470 (void) fprintf(file," gray: %lu-bit\n",
471 channel_statistics[GrayChannel].depth);
472 if (image->matte != MagickFalse)
473 (void) fprintf(file," alpha: %lu-bit\n",
474 channel_statistics[OpacityChannel].depth);
479 if (image->depth <= MAGICKCORE_QUANTUM_DEPTH)
480 scale=QuantumRange/((unsigned long) QuantumRange >> ((unsigned long)
481 MAGICKCORE_QUANTUM_DEPTH-image->depth));
483 if (channel_statistics != (ChannelStatistics *) NULL)
485 (void) fprintf(file," Channel statistics:\n");
491 (void) PrintChannelStatistics(file,RedChannel,"Red",1.0/scale,
493 (void) PrintChannelStatistics(file,GreenChannel,"Green",1.0/scale,
495 (void) PrintChannelStatistics(file,BlueChannel,"Blue",1.0/scale,
501 (void) PrintChannelStatistics(file,CyanChannel,"Cyan",1.0/scale,
503 (void) PrintChannelStatistics(file,MagentaChannel,"Magenta",1.0/scale,
505 (void) PrintChannelStatistics(file,YellowChannel,"Yellow",1.0/scale,
507 (void) PrintChannelStatistics(file,BlackChannel,"Black",1.0/scale,
513 (void) PrintChannelStatistics(file,GrayChannel,"Gray",1.0/scale,
518 if (image->matte != MagickFalse)
519 (void) PrintChannelStatistics(file,AlphaChannel,"Alpha",1.0/scale,
521 if (colorspace != GRAYColorspace)
523 (void) fprintf(file," Image statistics:\n");
524 (void) PrintChannelStatistics(file,AllChannels,"Overall",1.0/scale,
527 channel_statistics=(ChannelStatistics *) RelinquishMagickMemory(
530 if (channel_features != (ChannelFeatures *) NULL)
532 (void) fprintf(file," Channel features (horizontal, vertical, left and right diagonals, average):\n");
538 (void) PrintChannelFeatures(file,RedChannel,"Red",channel_features);
539 (void) PrintChannelFeatures(file,GreenChannel,"Green",
541 (void) PrintChannelFeatures(file,BlueChannel,"Blue",channel_features);
546 (void) PrintChannelFeatures(file,CyanChannel,"Cyan",channel_features);
547 (void) PrintChannelFeatures(file,MagentaChannel,"Magenta",
549 (void) PrintChannelFeatures(file,YellowChannel,"Yellow",
551 (void) PrintChannelFeatures(file,BlackChannel,"Black",
557 (void) PrintChannelFeatures(file,GrayChannel,"Gray",channel_features);
561 if (image->matte != MagickFalse)
562 (void) PrintChannelFeatures(file,AlphaChannel,"Alpha",channel_features);
563 channel_features=(ChannelFeatures *) RelinquishMagickMemory(
566 if (ping == MagickFalse)
568 if (image->colorspace == CMYKColorspace)
569 (void) fprintf(file," Total ink density: %.0f%%\n",100.0*
570 GetImageTotalInkDensity(image)/(double) QuantumRange);
572 if (image->matte != MagickFalse)
574 register const IndexPacket
577 register const PixelPacket
580 p=(PixelPacket *) NULL;
581 indexes=(IndexPacket *) NULL;
582 for (y=0; y < (long) image->rows; y++)
584 p=GetVirtualPixels(image,0,y,image->columns,1,exception);
585 if (p == (const PixelPacket *) NULL)
587 indexes=GetVirtualIndexQueue(image);
588 for (x=0; x < (long) image->columns; x++)
590 if (p->opacity == (Quantum) TransparentOpacity)
594 if (x < (long) image->columns)
597 if ((x < (long) image->columns) || (y < (long) image->rows))
600 tuple[MaxTextExtent];
605 GetMagickPixelPacket(image,&pixel);
606 SetMagickPixelPacket(image,p,indexes+x,&pixel);
607 (void) QueryMagickColorname(image,&pixel,SVGCompliance,tuple,
609 (void) fprintf(file," Alpha: %s ",tuple);
610 GetColorTuple(&pixel,MagickTrue,tuple);
611 (void) fprintf(file," %s\n",tuple);
614 artifact=GetImageArtifact(image,"identify:unique-colors");
615 if ((artifact != (const char *) NULL) &&
616 (IsMagickTrue(artifact) != MagickFalse))
617 (void) fprintf(file," Colors: %lu\n",GetNumberColors(image,
618 (FILE *) NULL,&image->exception));
619 if (IsHistogramImage(image,&image->exception) != MagickFalse)
621 (void) fprintf(file," Histogram:\n");
622 (void) GetNumberColors(image,file,&image->exception);
625 if (image->storage_class == PseudoClass)
627 (void) fprintf(file," Colormap: %lu\n",image->colors);
628 if (image->colors <= 1024)
631 color[MaxTextExtent],
633 tuple[MaxTextExtent];
641 GetMagickPixelPacket(image,&pixel);
643 for (i=0; i < (long) image->colors; i++)
645 SetMagickPixelPacket(image,p,(IndexPacket *) NULL,&pixel);
646 (void) CopyMagickString(tuple,"(",MaxTextExtent);
647 ConcatenateColorComponent(&pixel,RedChannel,X11Compliance,tuple);
648 (void) ConcatenateMagickString(tuple,",",MaxTextExtent);
649 ConcatenateColorComponent(&pixel,GreenChannel,X11Compliance,tuple);
650 (void) ConcatenateMagickString(tuple,",",MaxTextExtent);
651 ConcatenateColorComponent(&pixel,BlueChannel,X11Compliance,tuple);
652 if (pixel.colorspace == CMYKColorspace)
654 (void) ConcatenateMagickString(tuple,",",MaxTextExtent);
655 ConcatenateColorComponent(&pixel,IndexChannel,X11Compliance,
658 if (pixel.matte != MagickFalse)
660 (void) ConcatenateMagickString(tuple,",",MaxTextExtent);
661 ConcatenateColorComponent(&pixel,AlphaChannel,X11Compliance,
664 (void) ConcatenateMagickString(tuple,")",MaxTextExtent);
665 (void) QueryMagickColorname(image,&pixel,SVGCompliance,color,
667 GetColorTuple(&pixel,MagickTrue,hex);
668 (void) fprintf(file," %8ld: %s %s %s\n",i,tuple,hex,color);
673 if (image->error.mean_error_per_pixel != 0.0)
674 (void) fprintf(file," Mean error per pixel: %g\n",
675 image->error.mean_error_per_pixel);
676 if (image->error.normalized_mean_error != 0.0)
677 (void) fprintf(file," Normalized mean error: %g\n",
678 image->error.normalized_mean_error);
679 if (image->error.normalized_maximum_error != 0.0)
680 (void) fprintf(file," Normalized maximum error: %g\n",
681 image->error.normalized_maximum_error);
682 (void) fprintf(file," Rendering intent: %s\n",MagickOptionToMnemonic(
683 MagickIntentOptions,(long) image->rendering_intent));
684 if (image->gamma != 0.0)
685 (void) fprintf(file," Gamma: %g\n",image->gamma);
686 if ((image->chromaticity.red_primary.x != 0.0) ||
687 (image->chromaticity.green_primary.x != 0.0) ||
688 (image->chromaticity.blue_primary.x != 0.0) ||
689 (image->chromaticity.white_point.x != 0.0))
692 Display image chromaticity.
694 (void) fprintf(file," Chromaticity:\n");
695 (void) fprintf(file," red primary: (%g,%g)\n",
696 image->chromaticity.red_primary.x,image->chromaticity.red_primary.y);
697 (void) fprintf(file," green primary: (%g,%g)\n",
698 image->chromaticity.green_primary.x,
699 image->chromaticity.green_primary.y);
700 (void) fprintf(file," blue primary: (%g,%g)\n",
701 image->chromaticity.blue_primary.x,image->chromaticity.blue_primary.y);
702 (void) fprintf(file," white point: (%g,%g)\n",
703 image->chromaticity.white_point.x,image->chromaticity.white_point.y);
705 if ((image->extract_info.width*image->extract_info.height) != 0)
706 (void) fprintf(file," Tile geometry: %lux%lu%+ld%+ld\n",
707 image->extract_info.width,image->extract_info.height,
708 image->extract_info.x,image->extract_info.y);
709 (void) fprintf(file," Interlace: %s\n",MagickOptionToMnemonic(
710 MagickInterlaceOptions,(long) image->interlace));
711 (void) QueryColorname(image,&image->background_color,SVGCompliance,color,
713 (void) fprintf(file," Background color: %s\n",color);
714 (void) QueryColorname(image,&image->border_color,SVGCompliance,color,
716 (void) fprintf(file," Border color: %s\n",color);
717 (void) QueryColorname(image,&image->matte_color,SVGCompliance,color,
719 (void) fprintf(file," Matte color: %s\n",color);
720 (void) QueryColorname(image,&image->transparent_color,SVGCompliance,color,
722 (void) fprintf(file," Transparent color: %s\n",color);
723 (void) fprintf(file," Compose: %s\n",MagickOptionToMnemonic(
724 MagickComposeOptions,(long) image->compose));
725 if ((image->page.width != 0) || (image->page.height != 0) ||
726 (image->page.x != 0) || (image->page.y != 0))
727 (void) fprintf(file," Page geometry: %lux%lu%+ld%+ld\n",image->page.width,
728 image->page.height,image->page.x,image->page.y);
729 if ((image->page.x != 0) || (image->page.y != 0))
730 (void) fprintf(file," Origin geometry: %+ld%+ld\n",image->page.x,
732 (void) fprintf(file," Dispose: %s\n",MagickOptionToMnemonic(
733 MagickDisposeOptions,(long) image->dispose));
734 if (image->delay != 0)
735 (void) fprintf(file," Delay: %lux%ld\n",image->delay,
736 image->ticks_per_second);
737 if (image->iterations != 1)
738 (void) fprintf(file," Iterations: %lu\n",image->iterations);
739 if ((image->next != (Image *) NULL) || (image->previous != (Image *) NULL))
740 (void) fprintf(file," Scene: %lu of %lu\n",image->scene,
741 GetImageListLength(image));
743 if (image->scene != 0)
744 (void) fprintf(file," Scene: %lu\n",image->scene);
745 (void) fprintf(file," Compression: %s\n",MagickOptionToMnemonic(
746 MagickCompressOptions,(long) image->compression));
747 if (image->quality != UndefinedCompressionQuality)
748 (void) fprintf(file," Quality: %lu\n",image->quality);
749 (void) fprintf(file," Orientation: %s\n",MagickOptionToMnemonic(
750 MagickOrientationOptions,(long) image->orientation));
751 if (image->montage != (char *) NULL)
752 (void) fprintf(file," Montage: %s\n",image->montage);
753 if (image->directory != (char *) NULL)
769 Display visual image directory.
771 image_info=AcquireImageInfo();
772 (void) CloneString(&image_info->size,"64x64");
773 (void) fprintf(file," Directory:\n");
774 for (p=image->directory; *p != '\0'; p++)
777 while ((*q != '\n') && (*q != '\0'))
779 (void) CopyMagickString(image_info->filename,p,(size_t) (q-p+1));
781 (void) fprintf(file," %s",image_info->filename);
782 handler=SetWarningHandler((WarningHandler) NULL);
783 tile=ReadImage(image_info,&image->exception);
784 (void) SetWarningHandler(handler);
785 if (tile == (Image *) NULL)
787 (void) fprintf(file,"\n");
790 (void) fprintf(file," %lux%lu %s\n",tile->magick_columns,
791 tile->magick_rows,tile->magick);
792 (void) SignatureImage(tile);
793 ResetImagePropertyIterator(tile);
794 property=GetNextImageProperty(tile);
795 while (property != (const char *) NULL)
797 (void) fprintf(file," %s:\n",property);
798 value=GetImageProperty(tile,property);
799 if (value != (const char *) NULL)
800 (void) fprintf(file,"%s\n",value);
801 property=GetNextImageProperty(tile);
803 tile=DestroyImage(tile);
805 image_info=DestroyImageInfo(image_info);
807 (void) GetImageProperty(image,"exif:*");
808 ResetImagePropertyIterator(image);
809 property=GetNextImageProperty(image);
810 if (property != (const char *) NULL)
813 Display image properties.
815 (void) fprintf(file," Properties:\n");
816 while (property != (const char *) NULL)
818 (void) fprintf(file," %c",*property);
819 if (strlen(property) > 1)
820 (void) fprintf(file,"%s: ",property+1);
821 if (strlen(property) > 80)
822 (void) fputc('\n',file);
823 value=GetImageProperty(image,property);
824 if (value != (const char *) NULL)
825 (void) fprintf(file,"%s\n",value);
826 property=GetNextImageProperty(image);
829 (void) FormatMagickString(key,MaxTextExtent,"8BIM:1999,2998:#1");
830 value=GetImageProperty(image,key);
831 if (value != (const char *) NULL)
834 Display clipping path.
836 (void) fprintf(file," Clipping path: ");
837 if (strlen(value) > 80)
838 (void) fputc('\n',file);
839 (void) fprintf(file,"%s\n",value);
841 ResetImageProfileIterator(image);
842 name=GetNextImageProfile(image);
843 if (name != (char *) NULL)
849 Identify image profiles.
851 (void) fprintf(file," Profiles:\n");
852 while (name != (char *) NULL)
854 profile=GetImageProfile(image,name);
855 if (profile == (StringInfo *) NULL)
857 (void) fprintf(file," Profile-%s: %lu bytes\n",name,(unsigned long)
858 GetStringInfoLength(profile));
859 #if defined(MAGICKCORE_LCMS_DELEGATE)
860 if ((LocaleCompare(name,"icc") == 0) ||
861 (LocaleCompare(name,"icm") == 0))
866 icc_profile=cmsOpenProfileFromMem(GetStringInfoDatum(profile),
867 (cmsUInt32Number) GetStringInfoLength(profile));
868 if (icc_profile != (cmsHPROFILE *) NULL)
870 #if defined(LCMS_VERSION) && (LCMS_VERSION < 2000)
874 name=cmsTakeProductName(icc_profile);
875 if (name != (const char *) NULL)
876 (void) fprintf(file," %s\n",name);
881 (void) cmsGetProfileInfoASCII(icc_profile,cmsInfoDescription,
882 "en","US",info,MaxTextExtent);
883 (void) fprintf(file," Description: %s\n",info);
884 (void) cmsGetProfileInfoASCII(icc_profile,cmsInfoManufacturer,
885 "en","US",info,MaxTextExtent);
886 (void) fprintf(file," Manufacturer: %s\n",info);
887 (void) cmsGetProfileInfoASCII(icc_profile,cmsInfoModel,"en",
888 "US",info,MaxTextExtent);
889 (void) fprintf(file," Model: %s\n",info);
890 (void) cmsGetProfileInfoASCII(icc_profile,cmsInfoCopyright,
891 "en","US",info,MaxTextExtent);
892 (void) fprintf(file," Copyright: %s\n",info);
894 (void) cmsCloseProfile(icc_profile);
898 if (LocaleCompare(name,"iptc") == 0)
919 profile_length=GetStringInfoLength(profile);
920 for (i=0; i < (long) profile_length; i+=(long) length)
923 sentinel=GetStringInfoDatum(profile)[i++];
924 if (sentinel != 0x1c)
926 dataset=GetStringInfoDatum(profile)[i++];
927 record=GetStringInfoDatum(profile)[i++];
930 case 5: tag="Image Name"; break;
931 case 7: tag="Edit Status"; break;
932 case 10: tag="Priority"; break;
933 case 15: tag="Category"; break;
934 case 20: tag="Supplemental Category"; break;
935 case 22: tag="Fixture Identifier"; break;
936 case 25: tag="Keyword"; break;
937 case 30: tag="Release Date"; break;
938 case 35: tag="Release Time"; break;
939 case 40: tag="Special Instructions"; break;
940 case 45: tag="Reference Service"; break;
941 case 47: tag="Reference Date"; break;
942 case 50: tag="Reference Number"; break;
943 case 55: tag="Created Date"; break;
944 case 60: tag="Created Time"; break;
945 case 65: tag="Originating Program"; break;
946 case 70: tag="Program Version"; break;
947 case 75: tag="Object Cycle"; break;
948 case 80: tag="Byline"; break;
949 case 85: tag="Byline Title"; break;
950 case 90: tag="City"; break;
951 case 95: tag="Province State"; break;
952 case 100: tag="Country Code"; break;
953 case 101: tag="Country"; break;
954 case 103: tag="Original Transmission Reference"; break;
955 case 105: tag="Headline"; break;
956 case 110: tag="Credit"; break;
957 case 115: tag="Src"; break;
958 case 116: tag="Copyright String"; break;
959 case 120: tag="Caption"; break;
960 case 121: tag="Local Caption"; break;
961 case 122: tag="Caption Writer"; break;
962 case 200: tag="Custom Field 1"; break;
963 case 201: tag="Custom Field 2"; break;
964 case 202: tag="Custom Field 3"; break;
965 case 203: tag="Custom Field 4"; break;
966 case 204: tag="Custom Field 5"; break;
967 case 205: tag="Custom Field 6"; break;
968 case 206: tag="Custom Field 7"; break;
969 case 207: tag="Custom Field 8"; break;
970 case 208: tag="Custom Field 9"; break;
971 case 209: tag="Custom Field 10"; break;
972 case 210: tag="Custom Field 11"; break;
973 case 211: tag="Custom Field 12"; break;
974 case 212: tag="Custom Field 13"; break;
975 case 213: tag="Custom Field 14"; break;
976 case 214: tag="Custom Field 15"; break;
977 case 215: tag="Custom Field 16"; break;
978 case 216: tag="Custom Field 17"; break;
979 case 217: tag="Custom Field 18"; break;
980 case 218: tag="Custom Field 19"; break;
981 case 219: tag="Custom Field 20"; break;
982 default: tag="unknown"; break;
984 (void) fprintf(file," %s[%ld,%ld]: ",tag,dataset,record);
985 length=(size_t) (GetStringInfoDatum(profile)[i++] << 8);
986 length|=GetStringInfoDatum(profile)[i++];
987 attribute=(char *) NULL;
988 if (~length >= MaxTextExtent)
989 attribute=(char *) AcquireQuantumMemory(length+
990 MaxTextExtent,sizeof(*attribute));
991 if (attribute != (char *) NULL)
993 (void) CopyMagickString(attribute,(char *)
994 GetStringInfoDatum(profile)+i,length+1);
995 attribute_list=StringToList(attribute);
996 if (attribute_list != (char **) NULL)
998 for (j=0; attribute_list[j] != (char *) NULL; j++)
1000 (void) fputs(attribute_list[j],file);
1001 (void) fputs("\n",file);
1002 attribute_list[j]=(char *) RelinquishMagickMemory(
1005 attribute_list=(char **) RelinquishMagickMemory(
1008 attribute=DestroyString(attribute);
1012 if (image->debug != MagickFalse)
1013 PrintStringInfo(file,name,profile);
1014 name=GetNextImageProfile(image);
1017 ResetImageArtifactIterator(image);
1018 artifact=GetNextImageArtifact(image);
1019 if (artifact != (const char *) NULL)
1022 Display image artifacts.
1024 (void) fprintf(file," Artifacts:\n");
1025 while (artifact != (const char *) NULL)
1027 (void) fprintf(file," %c",*artifact);
1028 if (strlen(artifact) > 1)
1029 (void) fprintf(file,"%s: ",artifact+1);
1030 if (strlen(artifact) > 80)
1031 (void) fputc('\n',file);
1032 value=GetImageArtifact(image,artifact);
1033 if (value != (const char *) NULL)
1034 (void) fprintf(file,"%s\n",value);
1035 artifact=GetNextImageArtifact(image);
1038 ResetImageRegistryIterator();
1039 registry=GetNextImageRegistry();
1040 if (registry != (const char *) NULL)
1043 Display image registry.
1045 (void) fprintf(file," Registry:\n");
1046 while (registry != (const char *) NULL)
1048 (void) fprintf(file," %c",*registry);
1049 if (strlen(registry) > 1)
1050 (void) fprintf(file,"%s: ",registry+1);
1051 if (strlen(registry) > 80)
1052 (void) fputc('\n',file);
1053 value=(const char *) GetImageRegistry(StringRegistryType,registry,
1055 if (value != (const char *) NULL)
1056 (void) fprintf(file,"%s\n",value);
1057 registry=GetNextImageRegistry();
1060 (void) fprintf(file," Tainted: %s\n",MagickOptionToMnemonic(
1061 MagickBooleanOptions,(long) image->taint));
1062 (void) FormatMagickSize(GetBlobSize(image),MagickFalse,format);
1063 (void) fprintf(file," Filesize: %sB\n",format);
1064 (void) FormatMagickSize((MagickSizeType) image->columns*image->rows,
1065 MagickFalse,format);
1066 (void) fprintf(file," Number pixels: %s\n",format);
1067 (void) FormatMagickSize((MagickSizeType) ((double) image->columns*image->rows/
1068 elapsed_time+0.5),MagickFalse,format);
1069 (void) fprintf(file," Pixels per second: %s\n",format);
1070 (void) fprintf(file," User time: %0.3fu\n",user_time);
1071 (void) fprintf(file," Elapsed time: %ld:%02ld.%03ld\n",(long)
1072 (elapsed_time/60.0),(long) ceil(fmod(elapsed_time,60.0)),(long)
1073 (1000.0*(elapsed_time-floor(elapsed_time))));
1074 (void) fprintf(file," Version: %s\n",GetMagickVersion((unsigned long *)
1076 (void) fflush(file);
1077 return(ferror(file) != 0 ? MagickFalse : MagickTrue);